You have probably seen URL shorteners that use short, seemingly random strings to identify sites. These strings are not random, they are encoded integer values. My valerii gem allows you to easily and quickly encode and decode integer values. Let me show you.
Posts Tagged ‘Ruby’
Valerii: 32-base string encoder and decoder
October 13th, 2009Speaking at Rails Underground
June 14th, 2009
I 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, 2009I 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
has_one – find all that have no associated object
June 7th, 2009Let 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.
Ruby Gem: IMDB
June 3rd, 2009I just released version 0.1.0 of my IMDB gem which allows your app to search IMDB for IMDB movie ID’s and access most data that’s publicly available.
Installation
sudo gem install imdb
This will also install the dependencies Hpricot and HTTParty.
Usage
In your project, include the gem (and possibly rubygems as well).
warcraft-armory 0.1.0 Released
February 7th, 2009Yay! warcraft-armory version 0.1.0 has been released!
The warcraft-armory gem allows your application to easily access information from the World of Warcraft Armory site.
This is an early version that allows the retrieval of character information from EU and US armories. But, more is in the making!
RSpec’ing with Time.now
November 5th, 2008I’m currently writing some RSpec tests that use Time.now.
I want my model to calculate a duration and store the future time in the database. I’ve already specced the calculation of the duration, but I also want to spec that everything gets saved correctly. Here’s my first spec:
it "should do stuff" do m = Model.create() m.expires_at.should eql(Time.now + some_value) end
This fails.
BaseApp: a quick start for your Rails App
September 28th, 2008BaseApp is no longer maintained. There is a very good alternative called bort.
For the impatient: http://github.com/ariejan/baseapp
Got issues? Feature requests or patches? http://baseapp.lighthouseapp.com/
Every Rails developer has at least once developed an application that needed user authentication and some basic UI features like tabs and a sidebar. Ask yourself now: “how often have you installed and extended the restful_authentication plugin?”.
Skinny Controllers and Overweight Models
August 17th, 2008All Rails developers know the slogan “Skinny Controllers, Fat Models” and I heartily agree with it. Every conference you go to, you hear it. But there’s a problem! My Fat models got overweight!
ActiveRecord Read Only Model
August 17th, 2008ActiveRecord is great in providing CRUD for your data models. In some cases, however, it’s necessary to prevent write access to these models. The data may be provided by an external source and should only be used as a reference in your application, for example.
