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
/*Prolog Num succ and prev defined in some wierd ass JS */ | |
var num= (function(num) { | |
num = num || 0; | |
var x = num; | |
return { | |
s: function() { | |
x+=1; | |
return x; | |
}, |
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 Data.List | |
data Piece = X | O deriving (Ord, Eq, Show) | |
data Board = Board [(Int, Int, Piece)] deriving(Ord, Eq,Show) | |
winning_combinations = [[(a,0), (a,1), (a,2)] | a <- [0..2] ] ++ [[(0,a), (1,a), (2,a)] | a <- [0..2] ] ++ [[(0,0), (1,1), (2,2)], [(0,2), (1,1), (2,0)]] | |
over2 :: Board -> Bool | |
over2 (Board []) = False | |
over2 (Board x) = is_winner newx winning_combinations |
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 System.Random | |
newtype State s a = State { | |
runState :: s -> (a, s) | |
} | |
returnState :: a -> State s a | |
returnState a = State (\s-> (a, s)) | |
bindState :: State s a -> (a -> State s b) -> State s b |
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
data State s a = State (s -> (a, s)) | |
test :: Int -> State Int () -> State Int () -> State Int Bool | |
test n f g = (f `bindState` (\_ -> g) `bindState` (\_ -> State $ (\s -> ((s > n), s)))) | |
runState (State t) s = t s | |
returnState :: a -> State s a | |
returnState a = State $ (\s -> (a, s)) |
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 python | |
#usage: lines.py filenames seperated by space | |
#my personal way of using it: lines.py `git diff --no-ext-diff --name-only HEAD~1 HEAD | grep .py` | |
import sys | |
TAB_WIDTH = 8 | |
LINE_LENGTH = 79 | |
def count(line): |
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
def restore_cwd(func): | |
""" | |
decorator to restore the current working directory | |
""" | |
def wrapper(*args, **kwargs): | |
cwd = os.getcwd() | |
results = func(*args, **kwargs) | |
os.chdir(cwd) | |
return results |
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 random | |
def roll_dice(): | |
return random.randint(1, 6) | |
def sum_two_dice(): | |
sum_one = roll_dice() | |
sum_two = roll_dice() |
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
class NiceNumber(long): | |
def __new__(cls, *args): | |
x = 0 | |
if long(args[0]) >= 0: | |
sign = 1 | |
else: | |
sign = -1 | |
for i in range(0, len(args)): | |
reverse_i = (len(args) - 1) - i | |
x += (1000 ** i) * abs(long(args[reverse_i])) |
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
# in settings.py | |
USERS: { | |
"alice": { | |
"alice_specific_information" : True | |
}, | |
"bob": { | |
"bob_specific_information": True | |
} | |
} |
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
$ hooked.py --help | |
Usage: hooked.py [options] | |
Options: | |
-h, --help show this help message and exit | |
--git-root=GITROOT the root directory of the git folder to inject hook | |
--clean Clean up after yourself | |
$ # lets make a new repo |
OlderNewer