Skip to content

Instantly share code, notes, and snippets.

View zwass's full-sized avatar
🌐
Hiring engineers #remote worldwide: fleetdm.com/jobs

Zach Wasserman zwass

🌐
Hiring engineers #remote worldwide: fleetdm.com/jobs
View GitHub Profile
@zwass
zwass / treetest.c
Created April 28, 2011 08:13
Exploring Caches and Spatial Locality with C
#define DEFAULTTREEHEIGHT 20
#define DEFAULTITERATIONS 1000
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
typedef struct{
void* right;
@zwass
zwass / pytalk.py
Created September 15, 2011 03:06
Code from PennApps CherryPy Talk
import cherrypy
import sqlite3
import json
def wrap_html(function):
def new_function(*args, **kwargs):
return """\
<html><body>
""" + function(*args, **kwargs) + """
</body></html>
@zwass
zwass / gist:3732941
Created September 16, 2012 15:55
Haskell Fibonacci Prime Finder
squareRoot :: Integer -> Integer
squareRoot = floor . sqrt . (fromIntegral :: Integer -> Double)
isPrime :: Integer -> Bool
isPrime 1 = False
isPrime x = testDown x (squareRoot x) where
testDown a 1 = True
testDown a n
| a `mod` n == 0 = False
| otherwise = testDown a (n-1)
@zwass
zwass / personal.el
Created September 25, 2012 23:12
emacs config file as of 2012-09-25
;; Here are some examples of how to override the defaults for the
;; various prelude-emacs settings. To *append* to any of the
;; configurations attached to prelude-*-hooks, you can attach a
;; function to the appropriate hook:
;; disable whitespace-mode and whitespace-cleanup
(add-hook 'prelude-prog-mode-hook
(lambda ()
(prelude-turn-off-whitespace)
(remove-hook 'before-save-hook 'whitespace-cleanup)) t)
@zwass
zwass / DefaultKeyBinding.dict
Created October 2, 2012 22:37
Mac Keybindings
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally
@zwass
zwass / gist:4163491
Created November 28, 2012 19:28
Haskell config
;;Haskell setup
(defun haskell-custom-setup ()
(progn
(define-key haskell-mode-map (kbd "C-x C-s") 'haskell-mode-save-buffer)
(setq haskell-indent-offset 2)
(ghc-init)
(flymake-mode 1)
(defun haskell-mode-stylish-buffer-custom ()
@zwass
zwass / euler4.py
Created December 11, 2012 22:48
One-liner brute force solution to Project Euler problem 4 (http://projecteuler.net/problem=4)
print sorted([int(c) for c in [str(x * y)
for x in range(999, 99, -1)
for y in range(999, x - 1, -1)]
if all([c[i] == c[-1 - i]
for i in range(len(c) / 2)])])[-1]
@zwass
zwass / gist:4991471
Created February 20, 2013 00:06
Watch out, Chrome.
҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈⃦⃧⃜⃧⃛⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧⃤⃧ ⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧⃧ه҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈҈
@zwass
zwass / scrape_ama_reviews.py
Created February 26, 2013 19:39
Basic scraping of Amazon reviews
import requests
from bs4 import BeautifulSoup, NavigableString
def get_review_text(block):
"""Get just the text of a review from it's DIV"""
strings = []
for possible_text in block.children:
if isinstance(possible_text, NavigableString):
stripped_text = possible_text.strip()
@zwass
zwass / break_hash.go
Created April 1, 2013 22:52
For cracking the hash in http://xkcd.com/1193/
package main
import (
"fmt"
"crypto/skein" //https://github.com/wernerd/Skein3Fish
"encoding/hex"
"os"
"bufio"
"io"
"strings"