Skip to content

Instantly share code, notes, and snippets.

View davidcrawford's full-sized avatar

David Crawford davidcrawford

View GitHub Profile
Process: Electron Helper [4391]
Path: /Users/USER/*/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper
Identifier: com.github.electron.helper
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Terminal [808]
User ID: 501
Date/Time: 2015-10-22 23:12:54.780 -0700
@davidcrawford
davidcrawford / crawler.go
Created February 22, 2015 20:22
Golang Tour of Go: Web Crawler
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
@davidcrawford
davidcrawford / unzip.py
Created October 1, 2013 06:16
Python UnzipStream — A file-like wrapper around a gzipped stream that uncompresses as it reads.
import os
import zlib
from StringIO import StringIO
ESTIMATED_COMPRESSION_FACTOR = 2
class UnzipStream(object):
'''
SELECT * FROM purchases ORDER BY created_at DESC;
@davidcrawford
davidcrawford / 01-signed_up_users.sql
Last active December 14, 2015 15:09
Rolling cohort retention SQL
SELECT count(1) as signed_up_users
FROM users
WHERE users.sign_up_time >= date_trunc('day', now() - interval '2 days')
AND users.sign_up_time < date_trunc('day', now() - interval '1 day');
@davidcrawford
davidcrawford / auditor-bookmarklet.html
Created April 24, 2012 20:13
Auditor bookmarklet
<html>
<head>
<style>
body {
font-family: 'Helvetica', sans-serif;
width: 950px;
margin: auto;
}
</style>
</head>
@davidcrawford
davidcrawford / gist:1180363
Created August 30, 2011 07:05
Base62 encoder/decoder
var Base62 = (function() {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
var base = chars.length;
var decoder = chars.split('').reduce(function(memo, c, i) {
memo[c] = i;
return memo;
}, {});
var encode = function(value) {