Sunday, September 14, 2008

A Nice Summary of Ruby MetaProgramming

Check out this simple introduction to metaprogramming. I have an article bubbling away in my head about why in .Net I need tools like NDependencyInjection, but in ruby you don't.

You really do need tools like NDependencyInjection in .Net by the way.. I'll explain that too.

MapReduce in Ruby

Some guys at Google came up with this idea of specifying a set of problems as two stages processes.

Step 1: Map (come up with a mapping function that takes a key value pair and maps it to a new set of key value pairs)
** do this for all key value pairs **
Step 2: Reduce (for each of the new key values, take all values and reduce them down to a single value)

Any problem that can be broken down into these steps can be parallelized really easily and scales well by adding more boxes.

An example may be 'Count word occurrence on the web'
Mapping: [word, url] => for each occurrence of 'word' in document@url add an item to an output hash for value 'word'
Reduce : [word, values] => number of items in value list 'values'

Anyway... lots of problems can be defined in this way... the code that runs your map/reduce functions for you can solve all sorts of problem handling networking issues, machine loading, etc...

Blaine Cook wrote a version in ruby here. Or see mapreducerb@github

I can't wait to have a play with this.

Saturday, September 13, 2008

Maximize window in osx

Finally someone has got some scripts together to maximise windows in osx.

OSX has this weird idea that you want to see lots of windows at once. "Maximizing" a window therefore means make it big enough to show the content of the window, but not too big. This leaves the application to decide how big is big enough. Some apps do this fine... others (like Preview) keep getting it wrong.

Grab these scripts form git hub. From a terminal type "rake install", then type "rake install_fastscripts" so you can map the scripts to keys easily. Once you have this working map Maximise to something like Ctrl + Apple + M and you can now make one app take over the whole screen.

THANK YOU TopFunky THANK YOU!

A couple of the scripts are hardcoded to use Terminal, so I have forked the repository for my own edification. I also want to fix a problem with the scripts expecting the draws to be on the right hand side of a window.. which it isn't always.

Lisp in Ruby... amazing

http://onestepback.org/index.cgi/Tech/Ruby/LispInRuby.red

You have to check this out if you have any interest in programming languages at all.

GitHub Projects