Getting proper unix user land tools on os x

Personally, I think the Mac OS X unix userland is rotten. There are apple tools mixed with some current unix tools and there are outdated unix tools like locate. Maybe you didn’t even notice that but locate for example doesn’t even know the -i option for case insensitive lookups in the locate.datbase. As usual, you can help yourself with MacPorts. Simply install the GNU coreutils and findutils. For convenience provide the +with_default_names option. If you don’t add this option you get glocate instead of locate and so on. Now the new locate can’t find anything unless you run updatedb from /opt/local/bin/updatedb. After that everything should be fine. Checkout what tools are included in coreutils and findutils by clicking on the equivalent hyperlinks. This resolves the weird behavior of tools on OS X that you might expect to work like on your FreeBSD or Linux machines.

Install coreutils (the -c option is equivalent to sudo port clean portname):

sudo port -c install coreutils +with_default_names
sudo port -c install findutils +with_default_names

Locate before the installation:

man locate
LOCATE(1) BSD General Commands Manual LOCATE(1)

NAME
locate -- find files

SYNOPSIS
locate pattern

DESCRIPTION…

and afterwards:

LOCATE(1) LOCATE(1)

NAME
locate - list files in databases that match a pattern

SYNOPSIS
locate [-d path | --database=path] [-e | -E | --[non-]existing] [-i |
--ignore-case] [-0 | --null] [-c | --count] [-w | --wholename] |-b |
--basename] [-l N | --limit=N] [-S | --statistics] [-r | --regex ]
[--max-database-age D] [-P | -H | --nofollow] [-L | --follow] [--ver-
sion] [-A | --all] [-p | --print] [--help] pattern...

DESCRIPTION…

I think you get the idea.

Cheating the hacker way

A couple of days ago I found this cute little game for OS X called »Chopper«. I played it several times but I couldn’t make it to the last level although I played it on »easy«. Since it is open source I thought I could compile it with more lives but unfortunetly it didn’t compile because the file libfmodUniversal.a was missing for some reason. Good to have hackers around though – with the help of one of them I used »gdb« to get the job done. This is what I did (with Chopper Version 1.04):

First download Chopper and its Source from majicjungle.com. Then I navigated to the source folder for chopper and started gdb in that directory with the executable path

$> cd /Volumes/Data/Downloads/Chopper_104_src/Source
/Volumes/Data/Downloads/Chopper_104_src/Source $> gdb /Volumes/Data/Downloads/Chopper\ 1.0.4/Chopper.app/Contents/MacOS/Chopper

Then I set a breakpoint in playerStats.m on line 33. This is where the initial lives are set.

(gdb) break playerStats.m:33
Breakpoint 1 at 0x23ede: file /Users/davidframpton/Documents/Code/Old Projects/Chopper_104/Source/playerStats.m, line 33.

Then run the app:

(gdb) run
Starting program: /Volumes/Data/Downloads/Chopper 1.0.4/Chopper.app/Contents/MacOS/Chopper
Reading symbols for shared libraries ............................................................................ done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries ... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done

Now click »new game« with whatever difficulty you prefer. Now press escape to switch to windowed mode so you can see the terminal output. As you can see gdb stopped at the breakpoint we set before:

Breakpoint 1, -[playerStats init] (self=0x17198290, _cmd=0x90a64924) at /Users/davidframpton/Documents/Code/Old Projects/Chopper_104/Source/playerStats.m:33
warning: Source file is more recent than executable.
33 lives = startLives;
(gdb)

Now press »n« to step into

(gdb) n
34 nextExtraLife = 2000;

If you now enter the following you see the original number of lives to start with:

(gdb) print lives
$1 = 4

Now set your preferred number of initial lives

(gdb) print lives=1000
$2 = 1000

Now enter »c« to continue

(gdb) c
Continuing.

Now switch back to Chopper and have endless fun! Cool huh?

Chopper with 1000 lives

Continue reading

Berlin – Brennende Autos und so

Wusstet ihr eigentlich, dass zur Zeit fast jede Nacht in Berlin Autos brennen? Kann man sich hier von überzeugen: http://www.berlin.de/polizei/presse-fahndung/presse.html
Es gibt auch einen RSS Feed

Im Kreuzberg formiert sich außerdem gerade Widerstand gegen eine geplante McDonalds Filiale. In der Zwischenzeit veranstaltet die Polizei Bundesweit Razzien bei potenziellen G8 Gipfels Störern und der Spiegel stellt überdies hinaus fest das die Republik nach links (link) rückt.

Zur Krönung verspricht unsere Kanzlerin, Frau Merkel, noch folgendes:

»Im Zusammenhang mit dem G8-Gipfel in Heiligendamm wird es sehr, sehr große Demonstrationen geben von Tausenden und Abertausenden friedlichen Demonstranten. Es gibt überhaupt nicht die geringste Besorgnis, dass diese Demonstrationen nicht auch abgehalten werden können und auch sehr stark unterstützt werden zum Teil von Popsängern und anderen mehr.«

(link)

Man könnte meinen es dauert nicht mehr lang bis nicht nur Autos brennen …

Hihi

Apple Wahlcomputer

Schon etwas älter aber dennoch lustig. Hier gibts noch mehr.

How to bind WEBrick to any IP address

I found several and somewhat complex solutions for this particular problem but actually it’s a no-brainer once you know. Simply type:

hukl$ script/server -h
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
Usage: server [options]
    -p, --port=port                  Runs Rails on the specified port.
                                     Default: 3000
    -b, --binding=ip                 Binds Rails to the specified ip.
                                     Default: 0.0.0.0
    -d, --daemon                     Make server run as a Daemon.
    -e, --environment=name           Specifies the environment to run
                                     this server under
                                     (test/development/production).
                                     Default: development

    -h, --help                       Show this help message.

The magic trick is to use sudo to start WEBrick, else the bind might not work and the webserver is unreachable for virtual machines or other hosts.

sudo script/server -b 10.0.2.1 -p 80

Yippeeh! Now I can test my Ruby on Rails projects, which are running on OS X, from my WinXP Paralles virtual machine using IE6 and IE7.

Continue reading