Skip to content

Instantly share code, notes, and snippets.

View dgilperez's full-sized avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
@dgilperez
dgilperez / will_paginate_supports_internationalization.rb
Created June 10, 2011 22:15
monkey-patching will_paginate to support internationalization for page_entries_info using gettext
# monkey-patching will_paginate to support internationalizated literals
module WillPaginate
module ViewHelpers
def page_entries_info(collection, options = {})
entry_name = options[:entry_name] ||
(collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
if collection.total_pages < 2
case collection.size
when 0; _("No %{entries} found") % {:entries => entry_name.pluralize}
@dgilperez
dgilperez / gist:1461752
Created December 11, 2011 17:45
Authlogic to Devise Migration (rails3.1)
class AuthlogicToDevise < ActiveRecord::Migration
def up
## Database authenticatable
rename_column :users, :crypted_password, :encrypted_password
## Recoverable
add_column :users, :reset_password_token, :string, :limit => 255
add_column :users, :reset_password_sent_at, :datetime
## Rememberable
@dgilperez
dgilperez / I18n devise es
Created December 11, 2011 20:33 — forked from ianmurrays/I18n devise es
devise I18n file in spanish
es:
errors:
messages:
not_found: 'no encontrado'
already_confirmed: 'ya ha sido confirmada'
not_locked: 'no está bloqueada'
expired: "ha caducado, por favor pide uno nuevo"
not_saved:
one: "1 error evitó guardar este %{resource}:"
other: "%{count} errores evitaron guardar este %{resource}:"
@dgilperez
dgilperez / erb_to_haml.rake
Created December 11, 2011 20:41
ERB to HAML rake task
# Don't forget to install hpricot gem.
namespace :erb do
namespace :to do
task :haml do
files = `find . -name *.html.erb`
files.each_line do |file|
file.strip!
`bundle exec html2haml #{file} | cat > #{file.gsub(/\.erb$/, ".haml")}`
end
@dgilperez
dgilperez / installation.sh
Created December 14, 2011 03:15 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
@dgilperez
dgilperez / installation.sh
Created December 20, 2011 23:54 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
@dgilperez
dgilperez / Selector de Idioma con Rails 2.3.8
Created January 4, 2012 21:43 — forked from andresgutgon/Selector de Idioma con Rails 2.3.8
Desplegar los idiomas que estan disponibles en tu App y setear el valor para cada usuario
#Selector de idioma
#dependencias:
# 1 - Rack locale del paquete Rack-contrib [1]
# USO: Se usa para detectar el idioma definido por el usuario en su browser ['HTTP_ACCEPT_LANGUAGE']
# Esplicado aquí http://guides.rubyonrails.org/i18n.html#using-accept-language
# [1] http://github.com/rack/rack-contrib
# 2 - Routing-filter [1]
# USO: Establecer el locale en las URLs ej.: www.mysite.com/es/foo/bar
# NOTA: Si tambien quieres traducir las URL's usa la gema de Raul Murciano Translate_routes [2] (De momento sin cobertura para Rails3)
@dgilperez
dgilperez / adsense_helper.rb
Created February 8, 2012 01:27 — forked from defkode/adsense_helper.rb
Google Adsense Rails 3 helper
module AdsenseHelper
# Author: Tomasz Mazur (defkode@gmail.com)
# http://www.mydigitallife.info/2009/01/17/google-adsense-legacy-old-generation-code-reference-generate-and-get/
# :slot
# :theme
# :background
# :border
# :link
# :text
@dgilperez
dgilperez / gist:1960607
Last active November 6, 2018 16:58
Compiling and Installing Sphinx 2.0 with libstemmer
# to execute from home folder
wget http://snowball.tartarus.org/dist/libstemmer_c.tgz
wget http://sphinxsearch.com/files/sphinx-2.1.2-release.tar.gz
tar -xvzf sphinx-2.1.2-release.tar.gz
tar -xvzf libstemmer_c.tgz
cp -R libstemmer_c/* sphinx-2.1.2-release/libstemmer_c/
cd sphinx-2.1.2-release/
./configure --with-libstemmer
make
@dgilperez
dgilperez / gist:2304667
Created April 4, 2012 18:48 — forked from eparreno/gist:2300165
About estimations
P = programmer; NP = non-programmer
NP: How long will it take?
P: It'll take as long as it takes.
NP: I don't understand. What does that mean?
P: When you tell me that the product is finished, it's done.
NP: You mean you can't estimate how long it'll take?
P: I can't estimate when you'll decide that it is done, therefore an
accurate prediction is impossible. From experience I know that a
project like this can take from three to nine months. A lot