Skip to content

Instantly share code, notes, and snippets.

Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@defunkt
defunkt / resque.py
Created November 3, 2009 19:49
Resque client in Python
from redis import Redis
import simplejson
class Resque(object):
"""Dirt simple Resque client in Python. Can be used to create jobs."""
redis_server = 'localhost:6379'
def __init__(self):
host, port = self.redis_server.split(':')
self.redis = Redis(host=host, port=int(port))
@steveh
steveh / gist:788790
Created January 20, 2011 22:12
Bash script to start fcgiwrap
We couldn’t find that file to show.
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@mbbx6spp
mbbx6spp / gist:1083536
Created July 14, 2011 21:45 — forked from onethirtyfive/gist:1083182
Class-Table Inheritance Meta-model for DataMapper
# Module with mixins for common queries across descendants:
module Descendant
# I guess I could use ActiveSupport::Concern here...
def self.included(receiver)
receiver.extend ClassMethods
receiver.send :include, InstanceMethods
end
module ClassMethods
def self.included(receiver)
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},
anonymous
anonymous / gist:1406238
Created November 29, 2011 20:09
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@asianmack
asianmack / gist:1482804
Created December 15, 2011 20:49
Emoji Cheat Sheet
:+1:
:-1:
:0:
:1:
:109:
:2:
:3:
:4:
:5:
:6:
@azizmb
azizmb / message_queue_pipeline.py
Created January 7, 2012 08:54
Scrapy pipeline to enque scraped items to message queue using carrot
from scrapy.xlib.pydispatch import dispatcher
from scrapy import signals
from scrapy.exceptions import DropItem
from scrapy.utils.serialize import ScrapyJSONEncoder
from carrot.connection import BrokerConnection
from carrot.messaging import Publisher
from twisted.internet.threads import deferToThread
@skipoleschris
skipoleschris / SSLCommunications.scala
Created February 16, 2012 08:48
Trait for doing SSL with mutual certificate exchange using dispatch http
import java.security._
import java.net.URL
import javax.net.ssl.{KeyManagerFactory, TrustManagerFactory}
import org.apache.http.conn.ssl.SSLSocketFactory
import org.apache.http.conn.scheme.Scheme
import dispatch._
// Gist trait for doing SSL with mutual certificate exchange using dispatch.
// This works without having to set up global JDK-wide keystore and truststore files.
//