Skip to content

Instantly share code, notes, and snippets.

describe("Model.extend", function() {
var applicant;
beforeEach(function(){
// I am passionate developer who learned to stop worrying and love Javascript
//
applicant = Person.init({
name: "Pedro Del Gallego",
github: "https://github.com/pedrodelgallego",
skills: ['ruby', 'css3', 'html5', 'scuba diving', 'js'],
passion: ["Javascript"]
{
"failed_at" => "2011/07/31 13:02:32",
"payload" => {
"args" => [
[0] {
"coordinates" => nil,
"truncated" => false,
"favorited" => false,
"created_at" => "Sun Jul 31 13:01:23 +0000 2011",
"id_str" => "97653080010661888",

Resque Command Line Cheatsheet

inspect a faied job in resque:

failed = JSON.parse(Resque.redis.lpop("failed"))
@pedrodelgallego
pedrodelgallego / a.rb
Created February 15, 2011 19:41
example.rb
Kernel.send :define_method, :namespace do |*args|
....
end
@pedrodelgallego
pedrodelgallego / example.rb
Created February 15, 2011 16:26
example.rb
describe "Hash literal" do
before do
@hash = {}
end
it "{} should return an empty hash" do
@hash.size.should == 0
@hash.should == {}
end
# mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
settings = URI.parse(ENV['MONGOLAB_URL'] || ENV['MONGOHQ_URL'] || 'mongodb://localhost/app_test')
database_name = settings.path.gsub(/^\//, '')
Mongoid.configure do |config|
config.master = Mongo::Connection.new(settings.host, settings.port).db(database_name)
config.master.authenticate(settings.user, settings.password) if settings.user
end
@pedrodelgallego
pedrodelgallego / Incoming_mails_controller.rb
Created December 6, 2010 15:58
This class control the incoming mails, parse the information in it, extract the attached picture and upload it to amazon s3 using paperclip, A monkey patch hack is needed to solve a inconsistence between paperclip and heroku/cloudmailin
class IncomingMailsController < ApplicationController
skip_before_filter :verify_authenticity_token
def create
message = Mail.new(params[:message])
user = User.where(:email=>message.from).first
if !message.attachments.first.nil?
post = Post.new(
:title => message.subject,
@pedrodelgallego
pedrodelgallego / kernel-revisited.scm
Created December 6, 2010 15:45
Scarecrow a lisp 1 like interpreter. It is written in Racket, a plt-scheme dialect
#lang racket/base
(require racket/match)
;; ----------------------------------- Evaluator.
(define (eval expr env)
(match expr
;; __environment__ will return the current environment/state of the interpreter.
[`__environment__ env]
@pedrodelgallego
pedrodelgallego / tags-counter.js
Created November 23, 2010 15:59
A map reduce function that count the tags in a gist
use gistcube
map = function() {
if (!this.tags) {
return;
}
for (index in this.tags) {
emit(this.tags[index], 1);
}
@pedrodelgallego
pedrodelgallego / pony-example.rb
Created October 27, 2010 07:30
A working example of pony and sinatra.
# You need to install these gems.
# - smtp_tls
# - pony
post "/contact-us" do
Pony.mail :to => 'pedro.delgallego@gmail.com',
:from => "#{params[:email]}",
:subject => "Contact SFT : #{params[:name]}",
:body=> "#{params[:body]}, --- Contact Address #{params[:email]}",
:via => :smtp,