Skip to content

Instantly share code, notes, and snippets.

View jacortinas's full-sized avatar
💭
Coding

Jose Cortinas jacortinas

💭
Coding
View GitHub Profile
print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % (
age, height, weight)
@jacortinas
jacortinas / create_admin.rake
Created April 6, 2011 22:30
Creates an admin user from the command line, hides the input of the password fields. Also show colorized errors and success output.
require 'highline'
hl = HighLine.new
desc "Create an admin user for the current environment"
task :create_admin => :environment do
puts "\n== Creating an admin ==\n"
email = hl.ask(' Email: ')
password = hl.ask(' Password: ') { |q| q.echo = '*' }
@jacortinas
jacortinas / gist:918703
Created April 14, 2011 00:26
Small application has like 5 specs right now.
Running: 'time rake spec'
== ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
Finished in 0.31999 seconds
5 examples, 0 failures
real 0m12.500s
user 0m10.200s
sys 0m1.676s
Rubinius Crash Report #rbxcrashreport
[[Exception]]
A toplevel exception occurred
Thread has been interrupted (Interrupt)
Backtrace:
{ } in Rubinius::Loader#signals at kernel/loader.rb:124
Signal.run_handler at kernel/common/signal.rb:68
Rubinius.received_signal at kernel/delta/rubinius.rb:240
@jacortinas
jacortinas / app_config.rb
Created July 1, 2011 15:42
Redis Logging
# config/initializers/app_config.rb
# An initializer that contains config stuff
# ...
class RedisConfig < Settingslogic
source "#{Rails.root}/config/redis.yml"
namespace Rails.env
end
@jacortinas
jacortinas / Gemfile
Created July 19, 2011 01:29
This used to be much more complicated, but nothing felt as solid as this core setup.
...
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
gem 'spork', '~> 0.9.0.rc'
...
gem 'rb-fsevent' # recommended for non-polling filesystem event notifications
gem 'growl'
gem 'guard'
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
redis_instance.pipelined do
[1,2,3].each do |item|
redis_instance.sadd 'some_key', item
end
end
@jacortinas
jacortinas / gist:3079083
Created July 9, 2012 21:30
Psych error using rbenv, ruby 1.9.3-p194 and rails 3.2.6
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant ANY
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF8
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF16LE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF16BE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:12: warning: already initialized constant ANY
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:15: warning: already initialized constant UTF8
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:18: warning: already initialized constant UTF16LE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:
@jacortinas
jacortinas / authentication.rb
Created July 13, 2012 09:50
The difference between testing a small authentication file with BCrypt cost set to normal, then set to min.
# app/models/user/authentication.rb
require 'bcrypt'
class User
# Password authentication related methods and utilities.
module Authentication
extend ActiveSupport::Concern
module ClassMethods