Skip to content

Instantly share code, notes, and snippets.

View tippenein's full-sized avatar

Brady Ouren tippenein

  • Los Angeles, CA
View GitHub Profile
@tippenein
tippenein / sensationalistGen.py
Last active December 12, 2015 08:59
alex jones sensationalist nonsense generator
#!/usr/bin/env python
import random
def makeSentence(part1, part2, part3, n=10):
"""return n random sentences"""
#convert to lists
p1 = part1.split('\n')
p2 = part2.split('\n')
p3 = part3.split('\n')
parse_git_branch () {
git branch 2> /dev/null | grep '*' | sed 's#*\ \(.*\)#(git::\1)#'
}
export PS1="$PS1\$(parse_git_branch) "
(define-syntax while-less
(syntax-rules (do)
[(while-less e1 do e2)
(if (< e1 e2)
#t
e2)]))
;; this is obviously wrong, but I'm not sure how to eval e2 until (< e1 e2)
@tippenein
tippenein / gist:5113504
Created March 8, 2013 01:24
linked list questions
//return the nth to last item in a linked list
public static void nthToLast(LinkedListNode n, Integer i) {
LinkedListNode p1 = n;
LinkedListNode p2 = n;
// just iterate p2 for i steps and wait for it to hit null
while (i != 0) {
p2 = p2.next;
i--;
}
while (p2 != null) {
// given a sorted array, create a BST
public static void add(int[] arr, int start, int end) {
int mid = (start + end) / 2;
TreeNode n = new TreeNode(arr[mid]);
n.left = add(arr, start, mid-1);
n.right = add(arr, mid+1, end);
return n
}
public static TreeNode makeBST(int[] arr, int start, int end) {
;; A small portion of the MUPL assignment
#lang racket
(provide (all-defined-out)) ;; so we can put tests in a second file
;; definition of structures for MUPL programs - Do NOT change
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo")
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17)
(struct add (e1 e2) #:transparent) ;; add two expressions
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4
@tippenein
tippenein / gist:5328240
Last active December 15, 2015 21:49
pull podcasts from jet set planet page.
#!/usr/bin/ruby
#file: get_jetset.rb
require 'net/http'
require 'open-uri'
path = '/home/tippenein/podcasts/jet-set-planet/'
uri = URI('http://kfai.org/jet-set-planet')
@tippenein
tippenein / gist:5347634
Created April 9, 2013 17:27
word count for multiple files
# have a folder full of txt files to word count
cat `find . -type f` | tr -cs [:alpha:] [n*] | sort | uniq -c | sort -nr > results.txt
@tippenein
tippenein / gist:5834109
Created June 21, 2013 20:31
md to html
#!/usr/bin/env python
import markdown
import sys
import codecs
if __name__ == '__main__':
in_file = codecs.open(sys.argv[1], mode="r", encoding="utf-8")
text = input_file.read()
html = markdown.markdown(text)
@tippenein
tippenein / gist:5952751
Last active December 19, 2015 12:09
slightly ugly, but useful bloomfilter
from random import Random
class BloomFilter:
# http://en.wikipedia.org/wiki/Bloom_filter
def __init__(self, num_bytes, num_probes, iterable=set()):
self.array = bytearray(num_bytes)
self.num_probes = num_probes
self.num_bins = num_bytes * 8
self.update(iterable)