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 '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 |
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
#!/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? |
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
#!/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 |
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
# 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) |
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
from signal import * | |
from subprocess import * | |
Popen(['true']).communicate() | |
signal(SIGCHLD, SIG_IGN) | |
Popen(['true']).communicate() |
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
#!/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() |
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
bin | |
*.pidb | |
*.userprefs |
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
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 |
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
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) |
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
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() |
OlderNewer