Skip to content

Instantly share code, notes, and snippets.

@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,
# 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 / 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
@pedrodelgallego
pedrodelgallego / a.rb
Created February 15, 2011 19:41
example.rb
Kernel.send :define_method, :namespace do |*args|
....
end

Resque Command Line Cheatsheet

inspect a faied job in resque:

failed = JSON.parse(Resque.redis.lpop("failed"))
{
"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",
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"]
@pedrodelgallego
pedrodelgallego / config.js
Created August 27, 2012 18:29
testacular is not finding jasmine
// base path, that will be used to resolve files and exclude
basePath = '../';
// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
"spec/*.js"
];
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Chapter 9: 2 Column Layout - positioning</title>
<link rel="stylesheet" href="style.css" />
<style type="text/css" media="screen">
/* Write here your code */
</style>
</head>
<body>
/* Learn layout */