Skip to content

Instantly share code, notes, and snippets.

View snowyu's full-sized avatar

Riceball LEE snowyu

View GitHub Profile
@snowyu
snowyu / Gemfile
Created March 11, 2012 04:30 — forked from nu7hatch/Gemfile
Padrino authentication with Warden
# ...
gem 'padrino-warden', :git => "git://github.com/zmack/padrino-warden.git"
gem 'authtools'
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)
# Validates whether the value of the specified attribute matches the format of an URL,
# as defined by RFC 2396. See URI#parse for more information on URI decompositon and parsing.
#
# This method doesn't validate the existence of the domain, nor it validates the domain itself.
#
# Allowed values include http://foo.bar, http://www.foo.bar and even http://foo.
# Please note that http://foo is a valid URL, as well http://localhost.
# It's up to you to extend the validation with additional constraints.
#
# class Site < ActiveRecord::Base
@snowyu
snowyu / 12306AutoSubmit.user.js
Created January 9, 2012 08:01
12306 Auto Submit
/*
12306 Auto Submit => A javascript snippet to help you auto submit.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js