Instance | Branch |
---|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warden::Strategies.add(:bcrypt) do | |
def valid? | |
params[:username] || params[:password] | |
end | |
def authenticate! | |
return fail! unless user = User.first(:username => params[:username]) | |
if user.encrypted_password == params[:password] | |
success!(user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For linux | |
sudo apt-get install unzip | |
wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/; | |
sudo chown -R $(whoami):$(groups $(whoami) | cut -d' ' -f1) /usr/local/bin/chromedriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For mac | |
brew install unzip | |
wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/2.12/chromedriver_mac32.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/; | |
sudo chown -R $(whoami):$(groups $(whoami) | cut -d' ' -f1) /usr/local/bin/chromedriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require("q"); | |
var phantom=require('node-phantom'); | |
function promisify(nodeAsyncFn, context, modifier) { | |
return function() { | |
var args = args = Array.prototype.slice.call(arguments); | |
var defer = Q.defer() | |
args.push(function(err, val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web.iweb import IBodyProducer | |
from twisted.internet import defer | |
from twisted.web.client import Agent | |
from twisted.web.http_headers import Headers | |
import urllib | |
class StringProducer(object): | |
implements(IBodyProducer) | |
def __init__(self, body): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
def urlencode(s): | |
return urllib2.quote(s) | |
def urldecode(s): | |
return urllib2.unquote(s).decode('utf8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.contrib.auth.decorators import login_required | |
from django.utils.cache import patch_response_headers | |
from django.utils.decorators import method_decorator | |
from django.views.decorators.cache import cache_page, never_cache | |
from django.views.decorators.csrf import csrf_exempt | |
class NeverCacheMixin(object): | |
@method_decorator(never_cache) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For IE | |
.btn-inverse:active, | |
.btn-inverse.active { | |
background-color: #080808 \9; | |
} | |
// Add 'btn-flat' to your buttons | |
.btn-flat { | |
filter:progid:DXImageTransform.Microsoft.Gradient(enabled='false'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oldSync = Backbone.sync; | |
Backbone.sync = function(method, model, options){ | |
options.beforeSend = function(xhr){ | |
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN); | |
}; | |
return oldSync(method, model, options); | |
}; |