Skip to content

Instantly share code, notes, and snippets.

View oriolgual's full-sized avatar

Oriol Gual oriolgual

View GitHub Profile
<div class="idiomes grid_2">
<h5>Idioma</h5>
<ul id="languages">
<r:locales codes="es">
<r:normal>
<li><r:link>Español</r:link></li>
</r:normal>
<r:active>
<li class="active_lang"><r:link>Español</r:link></li>
</r:active>
@oriolgual
oriolgual / Guardfile
Created March 1, 2011 18:33
Sample Guardfile with a backend and frontend groups
group 'all' do
guard 'ego' do
watch(%r{Guardfile})
end
guard 'shell' do
watch(%r{db/schema.rb}) do
`rake db:test:prepare`
end
end
group 'frontend' do
guard 'compass' do
watch(%r{src/(.*)\.s[ac]ss})
watch(%r{app/stylesheets/(.*)\.s[ac]ss})
end
guard 'jammit' do
watch(%r{public/javascripts/(.*)\\\\.js})
watch(%r{public/stylesheets/(.*)\\\\.css})
end
@oriolgual
oriolgual / benchmark.rb
Created March 21, 2011 12:52 — forked from wbailey/benchmark.rb
Use with plain Ruby
require 'rubygems'
require 'benchmark'
include Benchmark
class Array
def to_hash_using_inject_push( use_array )
Hash[*(0 .. self.size).inject( [] ) { |r,i| r.push( self[i], use_array[i] ) }]
end
@oriolgual
oriolgual / 100
Created March 30, 2011 10:23
Listing benchmark result with 100 elements
Resort with 100 elements
user system total real
Create: 0.260000 0.010000 0.270000 ( 0.266756)
Order: 0.010000 0.000000 0.010000 ( 0.003027)
Prepend: 0.050000 0.000000 0.050000 ( 0.050237)
Append after: 0.070000 0.000000 0.070000 ( 0.080377)
Destroy: 0.090000 0.000000 0.090000 ( 0.089069)
0.090000 0.000000 0.090000 ( 0.089069)
rvm use --create 1.9.2@list_benchmark
@oriolgual
oriolgual / README.textile
Created April 4, 2011 07:57
Jekyll extension to easly use HAML instead of plain HTML

HAML Jekyll extension

Auto-generates html and css files for your layouts in HAML/SASS (you can still have your liquid syntax)

This extension uses jekyll_ext, which allows you to extend the Jekyll static blog generator without forking and modifying it’s codebase.
With this code, not only do your extensions live in your blog directory, but they can also be shared and reutilized.

Use this extension with jekyll_ext by just cloning this repo into the extensions dir of your blog: git clone git://github.com/codegram/haml_jekyllextension.git _extensions

More information about jekyll_ext can be found here: Jekyll Extensions -= Pain

module DogMixin
class << self
def included(base)
base.extend ClassMethods
end
end
module ClassMethods
def assign(*names)
@dog_names = names
@oriolgual
oriolgual / devise.ca.yml
Created June 1, 2011 13:47 — forked from jrom/devise.ca.yml
Catalan translation for Devise
ca:
errors:
messages:
expired: "ha caducat, demanen un de nou"
not_found: "no s'ha trobat"
already_confirmed: "ja està confirmat"
not_locked: "no està bloquejat"
not_saved:
one: "1 error ha evitat que %{resource} es pugui desar:"
other: "%{count} errors han evitat que %{resource} es pugui desar:"
@oriolgual
oriolgual / missing_translations.rb
Created July 6, 2011 11:01
No more missing translations in Rails thanks to Cucumber!
# features/support/missing_translations.rb
missing_translations = []
After do |scenario|
temp = all('.translation_missing')
if temp.any?
missing_translations << temp.to_a
raise "Missing Translation"
end