Skip to content

Instantly share code, notes, and snippets.

View jleedev's full-sized avatar
🧙‍♀️

Josh Lee jleedev

🧙‍♀️
View GitHub Profile
@jleedev
jleedev / fib.rb
Created December 10, 2009 01:12
Fibonacci numbers in ruby
require 'matrix'
# fib1: Fast algorithm using the Golden Ratio
$sqrt5 = Math.sqrt 5
$phi = (1 + $sqrt5) / 2
def fib1 n
(($phi**n - (1-$phi)**n) / $sqrt5).to_int
end
@jleedev
jleedev / wallrotate.rb
Created February 9, 2010 08:39 — forked from tensorpudding/wallrotate.rb
Wallpaper rotation script
#!/usr/bin/env ruby
srand
command = ["/usr/bin/feh","--bg-scale"]
dir = ARGV[0] || "/home/michael/wall/default/"
choice = Dir[dir + "*.{jpg,png,jpeg}"].choice
system *([command] + [choice]) unless choice.empty?
@jleedev
jleedev / razr.rb
Created February 26, 2010 17:50
Timestamps RAZR pictures
#!/usr/bin/env ruby
Dir["*.jpg"].each do |file|
mm,dd,yy,h,m = [0,3,6,9,11].map { |start| file[start,2] }
stamp = "20%s-%s-%s %s:%s" % [yy,mm,dd,h,m]
`exiv2 -k -Y 20#{yy} -O #{mm} -D #{dd} -a#{h}:#{m} ad "#{file}"`
exit $?.exitstatus if $?.exitstatus.nonzero?
`touch -d "#{stamp}" "#{file}"`
exit $?.exitstatus if $?.exitstatus.nonzero?
end
@jleedev
jleedev / sansa-clip.py
Created July 16, 2010 21:28
Put track numbers in a format that the Sansa Clip doesn't choke on.
# Put track numbers in a format that the Sansa Clip doesn't choke on.
from mutagen.easyid3 import EasyID3
import sys,re
r = re.compile('\d/\d\d')
for f in sys.argv[1:]:
print f
g = EasyID3(f)
@jleedev
jleedev / gist:497243
Created July 29, 2010 04:29
Screwing with subprocess
from signal import *
from subprocess import *
Popen(['true']).communicate()
signal(SIGCHLD, SIG_IGN)
Popen(['true']).communicate()
@jleedev
jleedev / gist:503720
Created August 1, 2010 20:16
Hello world in IronPython with WinForms
#!/usr/bin/env ipy
import clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Form, Button, Application
class HelloForm(Form):
def __init__(self):
super(HelloForm, self).__init__()
self.button = Button()
@jleedev
jleedev / .gitignore
Created October 22, 2010 16:24
Gtk# font viewer
bin
*.pidb
*.userprefs
@jleedev
jleedev / fontlist.hs
Created October 22, 2010 17:40
Gtk2hs font viewer
import Char
import Control.Applicative
import Control.Monad
import Data.IORef
import Data.Ord
import Graphics.UI.Gtk
import qualified Graphics.UI.Gtk.ModelView as L
import Graphics.UI.Gtk.TreeList.TreeIter
import List
import Maybe
import b
test1 = 'a'
test2 = None
test3 = '3'
if __name__ == '__main__':
print test1, test2, test3 #prints 'a', None, 3
b.changeVars()
print test1, test2, test3 #prints 'a', None, 3 (i.e. nothing has changed)
import sys
print sys.argv[0]
import os.path
ROOT = os.path.join(os.path.dirname(sys.argv[0]), '..')
print open(os.path.join(ROOT, 'res', 'hello.txt')).read()