Skip to content

Instantly share code, notes, and snippets.

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

Josh Lee jleedev

🧙‍♀️
View GitHub Profile
@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()
diff --git i/src/scene.cpp w/src/scene.cpp
index 8382ef7..3ef0d1a 100644
--- i/src/scene.cpp
+++ w/src/scene.cpp
@@ -92,6 +92,9 @@ Color Scene::raytrace(const Ray& camera_ray, int level) const {
continue;
float int_distance2 = Ray::makeRay(camera_ray.getOrigin(),
intersection->getOrigin()).getDir().magnitude2();
+ if (int_distance2 < 1e-6)
+ // Too close! We must move forwards a little.
@jleedev
jleedev / say
Created April 8, 2011 20:19 — forked from tensorpudding/say
#!/bin/sh
# A very simplified version of OSX's say, using festival
# Usage: say [words]
if [ $# = 0 ]
then
echo "Usage: `basename $0` [words]"
exit 1
fi
#!/bin/sh
export PAGER=
[ $# -le 1 ] || (echo "Usage: git how [ref]"; exit -1)
[ "$1" ] && ref="$1" || ref=HEAD
old="$ref@{1}"
git rev-parse --short "$old" | tr -d '\n'
printf ..
git rev-parse --short "$ref"
josh@tortuga:~/repo1$ (master) git ls-files -s
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 files
160000 8b2785e26ff50203b827a29a590fc4cf8b91fe10 0 repo2
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 stuff
josh@tortuga:~/repo1$ (master) (cd repo2; git rev-parse HEAD)
8b2785e26ff50203b827a29a590fc4cf8b91fe10
josh@tortuga:~/repo1$ (master) (cd repo2; git commit --allow-empty -m 'Updated repo2')
[master 0224058] Updated repo2
josh@tortuga:~/repo1$ (master) git status
# On branch master
class TumbleDRYer
def initialize filename
@hash = Hash.new 0
@links = Hash.new 0
previous = nil
open(filename).read.scan /\w+|\W+/ do |word|
unless previous.nil?
@links[[previous,word]] += 1
end
@hash[word] += 1