Skip to content

Instantly share code, notes, and snippets.

View trishume's full-sized avatar

Tristan Hume trishume

View GitHub Profile
@trishume
trishume / collatz.rb
Created July 6, 2011 22:26
Collatz conjecture chains in ruby
# 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 July 18, 2011 23:27
Graphviz collatz.
# 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
@trishume
trishume / print-x.subleq
Created August 27, 2011 13:05
Subleq VM
6 7 3
7 -1 9
2 122 0
8 35 -7
@trishume
trishume / count.lol
Created September 21, 2011 20:38
Counting in LOLCODE
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 September 22, 2011 00:29
Shakespeare language (an esoterical programming language) program to print "LOL"
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 October 20, 2011 01:10
errors from turing compile
------ 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 June 8, 2012 01:33
My Hand-Made ruby cosine function
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 October 5, 2012 19:03
My Slate config, requires my window hint icon patch.
# 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 November 20, 2012 22:21
My Slate config
# 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 November 23, 2012 13:16
My keyremap4macbook 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--