Internetbureau Holder

Placeholder.it

Daniel Willemse wo 11 aug 10

Recently, i discovered this website that generates placeholders for you on the fly like so:

It will generate an image for you, where you specify attributes like size, color and text in the url.
Like:

placehold.it/100x100&text=like this

To make things even better, Matt Darby came up with a gem that lets you generate placeholders with ruby code.
Simply install the gem Placeholder
and use it like this:

Placeholder.new(:size => 300, :fg_color => "aa0000", :bg_color => "00aa00", :text => "see how easy it is?")

and you’re done.

check it out at: http://github.com/mdarby/placeholder
and see what more you can specify.

Gepost in hor |  0 reacties

Git tip: Removing remote tags

Johan Vermeulen vr 06 aug 10

Last week I needed to delete some tags from a remote Git repository. You probably won’t need to do this often, but just in case:

If you have a tag called ‘release-1.0.1’ which you would like to delete, this is howto remove it:

git tag -d release-1.0.1
git push origin :refs/tags/release-1.0.1

This will remove the ‘release-1.0.1’ tag from the remote repository.

Gepost in hor |  2 reacties

OpenGem

Stephan Kaag wo 04 aug 10

You might be familiar with GemEdit. This is a great gem that lets you quickly open up the source for a gem in your favorite editor.

In the same category OpenGem is now available.

If you install OpenGem, you’ll have two handy commands available:

  • gem open rails will open the gem’s source code in an editor of your choice, and
  • gem read rails will open a browser pointed to the gem’s documentation.

That’s one extra feature compared with GemEdit. Wicked!

Gepost in hor |  0 reacties

Browsing Git in Ruby

Jeroen Bulters di 03 aug 10

Recently I’ve been working on a project which involves a lot of interaction with git repositories. When I started hacking around, all interaction with the repository was performed through `shell` commands which – of course – works; but can not really be called idiomatic Ruby.

Luckily I’m not the only one who thinks so. During a presentation by Chris Wanstrath (detailing the stack GitHub uses) I was pointed to Scott Chacon’s GRIT.

Grit is an object oriented wrapper for interacting with any git repository and has only one dependency, git itself (which you have installed… RIGHT?).

Through grit it is possible to walk through a repository in a way we are all quite familiar with. For example, the following snippet gives me all commits made by me during the past 14 days in a repository.

require 'rubygems'
require 'grit'
require 'optparse'

# OptParse code omitted for brevity
# The option hash is supposed to have a committer, branch and days
# (number of days to check) value.
options = {}
options[:committer] = 'Jeroen Bulters'
options[:branch] = 'master'
options[:days] = 14

repo = Grit::Repo.new(Dir.pwd)

# Collect commits

# Ok, I admit, this is rancid, should use rails' fixnum ext.
start_date = (Time.now - (options[:days] * 60 * 60 * 24))

commits = repo.commits.select{|c| c.date > start_date}
filtered_commits = commits.select{|c| c.committer.to_s == options[:committer]}
puts "Found #{filtered_commits.size} commits..."

Although this is a fairly straightforward example, we should not forget that a git repository is a ‘simple’ directed acyclic graph. So get out your favorite graph traversal algorithm and apply it in some
way to your repositories (shortest path between root-commit and master anyone?), it’s easy, it’s fun and it doesn’t hurt!

Gepost in hor |  0 reacties

Ruby5

Daniel Willemse do 29 jul 10

This week, when looking for an answer to one of my ruby issues, I stumbled across
an awesome website called ruby5.envylabs.com

Where you can listen to, and get updated on the latest ruby news in a couple of minutes.
You can subscribe to it via iTunes, and it also has an RSS-feed.

Pretty easy to keep updated now, as you can just listen to it while doing your daily ruby business.

Check it out!

Gepost in hor |  0 reacties

Suppress Rails logging

Dax Huiberts wo 28 jul 10

When Rails applications get rather complex the amount of log statements can get rather big in development mode. It is not uncommon to get hundreds of lines of SQL log statements.

This creates a problem when you try to insert your own log statements. With all the noise it gets pretty difficult to filter out your own log statements. One way is to prefix your statements with “>>>>>>>>>>” or “==” (or many more of those). If that doesn’t even help there is alway the ‘tail -f log/development.log | grep =’. This is not a very workable sollution either. In this case you also miss your request information. Like how long the request takes or what the request parameters are.

I’ve been using the following code snippet for a week now and it really meets my need:

# config/initializers/suppress_rails_logging.rb

# suppress active record sql logging
class ActiveRecord::ConnectionAdapters::AbstractAdapter
  def log_info(*args); end
end

# suppress 'rendered partial ...' logging
module ActionView::RenderablePartial
  def render(view, local_assigns = {})
    super
  end
end

This snippet of code suppresses the ActiveRecord SQL logging statements and the ActionView ‘rendered partial …’ logging statements. It makes my logs useable again and I still don’t lose my request information logging statements.

Try it out and see for yourself wether this works for you. Please leave a comment for any feedback you have.

Gepost in hor |  1 reactie

Rails gem: Localized pluralization with i18n

Paul Engel di 27 jul 10

As you are working on an internalization Rails application, you are maybe using Globalize2 along with I18n to translate models (e.g. categories). The end-user is probably able to manage the translations in different locales such as Dutch, German, French, Spanish and so forth.

>> I18n.locale
=> :en
>> (c = Category.first).name
=> "birthday"
>> I18n.locale = :nl
=> :nl
>> c.name
=> "verjaardag"
>> I18n.locale = :fr
=> :fr
>> c.name
=> "anniversaire"

Sometimes you want to display the translation in pluralized form. For instance:

>> I18n.locale
=> :en
>> "Found " + c.name.pluralize
=> "Found birthdays"

A solution to accomplish this is to translate both singular and plural form:

>> I18n.locale
=> :nl
>> I18n.t("found").capitalize + " " + c.name_pluralized
=> "Gevonden verjaardagen"

There are some cons though:

  • you have to translate in singular AND plural form
  • you have to use two columns (name and name_pluralized)

That’s some sort of redundancy as we want to keep things DRY: only translate in singular form and pluralize the translation. Fortunately, there is a Rails gem that does just that:

Rich-pluralization is a E9s module which pluralizes words with inflection rules of the current locale. You can compare it with the ActiveSupport::Inflector, except that the inflections do not influence the Rails pluralization (which is used for methods as tableize and classify).

Looking at our previous example, this is what the implementation can look like:

>> I18n.locale
=> :nl
>> I18n.t("found").capitalize + " " + c.name.pl
=> "Gevonden verjaardagen"

And of course, you can pluralize static strings:

>> I18n.locale
=> :nl
>> "Fiets".pl
=> "Fietsen"
>> "MUSEUM".pl
=> "MUSEA"

Please note: the letter casing stays preserved(!)

All in all, using Rich-pluralization provides you to only translate in singular form and call .pl for the pluralized translation. Now isn’t that a DRY implementation?

At the moment, Rich-pluralization is shipped with Dutch inflections. It covers 86% of the 54977 words provided by INL. This will increase as the developers are working hard on improving the inflections. Also, you can also add inflections for other locales.

Please visit the Github project page if you are interested for more information.

Gepost in hor |  0 reacties

CSS3 Pie: Making your life as a webdesigner a little bit easier

Johan Vermeulen vr 23 jul 10

We all know how it’s like to create beautiful websites, slice it and see it work in all the major browser, except for Internet Explorer.

Enter CSS3 Pie: CSS decorations for IE. Jason Johnston of 327creative.com wrote a CSS library which can be used in Internet Explorer with the IE behaviors capability. This library partially adds CSS3 support to IE6/7/8.

Example:

Normally: plays nicely in FF/Safari/Chrome

#myElement {
  background: #EEE;
  padding: 2em;
  -moz-border-radius: 1em;
  -webkit-border-radius: 1em;
  border-radius: 1em;
}

For IE: Rounded borders \o/

#myElement {
  ...
  behavior: url(PIE.htc);
}

PIE currently has full or partial support for the following CSS3 features:

  • border-radius
  • box-shadow
  • border-image
  • multiple background images
  • linear-gradient as background image

Gepost in hor |  0 reacties

jQuery Hashchange

Stephan Kaag do 22 jul 10

Nowadays web apps do heavily depend on Ajax requests (think GMail).

As we all know: by using Ajax request we lose the possibility to bookmark specific pages and the possibility to use the back and forward buttons in our browsers because the url doesn’t change.

Ban Alman wrote javascript solution for this problem. Enter jquery-hashchange. This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.

Version 1.3 was recently released. Check it out at github.

Gepost in hor |  0 reacties

RubyAndRails Conference 2010

Chiel Wester wo 21 jul 10

Yesterday the ticket sale for this year’s RubyAndRails Conference (formerly known as RubyEnRails) has started.

A new name for the conference, but also a new location. Last year the conference was held at the University of Amsterdam but this year’s conference will take place at Pakhuis de Zwijger, behind central station in Amsterdam. The conference will be a two day conference on 21 & 22 October 2010 including a Rails Rumble on the second conference day.

The first speaker on the conference has already confirmed, more will follow shortly. You can buy your ticket at the conference website on http://rubyandrails.eu. Tickets are for sale for € 149,00

Gepost in hor |  1 reactie

Welcome to Holland On Rails

This weblog is the official Ruby techblog from the guys at Holder, a Ruby development company. Holder is also the company behind the RubyAndRails Europe Conference in Amsterdam.

Recente Jobs


Bekijk alle jobs »»

Gereedschapskist

Onmisbare tools voor
iedere developer!
Ruby On Rails
Framework voor de web 2.0 developer. Eindelijk vooruitgang!
TextMate
Editor for true pro's
Typ, tab, top :-)
Nee, niet voor Win.
Made On A Mac
En nou is het over met die saaie grijze Windows bak van je!

Auteurs op deze site

Chris Obdam

'Less is more' evangelist, past dit ook dagelijks toe op zijn tandenborstel.

Chiel Wester

Snelheidswonder op Ruby wielen. Leuk om mee te pair-programmen ;-) Recommend Me

Stephan Kaag

Het eerste Rails coreteam- member uit Nederland? Rails evangelist van het eerste uur.

Paul Engel

Én Rails programmeren én interfaces designen? Je zou hem superman kunnen noemen..

Dax Huiberts

Official Zip-Programmer, skinny code is helemaal zijn ding. Haalt meer code weg dan dat er bij komt.

Freek Monteban

Het nieuwste telg uit het Holland on Rails nest! Hij doet niets anders meer!

Johan Vermeulen

De stylesheet-koning uit de kop van Noord-Holland!