Skip to content

Instantly share code, notes, and snippets.

🌊
Build that!

David Gil dgilperez

🌊
Build that!
Block or report user

Report or block dgilperez

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
@dgilperez
dgilperez / will_paginate_supports_internationalization.rb
Created Jun 10, 2011
monkey-patching will_paginate to support internationalization for page_entries_info using gettext
View will_paginate_supports_internationalization.rb
# 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 Dec 11, 2011
Authlogic to Devise Migration (rails3.1)
View gist:1461752
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 Dec 11, 2011 — forked from ianmurrays/I18n devise es
devise I18n file in spanish
View I18n devise es
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 Dec 11, 2011
ERB to HAML rake task
View erb_to_haml.rake
# 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 Dec 14, 2011 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
View installation.sh
$ 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 Dec 20, 2011 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
View installation.sh
$ 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 Jan 4, 2012 — 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
View Selector de Idioma con Rails 2.3.8
#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 Feb 8, 2012 — forked from defkode/adsense_helper.rb
Google Adsense Rails 3 helper
View adsense_helper.rb
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 Nov 6, 2018
Compiling and Installing Sphinx 2.0 with libstemmer
View gist:1960607
# 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 Apr 4, 2012 — forked from eparreno/gist:2300165
About estimations
View gist:2304667
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
You can’t perform that action at this time.