Sun SPOT

Sun Microsystems released their Small Programmable Object Technology (SPOT) as open source earlier this year. SPOT fits in the same category as the Bug Labs BUG that I’ve previously blogged about. SPOT seems to be less modular than the BUG. Both platforms are Java based (SPOT is J2ME) and they also feature some of the same type of hardware. The Sun SPOT device measures 70 x 41 x 23 mm and contains features the following hardware sweetness:

  • IEEE 802.15.4 (forms the basis for ZigBee) with integrated antenna
  • 3-axis accelerometer (with two range settings: 2G or 6G)
  • Temperature sensor
  • Light sensor
  • Tri-color LEDs
  • 6 analog inputs readable by an ADC
  • 2 momentary switches
  • 5 general purpose I/O pins and 4 high current output pins

SPOT’s main advantage over the BUG is that it has built-in communication. Bug Labs are probably hard at work to build a communication module as well to make it more desirable.

Edit (2008-07-19): Clarified the relation between IEEE 802.15.4 and ZigBee.

Lego bug

Bug Labs has developed a modular mini-computer running on open source software. I first read about it in the O’Reilly Radar blog. Bug Labs has promised to make all the source code for the platform available. The main BUGbase module is 10×5 cm big and can accommodate four other modules, each 5×5 cm big.

The system isn’t completely finished, but soon it will be possible to buy the base module and other modules like:

  • BUGlocate – GPS receiver.
  • BUGcam2MP – 2 megapixel digital camera.
  • BUGview – 2.46″ 320×240 pixels LCD screen.
  • BUGmotion – A combined motion detector and accelerometer.

The base module will eventually have built-in WiFi and hopefully they will also make a UMTS (3G) communication module. Applications are developed using Java together with an Eclipse based IDE. I’m very interested to see what kind of applications people might come up with for this thing.

It’s like Lego for grownups.

New guy

The new title of this blog was slightly inspired by Jeff Dunham’s performance in this video (impatient people may skip to 07:04):

Eclipse CDT and shared libraries

I had some trouble getting Eclipse CDT (C/C++ Development Toolkit) to work across separate projects. My setup is Eclipse 3.3.1 with CDT 4.0.1 on Windows with the MinGW toolchain. I have two separate projects in Eclipse: One is a shared library and the other is an executable. The executable uses the shared library so naturally it needs to read the header files from the other project in order to sucessfully compile and link. It would also be nice if it was possible to use the Run As Local C/C++ Application feature without the need to copy the shared library file to the directory where the executable file is. I set out on a quest to find the answers.

The first thing you have to do is right-click on the executable project in the Project Explorer, and then go to Properties -> Project References. There you have to select the shared or static library project you want to link to. Then click OK. If you try to build the project it still won’t work because it cannot find the required files.

Let’s open the project properties window again, but this time go to C/C++ General -> Paths and symbols -> References. Make sure that you select the shared/static library under all your configurations. The standard setup contains the Debug and Release configurations which you can switch between with the dropdown list at the top of the window. To make sure that you always link against the Release version of the library when you build the Release version of your executable you can expand the library reference node and select Release instead of the default [Active] selection. The same thing goes for building against the Debug version of the library when you’re building the Debug version of the executable. Click Apply when you’re done.

You might think that everything should be good to go by now, but we have a bit more to do first. In the project properties window go to C/C++ Build -> Settings -> Tool settings -> MinGW C++ Linker -> Libraries. Click the document with the green plus sign (Add button) right next to where it says Libraries (-l). In the input box that appears you should type the name of the library without its file extension. If your library file is “useful.dll” or “useful.so” then you should only type “useful”. Don’t forget that you have to do this for both the Release and Debug configurations if you don’t want any nasty surprises later on. Click OK when you’re done.

At least now it should compile, but you would maybe like to run it from within Eclipse as well? First you have to create a so called run configuration for your executable. Right-click on the executable in the Project Explorer and go to Run As… -> Local C/C++ Application. This will actually launch the program, but it will also automatically create a run configuration for it. The program will terminate without any error messages because it couldn’t find the library file. On the top menu go to Run -> Open Run Dialog…, select the run configuration for your program (if it isn’t already selected, obviously) and go to the Environment tab. Click New…, name the new environment variable “Path” and give it the value “${env_var:Path};${workspace_loc:/useful/Debug}”. Substitute “useful” for the name of your shared library. This will modify the system environment “Path” variable by adding the full path to the library so that the executable will find it.

If you want to use the Release version of the library then just substitute “Debug” from the environment value with “Release”. Unfortunately I haven’t found a way to detect which build configuration is active so you have to manually change this value if you switch between Debug and Release. An alternative is to create a separate run configuration for Debug and Release. This can easily be done by right-clicking on the run configuration and clicking Duplicate.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Guns and ammo

In C, you merely shoot yourself in the foot.

In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can’t tell which are bitwise copies and which are just pointing at others and saying, “That’s me, over there.”

Borrowed from: Const Correctness in C++

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Ubuntu-licious

I’ve been trying to setup AWStats in Windows, but it was a real pain in the butt. A lot of packages had to be fetched manually to get the functionality I wanted. I also needed a way to automate the updating of the statistics website by periodically downloading an Apache log file from an FTP server, append it to the main log and run the AWStats update procedure. And let’s not forget the need to publish the webpages created by AWStats. Ironically enough the easiest way I know how to do this is by bringing Linux to the Windows platform by installing Cygwin (a Linux emulation layer).

At this point I was well aware of the amount of unnecessary complexity this system would have. It would be a pain to ensure it’s long term reliability, and a house of cards like this would likely crumble under the lack of maintainability. If somebody had to recreate the entire setup there would be way too many steps where things could go wrong.

My final solution was to take a few steps back and install VMWare Server and create a new virtual machine with Ubuntu Server 7.04 with the LAMP (Linux, Apache, MySQL, PHP) option. After the Ubuntu Server installation was complete I ran “apt-get update”, “apt-get install awstats”, “apt-get install libnet-ip-perl” and edited the awstats.conf file. Then I wrote a simple cron script where wget will fetch the log from the remote server and the AWStats web pages will be updated automatically.

With Ubuntu Server and VMWare already downloaded it took me about one hour to install and configure the whole thing. If the entire system needs to be moved to another machine this can easily be accomplished. Simply install VMWare Player on the other machine and move the virtual machine folder and you’re done. It’s fast and simple, and with the successful Debian package management system used by Ubuntu we have built one sexy package.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Probabilities for an extended ticket lottery – revised

This paper updates the original with a section on expected winnings, a conclusion, simplified Equation 3 and a lot of rewriting through the whole thing to make it more consistent.

NOTE: This post has been imported from my old it’s learning ePortfolio readables blog.

ePolio اثنين

In my previous post I shared a few of my complaints on the ePortfolio system.

I’m not done complaining yet.

Since my last post I’ve noticed that it’s problematic (read: impossible) to upload attachments in Firefox or Opera, but somehow IE always works. Seriously, it can’t be that hard to properly implement the upload feature that it had to be made IE only.

And also a ticking time bomb of sorts: Anonymous comments = gigantic spam magnet

Footlike notes

1 اثنين is Arabic for the number 2 according to translate.google.com, and also “Jan Magne” is apparently “Magnetic” if translated to Chinese and back into English. Magnificent!

Edit: Google “fixed” the translation so now it returns “January magne” although “Magnificent” will currently return “Majestic”. I enjoy to mess with those translation services.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Probabilities for an extended ticket lottery

This paper describes an extended ticket lottery model with an upper bound on the number of tickets and how to maximize the probability of success. The lottery works on the basis that there will always be one and possibly two winners each round even though there are more tickets in the pool than the number of tickets distributed to the participants.

It can be compared to a competition where participants guess a number and the winner is the one who made the best guess. This way the winner does not necessarily have to guess the exact number, but must be the one who guessed the closest number. If the range within where the winning number is chosen is known in advance and nobody can is allowed to pick the same number the probabilities are as described in this paper (probably).

The method of maximizing the probability of success was intended to be used for the type of ticket lotteries being run in the online game Jottonia.

The beauty (read: inherent uglyness) of these results is how Equation 3 takes care of calculating unused tickets covered by a picking the ticket in the middle of a gap. Honestly, there must be a simpler formula which does the same job.

NOTE: This post has been imported from my old it’s learning ePortfolio readables blog.

it’s what-is-it ePolio?

Dedicated to Stargate SG-1, rest in peace. Yes dammit, I’m one of those raving lunatics.

The whole ePortfolio feature for it’s learning is a pretty sweet idea. The problem, of course, is the transformation of this idea to something people can actually use. This is the fundamental problem of all software development. Converting this perfect abstraction that only ever existed in your mind into something that works in the real world is no small feat. Not surprisingly it often doesn’t workout quite like you imagined. At least not on the first try (hint: prototyping does wonders). The problem is that you think you know all the details that are essential for this idea to be converted into a more solid form. Well you don’t, because if you did then you would most likely have implemented it already.

Let me borrow a few words from our mutual friend, Joel Spolsky, to elaborate:

“You can only see at a high-resolution in a fairly small area, and even that has a big fat blind spot right exactly in the middle, but you still walk around thinking you have a ultra-high resolution panoramic view of everything. Why? Because your eyes move really fast, and, under ordinary circumstances, they are happy to jump instantly to wherever you need them to jump to. And your mind provides this really complete abstraction, providing you with the illusion of complete vision when all you really have is a very small area of high res vision, a large area of extremely low-res vision, and the ability to page-fault-in anything you want to see—so quickly that you walk around all day thinking you have the whole picture projected internally in a little theatre in your brain.

[...]

One of the unfortunate side effects is that your mind gets into a bad habit of overestimating how clearly it understands things. It always thinks it has The Big Picture even when it doesn’t.

This is a particularly dangerous trap when it comes to software development. You get some big picture idea in your head for what you want to do, and it all seems so crystal clear that it doesn’t even seem like you need to design anything. You can just dive in and start implementing your vision.”

Don’t think you know how to implement it before you’ve done it at least once. Then you can throw the prototype away and do it better. Because now you know that the intricate class hierarchy you designed was just to damn backwards and the API your application exposed was way too inconsistent. Designing it first doesn’t hurt either.

The reason I mention this is of course because I’m a little disappointed with the implementation of the ePortfolio.

  • The Java editor will often mess things up when you try to do fancy things like inserting quotes, code snippets, bulleted lists or possibly other formatting changes. Luckily it’s possible to edit the underlying HTML to correct these things, but not all people are well versed enough in HTML to do that.
  • There is also an issue with other skins than the original in most browsers, at least IE, Firefox and Opera.
    • Text in bulleted list suddenly becomes much bigger than regular text (funky font tags automatically insert by the editor).
    • Depending on the skin certain components of the design will appear to hide other parts of the layout.
  • You can’t change the page title so you’re stuck with “it’s learning ePortfolio” which is not very helpful when your trying to identify the correct page in the taskbar or on a search engine.
  • Badly formatted RSS feeds that doesn’t play well with most, if not all, RSS readers.
    • it’s learning claims to be the copyright holder of all content published in the blog with the current copyright tag.
    • The link tag only contains an URL relative to www.itslearning.com.
    • Doesn’t specify your name as the author of the feed items.
  • Unable to set it to only display the latest post on the “front page”. The lower bound of the “Show at most entries” setting is 2, which is the same limit placed on the “Show at most days”.
  • No easy way to navigate between the next and previous posts and no overview of posts (list of post titles).
  • Security concerns.

Yes, I definitely need to start looking for other ways to do this blog thingy. WordPress looks like a promising alternative.

Just remember, when someone tells you they know exactly how they are going to go about implement something, say nothing and slowly step backwards until you are clear of the danger. It may save your life! What you don’t know, can and will hurt you, and it happens to do so at the moment it will hurt the most. Murphy 101.

And: “It’s the thought that counts”.

What does that mean? How do you expect to quantify the value of a thought?

No, let’s not.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.