Skip to content

Instantly share code, notes, and snippets.

@agentultra
agentultra / pascal.lisp
Created April 30, 2012 20:09
A function to calculate n rows of Pascal's Triangle
(defun triangle (num)
"Generate num rows of Pascal's Triangle"
(labels ((next-row (row last-num)
(cond ((null row) '(1))
(t (cons (+ last-num (car row))
(next-row (cdr row) (car row))))))
(triangle-b (num prev-row)
(cond ((= num 0) '())
(t (cons prev-row
(triangle-b (1- num)
@agentultra
agentultra / caruso.elisp
Created August 16, 2012 19:39
the caruso function
;; just copypasta to your *scratch* buffer and C-j
;; or add it to your emacs init file for awesomeness
(defun caruso (setup finisher)
(interactive "sSetup: \nsFinisher: ")
(insert (concat "(•_•) " setup "...\n"))
(insert "( •_•)>⌐■-■\n")
(insert (concat "(⌐■_■) ..." finisher "\n"))
(insert "YYYeeeeaaaah!!!!\n"))
@agentultra
agentultra / binary_tree.py
Last active August 29, 2015 14:01
binary tree implementation without class
from collections import deque
def node(value=None):
return {'value': value, 'left': None, 'right': None}
def insert(tree, key):
"""
Insert 'key' into binary tree.
@agentultra
agentultra / keybase.md
Created September 23, 2014 17:20
keybase.md

Keybase proof

I hereby claim:

  • I am agentultra on github.
  • I am agentultra (https://keybase.io/agentultra) on keybase.
  • I have a public key whose fingerprint is 292B 5A09 5E88 62B9 130B 600B 6FC2 7470 9AFB 231B

To claim this, I am signing this object:

@agentultra
agentultra / tags.hy
Created May 6, 2015 16:30
borked up calling conventions
<{'color': 'red'}
/body><True
/body>⏎
@agentultra
agentultra / setup.sh
Created September 8, 2015 15:34
minimal devstack with nova and neutron
git clone https://git.openstack.org/openstack-dev/devstack
cd devstack
cat << EOF > local.conf
[[local|localrc]]
DEST=/opt/stack
DATA_DIR=$DEST/data
SCREEN_LOGDIR=$DATA_DIR/logs/
LOGFILE=/$DATA_DIR/logs/devstacklog.txt
VERBOSE=True
USE_SCREEN=True
@agentultra
agentultra / sloccount.fish
Last active December 16, 2015 16:34
get a rough line count of a source tree
function count_sloc
find . -name $argv | xargs cat | wc -l
end
import sys
from collections import namedtuple
RightRectPrism = namedtuple('RightRectPrism', ('l', 'w', 'h'))
def parse_prism(s):
return RightRectPrism(*map(int, s.strip().split('x')))
import sys
def main(args=()):
x, y = 0, 0
total_presents = 1
visited = {(0, 0),}
with open('3-1.txt') as f:
directions = f.read(256)
while directions:
git clone https://git.openstack.org/openstack-dev/devstack
cd devstack
cat << EOF > local.conf
[[local|localrc]]
DEST=/opt/stack
DATA_DIR=/opt/stack/data
SCREEN_LOGDIR=/opt/stack/data/logs/
LOGFILE=/opt/stack/data/logs/devstacklog.txt
VERBOSE=True
USE_SCREEN=True