This file contains hidden or 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
#!/usr/bin/env ruby | |
## git-rank-contributors: a simple script to trace through the logs and | |
## rank contributors by the total size of the diffs they're responsible for. | |
## A change counts twice as much as a plain addition or deletion. | |
## | |
## Output may or may not be suitable for inclusion in a CREDITS file. | |
## Probably not without some editing, because people often commit from more | |
## than one address. | |
## |
This file contains hidden or 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
LotteryTicket = | |
get_picks: -> @picks | |
set_picks: (@picks) -> | |
get_purchased: -> @purchase | |
set_purchased: (@purchased) -> |
This file contains hidden or 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
use Rack::MailExceptions | |
use Sinatra::ExceptionHandler | |
use SetMailException | |
run yourapp |
This file contains hidden or 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
class SetMailException | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
status, header, body = @app.call(env) | |
rescue => ex | |
env['mail.exception'] = ex | |
raise ex |
This file contains hidden or 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
def check(number) | |
number = number.gsub(/\D+/, '') | |
first = Hash.new{|h,k| h[k] = number[0, k].to_i } | |
size = number.size | |
# American Express 34, 37 Yes 15 Luhn algorithm AmEx | |
if [13, 16].include?(size) && number =~ /^(34|37)/ | |
:AmEx | |
# China UnionPay 622126-622925, 624-626, 6282-6288 Yes 16-19 unknown CUP | |
elsif (16..19) === size && ((622126..622925) === first[6] || |
This file contains hidden or 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
url: require 'url' | |
querystring: require 'querystring' | |
request: require 'request' | |
class Rpx | |
constructor: (apiKey) -> | |
@apiKey: apiKey | |
authInfo: (token, callback) -> | |
@apiCall 'auth_info', {token: token}, (data) -> |
This file contains hidden or 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
module Ramaze | |
module Helper | |
module ReCaptcha | |
# Call this to generate the actual ReCaptcha script into your template. | |
# Options can include | |
# [rcc_pub] public recaptcha key (defaults to RCC_PUB constant) | |
# [rcc_priv] privte recaptcha key (defaults to RCC_PRIV constant) | |
# [ssl] generate ssl-based output, defaults to false | |
# | |
# This method also sets :rcc_err into the session. |
This file contains hidden or 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
# Simple RPN calculator with stack. | |
# Example usage: | |
# >> 400 400 400 * | |
# Top of stack: 64000000 | |
# >> 40 40 * | |
# Top of stack: 102400000000 | |
# >> 40 | |
# Top of stack: 40 | |
# >> 30 | |
# Top of stack: 30 |
This file contains hidden or 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
require 'activesupport' | |
module Password | |
VERSION = '1.0.0' | |
FILENAME = "#{ENV['HOME']}/.they_stole_my_facebook_login_oh_noez" # honestly, "security", who gives a shit | |
SITES = {} | |
def set(credentials) | |
SITES[credentials[:site]] = {:username => credentials[:username], | |
:password => credentials[:password]} | |
end | |
def username(site) |
This file contains hidden or 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
require './examples/javascript' | |
sys: require 'sys' | |
p: (obj) -> sys.puts(sys.inspect(obj, false, 100)) | |
p JSGrammar.parse('something.that(/works/)') |