Skip to content

Instantly share code, notes, and snippets.

View foca's full-sized avatar
👋
Looking for work!

Nicolás Sanguinetti foca

👋
Looking for work!
View GitHub Profile
Jurassic Park (1993) movie script
by David Koepp.
Based upon the novel by Michael Crichton and on adaption by Michael Crichton and Malia Scotch Marmo.
Final draft, December 11, 1992.
More info about this movie on IMDb.com
1 EXT JUNGLE NIGHT
# so everyone uses something like this for request-level authentication in Sinatra
class TestApp < Sinatra::Application
get "/path" do
require_authentication!
...
end
end
# and complain about how sinatra doesn't support per-route before filters like um, "other frameworks"
require "open-uri"
require "active_support/base64"
class Mixpanel
def initialize(token, clock=Time.now)
@auth_token = token
@clock = clock
end
def event(name, properties={})
module Numbers
def foo
2
end
def bar
foo * 2
end
end
@foca
foca / list.rb
Created September 5, 2010 01:20
module Pathfinder
class Feat
class List
class NoMatchingSlotsAvailable < StandardError; end
include Enumerable
def initialize
@feats = []
end
require "ffaker"
class ActiveRecord::Base
def self.define_factory(name=:factory, &block)
scope name, lambda { |overrides={}|
attributes = instance_eval(&block).merge(overrides)
where(attributes)
}
end
end
@foca
foca / gist:579194
Created September 14, 2010 15:17
Adding class methods from a module, that are added to the class hierarchy (so you can use super, unlike with Module#extend)
module Foo
def find(*)
"Foo#find"
end
end
class Blah
class << self
include Foo
end
@foca
foca / isolated_rails.rb
Created September 24, 2010 14:11
Rails template using Isolate for dependency management. Most of the code was blatantly stolen from jbarnette
run "rm public/index.html"
file "Isolate", <<-END
gem "rails", "3.0.1"
gem "haml", "3.0.22"
gem "sqlite3-ruby", "1.3.1"
env :development do
gem "haml-rails", "0.2"
end
@foca
foca / map.txt
Created October 10, 2010 02:41
How to get from my house to the office
This is basically an approximate drawing of the map between my home (H) and our
new office (O). The real map is http://bit.ly/home-to-office ("B" in the map is
my house, "A" the office).
I was bored while walking home from the office, and started thinking if it's
shorter to take a left or a right as I leave my house. (This only holds for
walking, biking there I must go through route a and come through route b due to
one-way streets, but I will walk there most days, since it's around 800-900m.)
# :facepalm:
class User < ActiveRecord::Base
validate do |user|
if user.login.blank?
user.errors.add_to_base("User Name can't be blank")
else
user.errors.add_to_base("User Name is too short(Minimum is 3 characters)") if user.login.length<3 and user.login.length !=0
user.errors.add_to_base("User Name is too long(Maximum is 3 characters)") if user.login.length>40
user.errors.add_to_base("User Name has already been taken.") if User.find_by_login(user.login)