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
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
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
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
#!/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
module Delegator | |
def self.extended(into) | |
(class << into; self; end).send :attr_accessor, :delegates | |
into.delegates = [] | |
into.send :define_method, :method_missing do |method, *args, &block| | |
self.class.delegates.map{|delegate| send(delegate) }.each do |receiver| | |
next unless receiver.respond_to?(method) | |
return receiver.send(method, *args, &block) | |
end |
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 'json' | |
require 'pstore' | |
class JSON::Store < PStore | |
def dump(table) | |
JSON.pretty_unparse(@table) | |
end | |
def load(content) | |
JSON.load(content) |
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 'ramaze' | |
require 'json' | |
class Main < Ramaze::Controller | |
provide(:json, type: 'application/json'){|action, value| value.to_json } | |
def index | |
{'some' => 'json'} | |
end | |
end |
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
# Maintainer: Michael Fellinger <[email protected]> | |
pkgname=google-talkplugin | |
pkgver=0 | |
pkgrel=1 | |
pkgdesc="Video chat plugin for Gmail, iGoogle, and Orkut" | |
arch=(x86_64) | |
url="http://www.google.com/chat/video" | |
license=('unknown') | |
depends=('libpng12' 'lib32-openssl-compatibility') | |
source=("http://dl.google.com/linux/direct/${pkgname}_current_amd64.deb") |
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 | |
require 'pp' | |
require 'coverage' | |
Coverage.start | |
ARGV.each do |arg| | |
require_relative arg | |
end |