Skip to content

Instantly share code, notes, and snippets.

@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 / 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"))
import sys
from collections import namedtuple
RightRectPrism = namedtuple('RightRectPrism', ('l', 'w', 'h'))
def parse_prism(s):
return RightRectPrism(*map(int, s.strip().split('x')))
@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
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]]
HOST_IP=192.168.33.33
PUBLIC_NETWORK_CIDR=10.0.1.0/24
DEST=/opt/stack
DATA_DIR=/opt/stack/data
SCREEN_LOGDIR=/opt/stack/data/logs/
LOGFILE=/opt/stack/data/logs/devstacklog.txt
@agentultra
agentultra / agealyzer.clj
Last active February 25, 2016 20:53 — forked from clee/agealyzer.clj
agealyzer: given a root directory, spits out histogram of ages of files
(ns clee.agealyzer)
(require '[clojure.java.io :as io])
(defn date [x] (java.util.Date. x))
(defn is-file? [f] (.isFile f))
(defn last-modified [f] (.lastModified f))
(defn get-year [x] (.getYear x))
(defn process-dir