Skip to content
View Common-Currency.json
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
View draw-tree.py
import cairo
from contextlib import contextmanager
@contextmanager
def saved(cr):
cr.save()
try:
yield cr
finally:
cr.restore()
View body.html
<html>
<head>
<script type="text/javascript" src="curry.js" />
<title>currying in javascript</title>
</head>
<body>
<div id="item">default</div>
</body>
</html>
View bak.sh
# quick and easy backuping
# put int ~/src/bak
cp -r "$1" "$1.bak"
View foreman.rb
class Foreman
attr_accessor :units_of_work, :workers_count
def initialize attrs = {}
@units_of_work = attrs[:units_of_work]
@workers_count = attrs[:workers_count]
end
def fair_shares
even_shares = Array.new(@workers_count) { @units_of_work / @workers_count }
View forking_and_waiting.rb
pids = []
[0, 1, 2].each do |i|
pids << fork do
sleep 5 - i
puts "Hi from #{i}\n"
end
end
puts "done forking" # note: if you >> this file to another file, you will need $stdout.flush to ensure proper write ordering
pids.each { |pid| Process.wait pid }
View git_mv_a_bunch_of_files.sh
for f in `ls ./*.png`; do git mv $f $(echo $f | sed s/control/ctrl/); done
View running_average_generator.rb
class RunningAverageGenerator
def initialize seed = []
@sum = seed.reduce(:+) || 0
@count = seed.count || 0
end
def << number
@count += 1
@sum += number
@sum / @count.to_f
Something went wrong with that request. Please try again.