Skip to content

Instantly share code, notes, and snippets.

[kjell@alentour ~/Sites/beaker]> rake
(in /Users/kjell/Sites/beaker)
/opt/local/bin/ruby -Ilib:test "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb" "test/functional/clients_controller_test.rb" "test/functional/code/commits_controller_test.rb" "test/functional/code/tree_controller_test.rb" "test/functional/deploy/deploys_controller_test.rb" "test/functional/deploy/servers_controller_test.rb" "test/functional/home_controller_test.rb" "test/functional/integrations_controller_test.rb" "test/functional/messages_controller_test.rb" "test/functional/notes/notes_controller_test.rb" "test/functional/notes/versions_controller_test.rb" "test/functional/projects_controller_test.rb" "test/functional/scrum/sprints_controller_test.rb" "test/functional/scrum/stories_controller_test.rb" "test/functional/scrum/story_comments_controller_test.rb" "test/functional/sessions_controller_test.rb" "test/functional/user_assignments_controller_test.rb" "test/functional/users_controller_test.rb"
/Users/kje
@kjell
kjell / itunes.rb
Created October 13, 2008 22:40
A Ruby script to drive iTunes in an alarm–clock–inspired fashion.
#!/usr/bin/env ruby
%w(rubygems chronic rbosa).each {|lib| require lib}
itunes = OSA.app('iTunes')
playlist = itunes.sources[0].playlists.select{|p| p.name == 'radio'}.pop
($sleep = true and ARGV.pop if ARGV.last.match(/!/))
directives = eval("{#{ARGV.last.gsub('-', '=>')}}") rescue []
chronic = lambda{|time| time.respond_to?(:integer?) ? Time.now + time*60 : (t = Chronic.parse(time, :context => :future); t < Time.now ? t += 24*60*60 : t )}
display_time = lambda {|t| t ||= Time.now; t.strftime('%H:%M %p')}
import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL
main = do
(name,_) <- getArgsAndInitialize
createWindow name
displayCallback $= display
mainLoop
display = do
require "rubygems"
require "hpricot"
require "open-uri"
url = "http://feeds.feedburner.com/Rubyconf2008-Confreaks"
(Hpricot(open url)/:enclosure).map {|x| x.attributes["url"]}.uniq.each do |vid|
filename = vid.gsub(/http:.+\//, '')
filename.gsub!(/-/, "_")
next if File.exist?(filename)
%w(rubygems open-uri hpricot ruby-debug prettyprint rbosa activesupport).each {|lib| require lib}
$KCODE = 'u'
class Track
attr_accessor :title, :composer, :artist
def initialize(*args)
@title = args.shift
@composer = args.shift
@artist = case args.size
when 1 then args.shift
@kjell
kjell / 1.txt
Created December 11, 2008 20:48
A cheap–branching based approach to issue tracking.
# So who needs a bug–tracker when you can do it all via cheap, easy, fast, local branching in git?
[kjell@adelaide ~/D/forest{master}]> git branch
* master
refactor/indexer
refactor/lose-settings
refactor/top-level-lib
refactor/write-files
rework-entries
# http://www.facebook.com/jobs_puzzles/index.php?puzzle_id=7
cap = ARGV[0] ? File.read(ARGV[0]).to_i : 189
=begin
A simplistic, brute force solution:
=end
mod = lambda {|n, m| n%m==0}
word = lambda {|k| return 'Hop' if mod[k,15]; return 'Hophop' if mod[k,5]; return 'Hoppity' if mod[k,3]}
(1..cap).map {|i| s = word[i]; s ? puts(s) : next}
##— http://github.com/raganwald/homoiconic/tree/master/2008-12-17/another_fibonacci.md
# Fibonacci has a closed form? That shit is probably pretty fast…
# The only problem is that ruby can't handle exponenting floats by modestly large values: Fib[10000] => Infinity
Fib = lambda do |n|
sqrt5 = Math.sqrt(5)
phi = (1+sqrt5)/2
(f = (phi**n-(-1/phi)**n)/sqrt5).infinite? ? f : f.floor
end
A000045 = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169]
(rdb:1) irb
>> atts
=> {:description=>"TerRoc™ 330 by Inov-8 at Zeta Zappos"}
>> atts.to_yaml
=> "--- \n:description: "TerRoc\\xE2\\x84\\xA2 330 by Inov-8 at Zeta Zappos"\n"
>>
$KCODE = 'u' is set. Generally, fancy UTF–whatever characters are behaving.
But soon as I convert to yaml, they all get messed up and turned to octal.
It's infuriating! And I can't seem to fix it.
#!/opt/local/bin/fish
# Merge the current branch back into master.
function parse_git_branch; sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; end
set branch_to_merge (parse_git_branch)
git co master
git merge $branch_to_merge