Thursday, November 6, 2008

Merb with ActiveRecord and Haml

I finally started hacking on Merb today.
Since I'm a Rails developer, I wanted to default to ActiveRecord for my Models and Haml for my views as opposed to Merbs DataMapper and Erb.

Here is how I did it:

$ merb-gen app my_merb
$ cd my_merb

$ sudo gem install merb_activerecord

$ mate config/init.rb
change 'use_orm :datamapper' to 'use_orm :activerecord'
change 'use_template_engine :erb' to 'use_template_engine :haml'

...at the bottom of the file add this line
dependency 'merb-haml'

You should now be on the Ar and Haml platform, jump over to the wiki and continue as normal

Thursday, August 14, 2008

useful git stuff on OSX

I just did this recently and its hella useful...

# Configure textmate globally as the commit comment editor for git
$ git-config --global core.editor 'mate -w'

# Configure opendiff(aka FileMerge) as the git merge tool
git config --global merge.tool opendiff

Tuesday, August 12, 2008

SMF and capistrano, straight outta compton!

Here is some useful stuff if you host with joyent and use SMF and capistrano.

Ok, so I'll start with some useful SMF commands that I always use yet forget.
Replace the_smf_service with the name of your service.

# Delete an existing service
sudo svccfg -v delete the_smf_service
# Import a service from the given xml manifest
sudo svccfg import .xml
# Restart
svcadm restart the_smf_service
# Enable
svcadm enable -r the_smf_service
# and Disable
svcadm disable the_smf_service

Here is what our capistrano deploy.rb has added to it. What this does is override the default capistrano tasks with smf related ones as well as define the smf related tasks.

Sunday, July 6, 2008

eschaton

We gave a small talk at Ruby-brigade 9th July 2008 about the eschaton and google maps.
We have also created a blog and the git repositorys are viewable here.

Please make any comments about the talk or what we are doing.

Friday, June 20, 2008

Rails on Git

Here is what I do to get a rails app under git and playing nice !

# rails your_dir
# cd your_dir
# git init

Create a .gitignore file in the root of your project...

# touch .gitignore

Add the below to the .gitignore file...

log/*.log
db/*.sqlite3
tmp/**/*
doc/api
doc/app
doc/plugins

Now add .gitignore files of log, db and temp so that they still get tracked...

# touch log/.gitignore
# touch tmp/.gitignore
# touch db/.gitignore

If you wish to freeze rails, do so now...

# rake rails:freeze:gems

If you have any submodules, use respective remote locations...


# git submodule add ssh://some_server/plugin_one.git vendor/plugins/plugin_one
# git submodule add ssh://some_server/plugin_two.git vendor/plugins/plugin_two

# git submodule init
# git submodule update

Now commit those initial changes...

# git add .
# git commit -m "Created rails app"

Thursday, June 19, 2008

Git on Joyent

So I recently had to setup Git on our Joyent Solaris box and host some repositories that would enable us to do remote pushes to our server.

So I thought I would share my experience in the hope to save people some time.

Here we go:

At the time of writing Git was 1.5.5.4, update the download url and git directories as need be to suit your git version.

1.) Get the git and decompress...

wget http://kernel.org/pub/software/scm/git/git-1.5.5.4.tar.gz
gtar xvfz git-1.5.5.4.tar.gz
cd git-1.5.5.4

2.) Configure, make and install...

./configure --prefix=/opt/local
sudo gmake AR=gar NO_ICONV=1 NO_TCLTK=1 CFLAGS="-Wall -O2 \
-I/opt/csw/include" LDFLAGS="-L/opt/csw/lib"
sudo gmake install AR=gar NO_ICONV=1 NO_TCLTK=1 CFLAGS="-Wall -O2 \
-I/opt/csw/include" LDFLAGS="-L/opt/csw/lib"


3.) Changing hook scripts...
On Solaris, it seems that /bin/sh is a Bourne Shell which will fail in error when executing some of git's hook scripts. So we need to update these hooks scripts to use /bin/bash


cd /opt/local/share/git-core/templates
perl -e "s/\/bin\/sh/\/bin\/bash/g;" -pi $(find hooks -type f)


4.) Update $PATH...
For any users who intend using ssh to access the git repositories they will have to add '/opt/local/bin' to their path. You can do so by editing your '.bashrc' and amending the path.

5.) Create the repositories, replace values as need be. This will have created a bare repository that is ready to be pushed to.

mkdir /repos/my_repos.git
cd /repos/my_repos.git
git --bare init


6.) Push to your repos...

git remote add origin ssh://your_user@your_joyent_server/repos/my_repos.git
git push origin master



Notes:
- The /bin/sh problem may not occur, it depends on what distro your are using.
- Make sure your Git ssh user accounts have the relevant access to the above created directories.

Monday, June 16, 2008

Git + GitHub + LightHouse = Awesome!

Just a quick entry.

I have started using github and lighthouse.
Git is awesome and in conjunction github it makes for a really good combo.

If you not using Git or GitHub, go and check them out its well worth it.

Its good to see companies doing work like this and they all use rails on their websites.