I had struggled to find an application to extract TTF files out of a Font Suitcase and had tried to install Fondu myself but couldn’t get it working on my Lion machine.
I followed the linked instructions on my Snow Leopard machine at home and it worked a treat.
Unit testing with Mongoid
Since MongoDB has no transactions you need to the clearing up for data after each unit test manually, here is a tip to make that a lot easier.
in file test_helper.rb in class ActiveSupport::TestCase add the following
teardown :clean_mongodb
def clean_mongodb
Mongoid.database.collections.each do |collection|
unless collection.name =~ /^system\./
collection.remove
end
end
end
Detecting a promenant colour
We are working on a new iOS app at the moment and I was asked by the designer this morning if it would be possible for us to detect the most promenant colour in a user uploaded photo. I considered using iOS to do the processing and then I reconsidered and looked into how it would be done with ruby. It turned out that some wonderful developer had already done it and released a gem. It is amazing how often this happens in the ruby world.
Based on a few rough tests the values it gives out are fairly accurate. Just make sure that you have already installed ImageMagick (which I did with HomeBrew, brew install imagemagick) and set the path to it correctly with
Miro.options[:image_magick_path] = YOUR_SERVER_PATH
The gem can be found on GitHub
Adding a directory to a bash path
Some day I will remember how to do this without a google search
echo 'export PATH=<<YOUR_PATH>>:$PATH' >> ~/.bash_profile
Strip SVN folders
At Paper Bag we are moving all our repos to use Git from Subversion and for some reason I can’t keep this handy little command in my head. Putting it here means I won’t have to keep doing a google search to find it.
rm -rf $(find . -name .svn)
Rails and Mongoid
If you are working with Mongoid and are trying to get dates to populate in your MongoDB you will find out after some searching that you need to add
include Mongoid::MultiParameterAttributes
to your model. What they do not mention is that if you put it above your include Mongoid::Document line it will not work. So what you are looking for is something like
class User
include Mongoid::Document
include Mongoid::MultiParameterAttributes
field :name, :type=> String
field :dob, :type=> Date
end
Automating TestFlight Builds
I posted last week about this article that I found detailing how to automated your TestFlight uploads. I can confirm that I have tested it and it works like a dream.
The only things I would point out are
- GrowlNotify needs to be installed on the system. Which by default will be installed at /usr/local/bin
- I didn’t want the script to be held up until I dismissed the growl notifications so I took out the -w flag
- If you are still using Snow Leopard make sure you get the 1.2.2 version of GrowlNotify
It should only take about 10-15 mins to get everything set up so there really is no excuse not to.
Stu