Ben Olive sionide21

View sqrtSums.hs
1 2
sqrtSums :: Double -> Int
sqrtSums x = length (takeWhile (<x) (scanl1 (+) (map sqrt [1..]))) + 1
View gist:7807702
1 2 3 4 5
$ time ls -lh > ~/files.txt
 
real 186m14.030s
user 0m9.361s
sys 43m37.939s
View gist:7356242
1 2 3 4 5 6 7 8 9 10
ve() {
local curdir ve
curdir="$PWD"
[ -z "$1" ] && ve="ve" || ve="$1"
while ! ls -d "$ve" >/dev/null 2>&1; do
if [ "$PWD" == "/" ]; then
echo "Cannot find a '$ve' directory on the current path" >&2
cd $curdir
return -1
fi
View gist:5214764
1 2 3
[alias]
pep8 = !git status -s | awk '{print $2}' | grep '.py' | xargs pep8
pyflakes = !git status -s | awk '{print $2}' | grep '.py' | xargs pyflakes
View regexen.rb
1 2 3 4 5 6 7 8 9 10
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)
View taxes.rb
1 2 3 4 5 6 7 8 9 10
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
View simple_form.rb
1 2 3 4 5 6 7 8 9 10
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
View test.rb
1 2 3 4 5 6 7 8 9
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
View gist:850065
1 2
sqlite> select count(*) from moz_downloads;
Error: database disk image is malformed
Something went wrong with that request. Please try again.