Running Google Test on Snow Leopard, C++ TDD

February 25th, 2010

A quick post from a coffee shop in Laos, I’m installing the Google Test framework on my OS X machine to do some TDD C++ work,

I’m using Make, and when I got to the instructions in the README explaining the how to run the sample tests …
### Using GNU Make ###
I ran into a problem ..


myosxmachine:make joe$ make clean && make
rm -f sample1_unittest gtest.a gtest_main.a *.o
g++ -I.. -I../include -g -Wall -Wextra -c ../samples/sample1.cc
g++ -I.. -I../include -g -Wall -Wextra -c ../samples/sample1_unittest.cc
g++ -I.. -I../include -g -Wall -Wextra -c ../src/gtest-all.cc
g++ -I.. -I../include -g -Wall -Wextra -c ../src/gtest_main.cc
ar rv gtest_main.a gtest-all.o gtest_main.o
ar: creating archive gtest_main.a
a - gtest-all.o
a - gtest_main.o
g++ -I.. -I../include -g -Wall -Wextra sample1.o sample1_unittest.o gtest_main.a -o sample1_unittest
ld: in gtest_main.a, archive has no table of contents
collect2: ld returned 1 exit status
make: *** [sample1_unittest] Error 1

Turns out there is an issue with ld and ar on OSX 10.6 .

Adding the ARFLAGS =-q -s to the sample makefile fixes the issue

Localising Rails

October 14th, 2009

I’m currently working on the  DIGITAL LIBRARY OF LAO MANUSCRIPTS which has been insteresting dealing with Fonts and various localisation issues. More later.

Getting started writting Flex based AIR applications from the command line

March 9th, 2009

There are couple or gotchas installing the latest  Open Source Flex and AIR SDKs.  Here are instructions to get started

Download the AIR and Flex SDKS

Get Flex from : http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK

Get Air from http://www.adobe.com/products/air/tools/sdk/

I installed them into /usr/local/flex_sdk and /usr/local/air_sdk

Add their bin directories to your path, in .profile or .bash_profile e.g.

export PATH=/usr/local/mysql/bin:$PATH:~/bin:/usr/local/flex_sdk/bin:/usr/local/air_sdk/bin

Make the compliers executable

sudo chmod +x mxmlc

sudo chmod +x amxmlc

It turns out the lastest version of the compiles scripts are dos terminated lines so you need to do

dos2unix mxmlc

dos2unix amxmlc

You can get dos2unix from macports , sudo port install dos2unix

(bug here :http://bugs.adobe.com/jira/browse/SDK-16699)

Next issue is the samples won’t compile, you will get an error “error while loading initial content”.

You need to update the namespace in your AIR project’s AppName-app.xml file to reflect the new AIR version 1.5:

<application xmlns="http://ns.adobe.com/air/application/1.5">

(from http://blog.sunild.com/2008/12/error-while-loading-initial-content.html)

Making autotest and growl a snap

January 25th, 2009


sudo gem install growl-glue

In .autotest

require 'growl_glue'
GrowlGlue::Autotest.initialize

Easy

JRuby 1.1.4 & getPlatformMBeanServer error on linux

September 13th, 2008

I was getting an error on a new install of JRuby on a Linux

jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [i386-java]
Created MBeanServer with ID: -vsnele:fl2bg1bd.0:mandlebrot:1
java.lang.management.ManagementFactory:-1:in `getPlatformMBeanServer’: java.lang.InternalError: One of the management beans is not compliant.
from org.jruby.management.BeanManager:59:in `register’
from org.jruby.management.BeanManager:29:in `register’
from org.jruby.compiler.JITCompiler:68:in `<init>’
from org.jruby.Ruby:207:in `<init>’
from org.jruby.Ruby:160:in `newInstance’
from org.jruby.Main:184:in `run’
from org.jruby.Main:100:in `run’
from org.jruby.Main:84:in `main’

It turned out that remove the following packages solved that problemRemoved the following packages:
java-gcj-compat
java-gcj-compat-headless

Apple embraces a little ruby with MobileME

June 19th, 2008

I’m sure most of the Apple fan boys here have seen  Apples new improved .net offering, MobileMe.
It turns out that the MobileMe interface is built using an opensource  Ajax/Widget  toolkit called SproutCore.

Lets have a look on how you install SproutCore

sudo gem install sproutcore

Look familiar ?  View Helpers  are RHTML files e.g.

<%= label_view :my_label, :tag => ‘h1′, :inner_html => ‘Hello World!’ %>

The ruby stuff is only used in production, in a similiar way that GWT uses Java to generates the HTML and JS runtime files….

While SproutCore uses Ruby to generate static HTML and JavaScript files, you are not tied to Ruby or Rails in production.  SproutCore runs in the browser, your production system can use whatever backend you want, as long as it sends JSON to the browser.

Solution to Textmate slow “find in project”

April 4th, 2008

I finally had enough of Textmate’s slow find in project,  and had a look around. I wish I’d taken 2 minutes to that before because I found the awesome Grep in Project command for TextMate
by some guy who’s name I couldn’t find easily, I know how much he runs and he listens to a lot of  Duran Duran, but I can’t see his name anywhere : -)  Anyway his grep script works great so  go get it .

Recipes: get (download) your log

March 24th, 2008

These are a few snippets for getting and viewing your log files

This task will download your production log and put a time stamped version in your local log directory

task :download_log do

TIMESTAMP = ‘%Y%m%d%H%M%S’

get "#{deploy_to}/current/log/production.log",

"log/production._#{Time.now.strftime(TIMESTAMP)}.log"

end

Dealing with user uploaded files between deployments

March 24th, 2008

If you are writing an application that allows your users to upload files, you have to work around the fact that their files will be deleted every time you deploy your application.

Usually if you want your file to available they will be uploaded to the public folder. The solution is to store those files in the “shared” directory.

Here is one example on how to set that up for a Rails app.

Create a directory called “uploads” in your.

When using attachment_fu or similar, use a :prefix=>”/public/uploads/#{tablename}

Add the following tasks to your deploy file

desc "link upload directory"
task :symlink_uploads, :roles => :app do
  run “ln -nfs /var/www/apps/#{application}/containers/rails/#{application}/shared/system/uploads #{release_path}/public/uploads
end
end
desc "create upload directory"
task :create_uploads_directory, :roles => :app do
	run “mkdir #{deploy_to}/shared/system/media”
end
end
Hook them into your deployment
after "deploy","symlink_uploads

after "deploy:setup","create_uploads_directory

Any uploads will now be stored outside the versioned directories.

Recipes: Ferret

March 24th, 2008

Ferret (http://ferret.davebalmain.com/trac) is a high-performance, full-featured text search engine library written for Ruby.

It is inspired by Apache Lucene Java project.

acts_as_ferret comes with a built in DRb server that acts

as the central hub for all indexing and searching in your application.

Ferret now comes with a recipe for managing your Drb server. The Ferret config file is located at config/ferret_server.yml and

looks like this:

production:
host: ferret.yourdomain.com
port: 9009
pid_file: log/ferret.pid

The supplied recipe looks like this

namespace :ferret do
desc “Stop the Ferret server, and continue even if the operation fails.”
task :stop_safe, :roles => :app, :on_error => :continue do
top.ferret.stop
end

desc “Start Ferret Server”
task :start, :roles => :app do
top.ferret.start
end

desc “Stop Ferret Server”
task :stop, :roles => :app do
top.ferret.stop
end

desc “Restart Ferret Server”
task :restart, :roles => :app do
top.ferret.restart
end

desc “Rebuild the Ferret index”
task :rebuild, :roles => :app do
run “cd #{current_path} && rake production ferret:rebuild”
end

desc “Destroy the Ferret index”
task :destroy, :roles => :app do
run “cd #{current_path} && rm -rf index/production index/development index/test”
end

end