> sudo gem install ramaze
- ab is the Apache Bench executable itself (found in /usr/sbin on my machine)
- -n 100 tells it to send the request 100 times
- -c 4 tells it to use 4 concurrent threads to do so
- finally we have the URL itself.
Even though it's simple, there are some important gotchas worth knowing about:
- Remember to put the URL in single quotes if it contains characters that would otherwise be interpreted by the shell. This is often the case for any URL with a query string, as the & characters will mess things up otherwise.
- If using a base URL for a site (just host name), you must use a trailing slash. http://foo.com doesn't work, but http://foo.com/ does work.
- Quite often you may see in the statistics "Failed requests: 5" or similar, followed by a list of the types of failure: "(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)". If the only type of failure that actually occurred is 'Length' then don't be alarmed. This simply means that each request (for the same URL) returned a different length response, which ab regards as suspicious. However it's perfectly normal for dynamic webpages, especially if they include the time or other very dynamic data on the page.
- I find on one of my machines that it just doesn't like localhost as a hostname, so I have to use 127.0.0.1 instead. I have no idea why, as localhost works fine in other contexts on the same machine.
Rather mysteriously, my bluetooth mouse suddenly stopped responding with no warning. I assumed it was duff batteries, though I'd normally get a warning a good while before they conk out completely. Changed them, but still no dice. I attached a wired mouse and did some digging – basically Bluetooth no longer seemed to exist on my Mac! The menubar widget claimed bluetooth was 'not available' and the System Preferences Panel said similar. Restarting didn't help – in fact it made the menubar widget and System Preferences Panel disappear entirely!
- sudo mv /var/root/Library/Preferences/blued.plist ~/Desktop/
At the same time I shutdown the computer, removed all attached cables, opened it up and pressed the PMU/SMC reset button down near the RAM (this is a PowerMac G5 tower) then restarted. It seems to be OK for now. It did mean the clock resetting to 1970 and me having to wait for all my iCal notifications to stream in once I'd reset to 2009.
I've been experimenting with Ruby 1.9.1 and trying to make it my natural home recently. Crucial to that was getting the mysql gem installed. Actually it's fairly straightforward with the 2.8.1 version of the gem and only very minor mods to the official instructions at http://www.tmtm.org/en/mysql/ruby/ were required.
- Downloaded 2.8.1 source tgz from RubyForge, linked from http://www.tmtm.org/en/mysql/ruby/ downloads section.
- Expanded the tgz with Finder, then opened a command prompt…
- > cd mysql-ruby-2.8.1
- > ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config -with-mysql-dir=/usr/local/mysql
- > make
- > sudo make install
I've been following the progress of MacRuby for a few months now and was looking forward to the next release. Finally, and a month or three after it was expected, MacRuby 0.4 is here, according to the MacRuby blog.
MacRuby is, to keep it simple, an implementation of Ruby 1.9 built in Objective-C with transparent calling between the ruby and Obj-C worlds. For instance Ruby Strings are actually NSStrings in MacRuby and have all the powers of both. This along with some other neat integrations provided by the team allow you to write Mac OS X Cocoa apps using Ruby instead of Obj-C, or even a combination of both. If like me you think that Obj-C is a dinosaur that doesn't deserve a place in the modern programming world, this is great news. There seems to be a lot of momentum behind this project and I wonder if it may eventually become quite a fully fledged citizen for Mac app programmers – maybe even ultimately taking over from Obj-C for most Mac OS X development. I can but hope.
One of the many neat improvements in 0.4 is the ability to bundle the MacRuby runtime into the app itself so the user need be none the wiser, and certainly doesn't need to install MacRuby.