Skip to content

Instantly share code, notes, and snippets.

View jaimeiniesta's full-sized avatar

Jaime Iniesta jaimeiniesta

View GitHub Profile
class Stat < ActiveRecord::Base
before_create :get_counts
validates_uniqueness_of :date
def self.create_all
(Plant.find(:first, :order => 'created_at').created_at.to_date..(1.day.ago.to_date)).each do |date|
Stat.find_or_create_by_date(date)
logger.info "Stat created for #{date}"
end
universe.log(ship, "your travel is gonna take until: "+
"#{Utils.ticks_to_time( 300 )} seconds from now")
@jaimeiniesta
jaimeiniesta / gist:953227
Created May 3, 2011 12:13
Paperclip + S3 with credentials from ENV and independent buckets

When using S3 for storage on a project, you should avoid commiting your S3 credentials for improved security. Instead of this, set them as environment variables on each machine like this:

S3 credentials from ENV

# .bash_profile
export APPNAME_S3_KEY="dasdsadsadsad"
export APPNAME_S3_SECRET="dfd8f8dfdfddfdsfdsafr332"
@jaimeiniesta
jaimeiniesta / gist:898669
Created April 1, 2011 19:05
tiendas gratis en Madrid
Tienda gratis de La Piluka
Plaza de Corcubión, 16
Metro: B. del Pilar/Peñagrande
Bus: 147, 42, 49, 83, 132
Tienda gratis de La Prospe
c/ Luís Cabrera 19
91 562 70 19
Metro: Prosperidad o Avda. América.
require "ripper"
require "pp"
sample_source = <<-EOS
class Person
def initialize(name)
@name = name
end
def first_name
rvm use 1.9.2-p0@ghendry-s6e1
!.*/(\.[^/]*|public\/images|doc\/app|vendor\/rails|cache|tmp|log|logs|system|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$
#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)
# Example on how to get the local file path for an attachment_fu attachment on a model
# (photos, in this example)
def attachment_fu_local_file_path
Rails.root+"/public/photos/"+("%08d" % id).scan(/..../).join('/')+"/"+filename
end
# spec/acceptance/blog_spec.rb
require File.dirname(__FILE__) + '/acceptance_helper'
feature "Feature name", %q{
In order to have a blog
As an administrator
I want to manage posts
} do