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
[alias] | |
pep8 = !git status -s | awk '{print $2}' | grep '.py' | xargs pep8 | |
pyflakes = !git status -s | awk '{print $2}' | grep '.py' | xargs pyflakes |
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
class Test | |
include Enumerable | |
def each | |
yield "Hello" | |
yield "World" | |
end | |
end | |
enum = Test.new | |
array = ["Hello", "World"] |
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
class Regexen | |
def initialize(a={}) | |
a.default_proc = proc { |h,k| [] } | |
@good = a[:good] | |
@bad = a[:bad] | |
end | |
def good=(r) | |
@good << r | |
end | |
def bad=(r) |
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
SINGLE_RATES = {8700 => 0.10, 35350 => 0.15, 85650 => 0.25, 178650 => 0.28, 388350 => 0.33, Float::INFINITY => 0.35} | |
MARRIED_RATES = {17400 => 0.10, 70700 => 0.15, 142700 => 0.25, 217450 => 0.28, 388350 => 0.33, Float::INFINITY => 0.35} | |
def taxes(amt, rates=SINGLE_RATES) | |
last_cap = 0 | |
taxes = 0 | |
rates.each do |cap, rate| | |
taxable = amt - last_cap | |
if taxable > 0 | |
taxes += [cap, taxable].min * rate |
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
1. Use latest build | |
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git' | |
2. Create an initializer | |
# /config/initializers/simple_form.rb | |
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
# Wrappers are used by the form builder to generate a complete input. | |
# You can remove any component from the wrapper, change the order or even |
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
require 'dns' | |
server = DNS::Server.new | |
server.handle_a do |query, response| | |
response << DNS::Record::A.new(query.name, "192.168.12.10#{rand 10}") | |
end | |
server.listen |
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
sqlite> select count(*) from moz_downloads; | |
Error: database disk image is malformed |
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
export FIGNORE=".svn" |
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
${FOO##*( )} |
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
FOO=" Bar" |