Skip to content

Instantly share code, notes, and snippets.

Avatar

Tristan Hume trishume

View GitHub Profile
@trishume
trishume / collatz.rb
Created Jul 6, 2011
Collatz conjecture chains in ruby
View collatz.rb
# small recursive version
def collatzr(num,arr = [])
return arr if arr.unshift(num)[0] == 1
num.even? ? collatzr(num / 2,arr) : collatzr(num * 3 + 1,arr)
end
# pretty looping version
def collatz(num,arr = [])
while num != 1
arr << num
num = num.even? ? num / 2 : num * 3 + 1
@trishume
trishume / collatz.rb
Created Jul 18, 2011
Graphviz collatz.
View collatz.rb
# gem install GraphvizR
require 'graphviz_r'
# small recursive version
def collatzr(num,arr = [])
return arr if arr.unshift(num)[0] == 1
num.even? ? collatzr(num / 2,arr) : collatzr(num * 3 + 1,arr)
end
# pretty looping version
def collatz(num,arr = [])
while num != 1
View print-x.subleq
6 7 3
7 -1 9
2 122 0
8 35 -7
@trishume
trishume / count.lol
Created Sep 21, 2011
Counting in LOLCODE
View count.lol
HAI
BTW Execute at http://asgaard.co.uk/misc/loljs/
BTW This program conts!
IM IN YR COOLR UPPIN YR FISH WILE DIFFRINT FISH AN 9
BTW Gonna count my fishes
BOTH SAEM FISH AN 0, O RLY?
YA RLY
VISIBLE "I HAZ NO FISH :("
MEBBE BOTH SAEM FISH AN 1
@trishume
trishume / lol.txt
Created Sep 22, 2011
Shakespeare language (an esoterical programming language) program to print "LOL"
View lol.txt
The Amazing LOL Program.
Romeo, a young man with a remarkable humor.
Juliet, the vowel of the word.
Hamlet, who makes the closing remark.
Act I: Hamlet's flattery.
Scene I: The insult and flattery of Romeo.
@trishume
trishume / errors.txt
Created Oct 20, 2011
errors from turing compile
View errors.txt
------ Build started: Project: GIF, Configuration: Release Win32 ------
dev2gif.c
..\src\libungif\dev2gif.c(105): warning C4101: 'k' : unreferenced local variable
..\src\libungif\dev2gif.c(105): warning C4101: 'j' : unreferenced local variable
..\src\libungif\dev2gif.c(419): warning C4101: 'i' : unreferenced local variable
..\src\libungif\dev2gif.c(418): warning C4101: 'ScreenByte' : unreferenced local variable
..\src\libungif\dev2gif.c(420): warning C4101: 'Bit' : unreferenced local variable
..\src\libungif\dev2gif.c(419): warning C4101: 'k' : unreferenced local variable
..\src\libungif\dev2gif.c(420): warning C4101: 'BufferOffset' : unreferenced local variable
..\src\libungif\dev2gif.c(419): warning C4101: 'j' : unreferenced local variable
@trishume
trishume / cos.rb
Created Jun 8, 2012
My Hand-Made ruby cosine function
View cos.rb
def cos(num,its=1000)
def factorial(num)
return 1 if num == 0
num.downto(1).inject(:*)
end
sum = 0.0
sign = 1
its.times do |i|
exp = i*2
sum += sign * num**exp / factorial(exp)
@trishume
trishume / .slate
Created Oct 5, 2012
My Slate config, requires my window hint icon patch.
View .slate
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout dvorak
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
@trishume
trishume / .slate
Created Nov 20, 2012
My Slate config
View .slate
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout dvorak
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
@trishume
trishume / private.xml
Created Nov 23, 2012
My keyremap4macbook private.xml
View private.xml
<?xml version="1.0"?>
<root>
<item>
<name>Remap Right Control to Hyper</name>
<appendix>OS X doesn't have a Hyper. This maps right control to Control + Shift + Option + Command.</appendix>
<identifier>space_cadet.left_control_to_hyper</identifier>
<autogen>
--KeyToKey--