go-left Software Rotating Header Image

Extending IKEA UTBY legs to 21cm and beyond

The IKEA UTBY legs (part# 901.289.71) are a bit short for a free standing cook island with a countertop of more than 90cm. To make them 21cm (95cm countertop) or longer and keep them stable you can get a long M8 screw (200 cm in the hardware store), saw it into pieces of 4 cm and add them to the leg using a coupling screw. Takes 10 min for the sawing and approximately 15 EUR in parts. The only downside is that you can’t use the lower part which would hide the screw. If you have a plinth which hides the legs this isn’t an issue.

node.js and hook.io

The more I look into node.js the more it looks like a game-changing ubiquitous tool since I find a lot of tools which are not just web applications but completely different things like the JavaScript code compressor UglifyJS. These are things you wouldn’t find or even consider looking for Apache Tomcat or jetty for example if you look at node.js as merely an application server – which it isn’t.

With hook.io from nodejitsu I have found another  tool which uses node.js in an interesting way. hook.io is basically a message broker on steroids – although currently a limited one. By using the hook.io module one creates a cluster of machines to which hook.io distributes events. The cool thing is that integrating hook.io is dead-simple and one can start writing event handlers for distributed events within minutes using a handful lines of code. The approach suggested by nodejitsu is to develop backend applications as separate node.js modules where each module responds to one or more distributed events.

By leveraging the socket.io library the hook.io library provides auto-discovery of hook modules (called hooks), election of a master and failover if the master dies. Since both the browser and the server are using JavaScript and JSON it is also possible to use hook.io directly in the browser via web sockets.

hook.io shows the flexibility of node.js which also changes my awareness again of node.js not  being a mere application server.

There are two areas where I am a bit skeptical about hook.io right now. The first thing I am missing are queues which allow to deliver an event to one and only one of a group of listeners. The typical use case for this is load balancing and failover. Imagine five machines running an EmailSender process which consumes a sendEmail event. A producer wants to send one and only one email when triggering the sendEmail event. For that the master server has to queue the events, keep track of the listeners and forward them to one of the active ones. Right now hook.io broadcasts all events to all connected listeners and the listener decides whether it wants to handle the event.

That is the second issue is about the current hook.io event distribution architecture since the events are distributed to all listeners. This can create quite some chatter between the servers. Traffic may not necessarily the issue here but latency since it should make a difference whether an event is distributed to all 1,000 listeners or just the 10 who are actually interested in it. This approach makes the server dead simple and failover a breeze but it may be a bit too simple. Time and experience will tell.

There are message brokers like ActiveMQ out there which also offer node.js support via stomp.js and native web socket/AJAX support. So there are alternatives but I am sure the node.js community will come up with a full fledged message broker which can compete with ActiveMQ and others and I think this will be rather sooner than later.

We are living in interesting times.

Speeding up my MacBookPro with an SSD

Update (23 Jul 2012): I’ve found this blog post from Martin Matula which describes a lot of good tips on how to optimize OSX Lion for an SSD.

 

I’ve got a 2 year old MacBook Pro from early 2009 with a nice 17″ screen, a 2.93 GHz Intel Core 2 Duo CPU, 4GB RAM and a 320 GB hard disk. Type: MacBookPro5,1. So when the display and logic board broke I’ve briefly considered buying a new machine but replacing this laptop would not be cheap.

So I’ve decided to have the machine fixed, upgrade the RAM to 8GB and to replace the 320 GB HD with a Crucial m4 256 GB SSD. For copying the data from the HD to the SSD and for future access to unlimited storage I’ve also purchased a Sharkoon Quickport Duo II which is an USB 2.0/eSATA docking station for two 2.5″/3.5″ SATA disks and a Sonnet Tempo edge eSATA Express/34 card (the 3GBit version with port multiplier functionality. The Sharkoon Quickport Duo is compatible with it).

The total cost was:

256GB SSD: 300 EUR
8 GB RAM: 50 EUR
SATA docking station: 35 EUR
eSATA Express/34 card: 50 EUR
Total: 435 EUR

Continue reading →

JavaScript Inheritance and Public/Private members

JavaScript as a prototyped language does not have native support for classes and classical inheritance through language constructs. Nevertheless programmers have tried to model the constructs in various ways. Some ideas can be found at Douglas Crockford, John Resig, Nicholas C. Zakas, Ben Nadel and others as well. A good overview is in Chapter 3 of “Pro JavaScript Design Patterns” from Ross Harms and Dustin Diaz. Also the video series from Crockford in the YUI Theater gives a good overview of the language and Part III – Function, the Ultimate explains his approaches for class creation and inheritance.

After doing some research and experimentation I’ve settled on the following model which incorporates inheritance, class level (aka static) methods and memberspublic and private methods and members, constructors with arguments and integration into requirejs. I’ll first show the pattern and then discuss the pros and cons.

Continue reading →

ghettoUI – Interactive backups for VMware’s free ESXi

Recently I’ve helped my ISP in Cameroon to set up a virtualized infrastructure for his internal datacenter. Power costs are a real issue and the largest cost factor besides bandwidth which is unbelievably expensive. Spare parts and somewhat recent servers are hard to get if you can get them at all. Purchasing in Europe or in the US incurs hefty shipment fees and customs wants its 30% plus whoever you have to bribe to speed up the process.

Needless to say that expensive software licenses are out of the question as well. Usually you counter such license costs with open-source solutions as well as trained and dedicated staff. Finding and keeping such people seems to be a real issue in this country so it’s not a viable option. I’ve decided to go with VMware’s free ESXi 4.1 hypervisor since the staff already had some experience with the tools and since its mainly a Windows shop and the initial tests with Citrix Xen Server 5.5 were mostly discouraging.

The problem with choosing ESXi 4.1 is that VMware has stripped the free version of useful features almost up to the point where it is completely useless. This is underlined by the fact that VMware will restrict the next free ESXi version to 8GB of physical RAM. However, one of the main issues is that there are no tools from VMware to create a backup of a virtual machine in a reasonable way and a reasonable amount of time. Copying files off of the VMware server using the datastore browser is error prone and takes forever.

Continue reading →

How to write a Long Polling Event Push Server with node.js

For one of my JavaScript projects I’ve needed a push technology to push server events to my web clients. After looking at several options I’ve decided to write a long polling server with node.js. I am going to explain step by step how I’ve done that. Feedback is welcome.

Read more …

CouchDB: The Definitive Guide in German

I’ve recently started reading the draft version of the CouchDB: The Definitive Guide and liked the book instantly. It is well written, nicely paced and leads you from the motivation of the developers to the design decisions on how to do things with a document based database.

Having written countless Java based server applications over the last 15 years which all use some kind of relational database I must admit their approach looks refreshing. It has a certain appeal to cut out the middleman in the Java application stack and to finally get rid of Hibernate.

Although I am not sure whether CouchDB can live up to its promise the approach sounds interesting, the book is well written and I got another project for which I was just starting to use a MySQL database scheme, Spring, … I think it is a good opportunity to try something new to see how it works.

As for the book and its translation: It is currently available in English only but the authors encourage people to create a translation. Well, here is a chance of giving something back to the community after using open source software for so many years. Being a native German speaker who has written more documentation than I want to remember I am giving it a shot at translating the book.

Although I’m still struggling with git I want to make the updates available as quickly as possible. Once the translation is done I’m going to push the changes into their original repository for others to feast on it.

http://guide.couchdb.org/editions/1/de/index.html

You can follow updates to the translation on Twitter at

http://twitter.com/goleftcom

Happy reading 🙂
Frank

100 Little Programming Exercises

If you want to learn how to write software – whether you are new to it or learning a different language – I often find it useful to write a number of little programs of small to medium complexity to get used to the syntax, the concepts and the tool chain. However, a lot of books have a small set of examples to illustrate the concepts of the language with the solution mostly given in the book.

I remember my high-school days when our CS teacher would give us 100 little programming exercises to solve in the upcoming weeks. The problems were of small to medium complexity but they helped us to demystify the art of software development. After all, the 26th program isn’t so difficult if you have just written 25 other little programs. It helped us to focus on the problem instead of the language and the tools.

While being in Cameroon I have the opportunity to teach people on computer science, system administration and programming in general. Getting hands-on experience in an environment where not everybody has a computer and internet is scarce and expensive and the basic education lacks practical training is an issue.

I’ve rummaged through the internet but couldn’t really find anything useful and I also like the idea of creating such a list myself. So I’ve decided to start the 100 little programming exercises for my students, myself and maybe others. While you are learning and you are ready to write some code you can turn to the list to have some problems to solve.

The exercises can be solved in almost any programming language. They don’t have a particular order or grouping. Just pick any which is of interest to you and start solving it.

Solutions are not provided as you can and should test yourself whether the program works as you think it should. Second, I could only provide solutions in one or two languages of my liking and that might not be the one you are trying to learn.

If you are new to programming these exercises should help you to develop analytical sense to dissect a problem and come up with an approach to solving it.

Some of the problems are a bit more complex and you find explanations on Wikipedia. But don’t cheat yourself by copying somebody else’s solution. The purpose is to solve the problem and learn how to do it.

Although the page is titled ‘100 Little Programming Exercises’ I am still working on the exercises. At some day I hope to get to an even hundred or even beyond. If you have a good idea for an exercise I’m happy to include it with your name if it fits.

But now without further ado: 100 little programming exercises

Happy coding 🙂

Frank

Hello World!

Welcome to the go-left Software blog. If you want to know more about go-left have a look at the About page.

Frank