Skip to content

Instantly share code, notes, and snippets.

Pablo Cantero phstc

Block or report user

Report or block phstc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:418119705b569fb2f9a5
# lib/liquid_i18n_rails.rb
module LiquidI18nRails
def t(string)
I18n.t(string.to_sym)
end
end
# config/initializers/liquid.rb
require 'liquid_i18n_rails'
Liquid::Template.register_filter LiquidI18nRails
View gist:1ed1a7060a80c2e33b64
# lib/liquid_i18n_rails.rb
module LiquidI18nRails
def t(string)
I18n.t(string.to_sym)
end
end
# config/initializers/liquid.rb
require 'liquid_i18n_rails'
Liquid::Template.register_filter LiquidI18nRails
View osx-for-hackers.sh
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
View gist:7733092

TODO: make gem for this

This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.

Bower

  1. Set the install directory for Bower components:

    // .bowerrc
View friendly_urls.markdown

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@phstc
phstc / rails31init.md
Created Mar 8, 2012 — forked from samnang/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard
View rails31init.md

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@phstc
phstc / gist:1989083
Created Mar 6, 2012 — forked from willnet/gist:1703102
install manual of swfmill on mac
View gist:1989083
# http://download.savannah.gnu.org/releases/freetype/ から最新のfreetypeをダウンロード
tar zxvf freetype-x.x.x
cd freetype
./configure
make
sudo make install
curl -O http://www.swfmill.org/releases/swfmill-0.3.2.tar.gz
tar zxvf swfmill-0.3.2.tar.gz
cd swfmill-0.3.2
View devise.pt-BR.yml
pt-BR:
errors:
messages:
not_found: 'não encontrado'
already_confirmed: 'já foi confirmado'
not_locked: 'não foi bloqueado'
not_saved:
one: '1 erro impediu que %{resource} fosse gravado:'
other: '%{count} erros impediram que %{resource} fosse gravado:'
You can’t perform that action at this time.