Foundation.j and AppKit.j 404
During some Rails integration with Cappuccino I noticed that my Rails' logs were filling fast with 404s.
At first I thought I did something wrong in including my Frameworks, however it turns out that's a normal behaviour by design.
I won't go into the details here on why it's happening, but here's a solution:
Ruby on Rails
To avoid the stack trace generation overhead in Rails simply put down those routes:
map.connect '/Frameworks/Foundation/Foundation.j', :controller => 'application', :action => 'handle_cappuccino_404', :conditions => { :method => :get } map.connect '/Frameworks/AppKit/AppKit.j', :controller => 'application', :action => 'handle_cappuccino_404', :conditions => { :method => :get }
Then in your handle_cappuccino_404 method you can simply render :nothing => true:
class ApplicationController < ActionController::Base def handle_cappuccino_404 render :nothing => true end end
I think we can't rescue_from ActionController::RoutingError at this point.
Please also read another solution involving Rails Metal below.
Rails Metal
I was thinking about using Rails Metal to avoid even the extra bits:
script/generate metal cappuccinoThen in app/metal/cappuccino.rb:
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) class Cappuccino def self.call(env) if env["PATH_INFO"] =~ /^\/Frameworks\/Foundation|AppKit\/Foundation|AppKit.j/ [200, {"Content-Type" => "text/html"}, []] else [404, {"Content-Type" => "text/html"}, ["Not Found"]] end end end
No need for the method described above: you can safely remove routes and the 404 handling method from your controller.
Sinatra
To avoid it in Sinatra:
# from http://github.com/mchung/cappuccino_sandbox get "/Frameworks/AppKit/AppKit.j" do [404, {}, "Look elsewhere"] end get "/Frameworks/AppKit/Foundation.j" do [404, {}, "Look elsewhere"] end
obj-j bits
Gotcha bits, taken from obj-j tutorial.
- Objective-J has two types of objects, native JavaScript objects and Objective-J objects
- The beginning of a class is always the keyword @implementation, followed by the class name
- Each method signature starts with either a dash (-) or a plus (+)
- Dashes are used for instance methods
- One pattern you'll find in Objective-J and Cappuccino is the idea of passing a method as an argument to another method
- The alloc class method is analogous to the "new" keyword in many languages
- The init instance methods are like the constructors in those languages, in that they perform initialization on the newly created instance
- Some classes specify their own custom init method
- "self" is the Objective-J equivalent to JavaScript's "this"
- There are two types of import statements. The angle brackets indicate framework code, while the quotation marks indicate local project code
- JavaScript is garbage collected, and so is Objective-J, so you won't see any calls to retain or release in Objective-J code as you would in Objective-C
- Categories allow you to add methods to a class without needing to create a new subclass or modify the class's source code
- The syntax for the category is @implementation, followed by the class you're adding to, followed by the name of your category in parentheses
- Technique called toll-free bridging which allows any JavaScript object like an array or a string to act both as a JavaScript object and a Cappuccino object at the same time
- Variables not specifically declared with var become globals
Rails vs. Tarantula
There are times when you, as a lone developer, simply don't have time to write tests.
It's bad but can happen, but I can guarantee that even if your application is small or simple it probably does contains some bugs, especially if you are forced to write it on the fly and fast (which should be the only reason to excuse your lack of tests).
Sending an application straight into production without running tests is bad, I can't stress it enough.
However there's a solution to have some little tests running prior in distributing your app: Tarantula.
Snow Leopard server FAQs, part 1
Snow Leopard server is a good system, however it does still suffer nasty bugs and you have to learn small gotchas to make things work as expected.
Here's a roundup on what I found.
Safari CTLoader errors?
CTLoader Toolbar has not been tested on this version. Toolbar bundle will not be loaded
Try this:
- Open a new finder window.
- Click on Applications.
- Open the Toolbars folder.
- Open the Vuze folder.
- Double click on Uninstall.
From the Vuze FAQ:
If you installed the Vuze Toolbar for Safari and are getting an error when launching Safari (an error about CTLoader), you can fix the issue with an updated toolbar. Download it here:
http://ct1609479.ourtoolbar.com/sf
If you didn't want the Vuze toolbar installed for Safari, you can remove it with these instructions:
http://faq.vuze.com/?View=entry&EntryID=346
Reminder: empty email subjects in Snow Leopard server’s postfix
By default Snow Leopard server doesn't allow sending emails with blank subjects.
In order to change this behaviour open:
/etc/postfix/custom_header_checks
and comment the:
/^subject: *$/ REJECT empty subject header
line by prepending a # , so it reads:
#/^subject: *$/ REJECT empty subject header
Restart the mail service.
Reminder: Outlook vs. Snow Leopard server’s postfix
Snow Leopard server implements some good anti-spam measures, on top of all Greylisting.
But there's a subtle issue with sending emails from Outlook, many users will get an error on the lines of:
helo command rejected: need fully-qualified hostname
In order to solve this open up:
sudo nano /etc/postfix/main.cf
Find this line:
smtpd_helo_restrictions = reject_invalid_helo_hostname reject_non_fqdn_helo_hostname
and change it to:
smtpd_helo_restrictions = permit_sasl_authenticated permit_mynetworks reject_invalid_helo_hostname reject_non_fqdn_helo_hostname
Restart the mail service.
do_sqlite3 on Snow Leopard
If you have encountered architecture issues installing the do_sqlite3 gem on Snow Leopard I resolved running the following:
sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3
Last.fm loved tracks to iTunes
Update: now includes experimental Windows support.
I wrote a little (raw) ruby script that imports your loved last.fm tracks into iTunes in a discrete playlist.
Bowtie doesn’t scrobble to last.fm, solution

Apparently there are some issues with Bowtie when using the last.fm integration.
Remember I'm using Snow Leopard.
Bowtie is a valid freeware alternative to CoverSutra for managing iTunes, showing cover art, current song, etc.
Using version 1.0b2 I found out two things:
- if you open the preference pane, Last.fm and check "Enabled", the checkbox goes automatically away
- it doesn't scrobble
A workaround to fix the first problem is to leave the checkbox alone and instead enable last.fm integration by right clicking the icon in the upper tray and selecting "Enable Last.fm".
The solution to the fact that isn't scrobbling is to capitalize your last.fm username in preferences, so for example if my username is "kain82" I will write "Kain82".
With those settings in place it does seem working, however I'll keep this post as reference for future updates on the matter.
Oh, and if you're into metal, add me to your friends over last.fm ;)