Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

Willow Chargin wchargin

View GitHub Profile
@wchargin
wchargin / labormarket.tex
Created April 11, 2016 13:04
plot of the U.S. labor market composition
\documentclass[margin=24pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={U.S.\@ Labor Market Composition},
@wchargin
wchargin / Scan.java
Created April 23, 2016 18:28
two methods of counting things
import java.util.*;
import java.io.*;
class Scan {
public static void main(String[] args) throws Exception {
final String filename = args[0];
int count = 0;
try (final Scanner sc = new Scanner(new File(filename))) {
sc.useDelimiter("\\W+");
while (sc.hasNext())
@wchargin
wchargin / counts
Created April 30, 2016 02:32
word counts from an aggregate of 20 different Project Gutenberg texts
121829
27 _
1 ________________________
1 ___________________________
1 _______________________________
34 0
14 00
55 000
1 0002407915892646028490894922299966167437
1 0004654137109163009678595156394733219093
@wchargin
wchargin / Exceptional.java
Created May 4, 2016 02:01
perfect branch coverage, imperfect line coverage, no dead code
import java.util.OptionalInt;
class Exceptional {
static void ensureEven(int x) {
if (x % 2 != 0) {
throw new OddException();
}
}
@wchargin
wchargin / ColorGo.hs
Last active May 16, 2016 15:45
the game of Go, with colors: gnugo | runhaskell ColorGo
-- | A Unix pipeline operation to color the output of GNU Go
-- so that the Xs and Os stand out more prominently against the board.
-- Run with no arguments: e.g., @gnugo | runhaskell ColorGo.hs@.
module Main where
import Data.Maybe (fromMaybe)
import Data.Char (isSpace, isDigit)
import System.Exit (exitSuccess)
import System.IO
map zx goBack
map zc goForward
map ζχ goBack
map ζψ goForward
map gl nextTab
map gh previousTab
map γλ nextTab
map γη previousTab
map zl nextTab
map zh previousTab
@wchargin
wchargin / segfault.sgf
Created May 23, 2016 02:57
GNU Go 3.8-7 segfault repro
(;GM[1]FF[4]AP[qGo:2.0.0]ST[1]
SZ[19]HA[0]KM[0]PW[Computer]PB[Human]
;B[oe];W[dd];B[dp];W[qq];B[jp];W[cn];B[mj];W[ck];B[gf];W[oc]
;B[pe];W[qd];B[re];W[rd];B[se];W[fq];B[fp];W[gp];B[ep];W[hq]
;B[hp];W[go];B[gn];W[fo];B[eo];W[lq];B[iq];W[hr];B[fr];W[eq]
;B[dq];W[er];B[es];W[dr];B[cr];W[ds];B[cs];W[gq];B[ir];W[lc]
;B[fm];W[lo];B[fs];W[ho];B[io];W[hn];B[hm];W[in];B[jn];W[im]
;B[il];W[ip];B[jo];W[mn];B[gs];W[jq];B[is];W[kq];B[hs];W[hp]
@wchargin
wchargin / app.yaml
Last active July 16, 2016 23:23
a minimal gae app
version: 1
runtime: python27
api_version: 1
threadsafe: true
application: <YOUR_APP_ID_HERE>
handlers:
- url: /.*
script: main.application
"""Draw lines through a unit square. Draw the central ones.
Usage: run it, then convert all the /tmp/%04d.png files to a movie or whatever.
"""
import bisect
import collections
import math
import random
@wchargin
wchargin / no_problem.sh
Created August 28, 2016 20:55
#unix-one-liners: fix lint and tests throughout history
(
(hlint **/*.hs >/dev/null 2>/dev/null || (echo "Lint problems"; false)) &&
(stack test >/dev/null 2>/dev/null || (echo "Test failures"; false)) &&
GIT_EDITOR=true git rebase --continue
) || (
$EDITOR $(hlint **/*.hs
| grep -F '.hs'
| sed 's/:.*//'
| uniq) &&
stack test &&