SuperEnvelope
March 29th, 2008
I just bought the song.
Wollmilchsau
March 29th, 2008
iPhone Bug
March 27th, 2008
Big Dog
March 20th, 2008
Disk Space and Installer.app Problems after JB 1.1.3
January 29th, 2008
Because the 1.1.3 firmware seems to take up more space on the system partition than 1.1.2, you quickly start running into disk space problems.
To solve these problems (like the Installer jumping to Springboard while installing a package) you can move your applications folder to the media partition, here is how:
Connect to your iPhone using SSH and issue the following commands.
cp -r /Applications /private/var/
rm -r /Applications
ln -s /private/var/Applications /
chmod +s /Applications/Installer.app/Installer
Close your SSH session.
You should now be able to run all applications and install new ones.
You could take on 22 five year old kids in a fight.
December 14th, 2007
Display all Rails ActiveRecord Attributes
November 28th, 2007
By accident I just found out that if you type the ActiveRecord model name in your Rails console session (script/console), it prints out all the attributes of your model.
Now more trips to your database, to find out how attributes are named!
Delayed:netmonic schmidp$ script/console
Loading development environment (Rails 1.99.0)
>> XenServer
=> XenServer(id: integer, hostname: string,
created_at: datetime, updated_at: datetime, slots: integer,
created_by: integer, updated_by: integer)
>> XenVm
=> XenVm(id: integer, customer_id: integer,
xen_server_id: integer, name: string, memory_size: integer,
swap_size: integer, disk_size: integer, architecture: string,
distribution: string, filesystem: string,
created_at: datetime, updated_at: datetime, internal_name: string,
state_id: integer, created_by: integer,
updated_by: integer)
>>
Rails MySQL and Leopard
September 29th, 2007
UPDATE:
I didn't know about the ARCHFLAGS environment variable, this is a less intrusive way (thanks to Sebastian for pointing this out):
sudo su -
ARCHFLAGS='-arch i386' gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(sudo su - asks you for your normal password not the root password)
I'm using the stock ruby environment on Leopard and the MySQL Package from http://www.mysql.com.
Unfortunately installing the mysql driver as a gem doesn't work out of the box and the default mysql driver that comes with rails seems to be quite buggy.
To get it working we have to remove all occurrences of "-arch ppc" in rbconfig.rb, otherwise it tries to compile the mysql driver for the powerpc plattform as well, what we don't want (assuming you have an Intel Mac, otherwise remove "-arch i386").
We also have to tell the driver where to find the the mysql libs, includes and so on. We can do this by specifying where the path the mysql_config command.
cd /usr/lib/ruby/1.8/universal-darwin9.0/
sudo mv rbconfig.rb rbconfig.rb.orig
sudo sed "s/-arch ppc//g" rbconfig.rb.orig > rbconfig.rb
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(if you use a PPC Mac replace ppc with i386 on line 2)
Google Gears
June 1st, 2007
Google just released their new offline-webapp Firefox and Internet Explorer plugin called Google Gears.
It's basically offers a persistent relational database that you can access from Javascript, as well as way to run Javascript code asynchronous, which is important if you have run expensive code.
We now have Firefox itself, Google, Adobe and Microsoft offering ways to take web applications offline. Google's offer is quite easy to integrate into your site and I guess as soon Google starts to use it in their own applications many people will have it installed in their browser.
As they have released it under the BSD license I wonder if they can get Mozilla to integrate it in their browsers, but it seems unlikely because Firefox 3.0 will feature a similar feature on it's own. But they could still distribute it with other applications Google offers.
Steve and Bill at All Things Digital
May 31st, 2007
Videos of the complete Steve Jobs and Bill Gates interview:
- Steve Jobs and Bill Gates Prologue
- Steve Jobs and Bill Gates Part 1
- Steve Jobs and Bill Gates Part 2
- Steve Jobs and Bill Gates Part 3
- Steve Jobs and Bill Gates Part 4
- Steve Jobs and Bill Gates Part 5
- Steve Jobs and Bill Gates Part 6
- Steve Jobs and Bill Gates Part 7
- Steve Jobs and Bill Gates Highlight Reel
- Steve Jobs and Bill Gates Session Transcript
I'd like one for my girlfriend
May 25th, 2007
"Businessweek profiles "Metro" -- a prototype laptop designed by Intel and Ziba Design. The 0.7 inch thick laptop is the world's thinnest notebook and weighs only 2.25 pounds."

"Other design-oriented features include different color choices, one side featuring an E Ink screen, and the addition of a shoulder strap (image)."
J2ME and RESTful Web Service
May 20th, 2007
I'm currently working on project involving a J2ME client on a mobile phone connecting to a Rails RESTful web service. As you might know, a RESTful web services utilizes the four HTTP verbs GET, POST, PUT and DELETE.
So yesterday we started to write unit tests, running on a J2ME device, which test if the Rails web service conforms to our specification, then suddenly we got this:
IOException: "unsupported method: PUT"
Huh?
We had the web service specification finished, the Rails Application was nearly finished, the J2ME web service adapter was finished, the J2ME GUI was underway - over 500 hours of work and suddenly this!
You can imagine our faces as we looked at the screen, reading the exception on the tiny display of the Nokia mobile phone emulator.
We went to the Sun site to get the sources of the J2ME MIDP2.0 reference implementation and found this:
public void setRequestMethod(String method) throws IOException {
if (!method.equals(HEAD) &&
!method.equals(GET) &&
!method.equals(POST)) {
throw new IOException("unsupported method: " + method);
}
this.method = method;
}
Why the hell did they do that? Why are they restricting the HTTP verbs to HEAD, GET and POST? Security? Fun?
To our luck, there is also another widely deployed platform/application that only supports GET and POST: the browser!
So when Rails started to support RESTful controllers and routing, they had to invent a mechanism to piggy-back PUT and DELETE requests on the POST method.
Rails solves this by using a hidden field in HTML forms named _method, but you can also specify _method as an URL parameter (given that you send a POST request):
http://localhost:3000/submarks/1?_method=put
Rails certainly intended this for the browser, but it also works with XML requests if you specify the method as URL parameter and can save your life if you use J2ME - at least it saved us from a serious headache.
Thank you Rails! And to you J2ME guys: please, remove those five idiotic lines - there are more verbs than those three.
Rails find :conditions
April 20th, 2007
The Rails application I'm currently working on accepts URLs like:
GET /submarks
GET /submarks?lat=:latitude&lng=:longitude
GET /submarks?lat=:latitude&lng=:longitude&user=:user_id
GET /submarks?lat=:latitude&lng=:longitude&channel=:channel_id
GET /submarks?lat=:latitude&lng=:longitude&channel=:channel_id&user=:user_id
All query parameters are optional, only lat and lng have to appear together.
On the Rails end, I have a Submark model with the attributes: lat, lng, user_id and channel_id.
So how do you implement find call on the Submark model without a long, ugly if-elsif-else statements?
First of all if you only have = as comparators you can use a Hash for the :conditions parameter of the find method:
conditions = {}
conditions[:user_id] => params[:user] if params[:user]
conditions[:channel_id] => params[:channel] if params[:channel]
Submark.find(:all, :conditions => conditions)
But what if you want OR instead of AND in the WHERE clause? Or what if you want do something like lat < 16?
Currently, you have revert back to ugly if-elsif-else statements like:
if params[:user] and params[:channel].nil?
Submark.find(:all, :conditions => ["user_id = ?", params[:user]])
elsif params[:user].nil? and params[:channel]
Submark.find(:all, :conditions => ["user_id = ?", params[:user]])
elsif params[:user] and params[:channel]
Submark.find(:all, :conditions => ["user_id = ? AND channel_id = ?", params[:user], params[:channel]])
else
Submark.find(:all)
end
A good solution for this problem is the ez_where plugin by Ezra Zygmuntowicz and Fabien Franzen.
It includes new find_where method in your ActiveRecord models which takes a code block building the conditions with a quite nifty syntax.
But I didn't want to depend on a external plugin, mainly because we are working with edge Rails, so it's not unlikely that ez_where breaks sometime during development.
Instead I've implemented a little helper, create_conditions, which is able to construct a conditions array, in the format the usualfind method likes. It also works by utilizing a code block. You get a Conditions class as parameter to your code block, which has the methods and and or.
This is how you would use create_conditions in your controller:
conditions = create_conditions do | c |
c.and ["channel_id = ?", params[:channel]] if params[:channel]
c.and ["user_id = ?", params[:user]] if params[:user]
c.or "distance < 10"
end
Submark.find(:all, :conditions => conditions)
The result of create_conditions looks like:
["channel_id = ? AND user_id = ? OR distance < 10", 1, 42]
As you can see, you can use both, String or Array based conditions. Hash based conditions are not supported.
Missed it
April 19th, 2007
Although I've been using Rails for some time now, I somehow missed out on DHH's speach during lasts RailsConf.
If you are working on CRUD or RESTful Rails applications (if you don't, you should), and haven't seen it yet, you are definitely missing out too!
"Here, briefly, is an outline of the talk:- Discovering Resources on Rails
- Problem with Crud?
- Get, Post and Clean URLs
- Accounts, Controllers and Crud
- CRUD is Not a Goal but and Inspiration
- Controllers, Design Patterns and MIME
- Doing By Hand Leads to Good Design
- Get, Find, Post Redux
- Q&A"
Year Zero Album
April 18th, 2007
The new NIN Year Zero album CD has a really cool a thermal secret. It changes from black to white as it heats up in the CD player and reveals some binary code.