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 / 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 / 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"
@zwass
zwass / worker.py
Created April 21, 2013 03:40
Really old work on aggregating RSS feeds into a Twitter account. Style is lacking, could really use some lovin'.
import os
import time
import json
from urllib import urlencode
import tweepy
import feedparser
import pymongo
import requests
from BeautifulSoup import BeautifulSoup
/*
* Copyright (c) 2004-2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this