Git Tag Mini Cheat Sheet Revisited

September 5th, 2009

Just as a kind of mini cheat sheet for using git tags. Jörg Mittag had some great additions that weren’t in the original post which warrant a new post.

Git has three different type of tags:

  • Lightweight tags
  • Annotated tags
  • Signed tags

Let’s start with lightweight tags.

Lightweight tags

Git Tag Mini Cheat Sheet

September 4th, 2009

Just as a kind of mini cheat sheet for using git tags:

Adding a tag:

  • git tag tag_name
  • git tag
    Should show your new tag.
  • git push origin --tags or git push origin :tag_name
    Because git push doesn’t push tags.

Removing a tag:

  • git tag -d tag_name
  • git tag
    Should no longer show your tag.
  • git push origin :refs/tags/tag_name
    Because git push --tags doesn’t push deleted tags.

Rails + MySQL: Case-Sensitive strings in your database

September 3rd, 2009

When using Rails + MySQL, you’ll find that normal string (or varchar(255)) fields are case insensitive. This can be quite a nuisance, but it’s easy to resolve. You need to set your table to the utf8_bin collation. By using the binary variant, you’re basically enabling case sensitivity.

JInput Mac OS X 64 bit natives

September 1st, 2009

Yesterday I ran into a little problem running Slick 2D on Java 6 64bit on my Mac. It’s a MacPro, which has a 64 bit processor and is running Leopard. The problem I encountered was related to the native libraries provided by LWJGL.

If you’re a user of LWJGL, you’ll be using JInput as well. Unfortunately, JInput does not currently have any 64 bit native libraries as it is only providing for PPC and i386 (32bit). This is a problem because Mac OS X users are somewhat bound to Java 6 64bit. There is no 32 bit version of Java 6 for Mac OS X.

Once and for all: Rails migrations integer :limit option

August 20th, 2009

I literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here’s an overview. Now let’s memorise it (oh, this works for MySQL, other databases may work differently):

Speaking at Rails Underground

June 14th, 2009

Speaking at Rails UndergroundI haven’t seen a schedule yet, but I’ve been told by Mark that I’ll be speaking at Rails Underground this year.

My talk will be on the topic of Git. In about 45 minutes time I’ll show you all the basic git features you’ll need on a daily basis. Not only that, but I’ll also explain how git manages all those commits and branches so you can be on your way to become a git power user.

IMDB Ruby Gem 0.4.0 Now available at RubyForge!

June 14th, 2009

I just released version 0.4.0 of the IMDB Ruby Gem into the wild. There are only a few minor updates:

Changes in 0.4.0

  • Updates to the console ‘imdb’ utility
    • Show the IMDB ID
    • Show the full IMDB URL

Installation or upgrade

$ sudo gem install imdb
$ sudo gem update imdb

Issues, source or contributions

Best Practice – The Git Development Cycle

June 8th, 2009

Git is quite an awesome version control system. Why? Because it’s lightning fast, even for large projects (among other reasons).

But, how do you use Git effectively for development on a daily basis? Let me explain to you.

Branches

ActiveRecord: Skipping callbacks like after_save or after_update

June 7th, 2009

Active Records provides callbacks, which is great is you want to perform extra business logic after (or before) saving, creating or destroying an instance of that model.

However, there are situations where you can easily fall into the trap of creating an infinite loop.

class Beer < ActiveRecord::Base
  def after_save
    x = some_magic_method(self)
    update_attribute(:my_attribute, x)
  end
end

has_one – find all that have no associated object

June 7th, 2009

Let me pose a typical Rails situation:

class Person < ActiveRecord::Base
  has_one :fancy_hat
end
 
class FancyHat < ActiveRecord::Base
  belongs_to :person
end

Now, how can you get all the people that don’t have a fancy hat?

class Person < ActiveRecord::Base
  has_one :fancy_hat
 
  named_scope :hatless, :joins => 'LEFT JOIN fancy_hats ON fancy_hats.person_id = people.id', :conditions => 'fancy_hats.person_id IS NULL'
end

Now you can find all the hatless people you want.

FYI: Finding fancy hats that have no one to wear them is a lot easier, because the foreign key is stored in the fancy_hats table.