Today I had to import about ~150 file entries into an XML file. Being a good lazy geek, I could not resign myself to copy/paste this over. With the help of Rake and some custom-tailored scripts, I made it through in no time :)
APServiceBox: cross-dependency injection
APServiceBox had a little update today (v12.08.29). Now, when you call the fill: method for the first time, APServiceBox will first scan all its dependencies and fill them as well. Thus, you can have dependencies that depend on each other. All you have to do is register both dependencies into the container before you fill: your first object. Read on for an example.
Unix signal handling example
UNIX signals can occur in various situations. For example, when you hit ctrl-C in the terminal, a SIGINT (interrupt) is sent to the process. Likewise, when you want to kill for sure a process, you’ll send it the SIGKILL signal. Read below for an example of signal handling on UNIX systems, including sigaction, sigsuspend, sigprocmask et al.
Quicksort, mergesort and binary search in ruby
Sample implementation of quicksort, mergesort and binary search in ruby. The two sort algorithms operate in O(n * lg(n)) time, and the search in O(lg(n)) time. Theory can be found in these slides on quicksort and mergesort by Princeton. And for the practical point of view, have a look at the code of this article :)
Binomial heap in ruby
Sample implementation of a binomial heap (or “priority queue”) in ruby. Read these excellent slides about heaps from Princeton for theory. And see my source code for practice :)