This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
) | |
func init() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ReadAll(r io.Reader) ([]byte, error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func LoadGzippedJSON(r io.Reader, v interface{}) error { | |
data, err := ioutil.ReadAll(r) | |
if err != nil { | |
return err | |
} | |
// oh wait, we need a Reader again.. | |
raw := bytes.NewBuffer(data) | |
unz, err := gzip.NewReader(raw) | |
if err != nil { | |
return err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func LoadGzippedJSON(r io.Reader, v interface{}) error { | |
raw, err := gzip.NewReader(r) | |
if err != nil { | |
return err | |
} | |
return json.NewDecoder(raw).Decode(&v) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is how we program for some reason | |
ls > files.txt | |
grep "foo" files.txt > grepped.txt | |
wc -l grepped.txt | |
rm files.txt grepped.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# github search for "json.loads(" => 210,000 matches | |
feed = urllib2.urlopen("http://example.com/api.json").read() | |
data = json.loads(feed) | |
# github search for "json.load(" => 58,000 matches | |
data = json.load(urllib2.urlopen("http://example.com/api.json")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: monte-c monte-go monte-rs monte-gccgo | |
monte-go: | |
go build montepi.go && mv montepi monte-go | |
monte-rs: | |
rustc -O -o monte-rs montepi.rs | |
monte-c: | |
gcc -std=c99 -O2 -o monte-c montepi.c -lm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
python -c 'import docopt' | |
if [ $? != 0 ]; then | |
echo "Missing docopt module." | |
echo " pip install docopt" | |
echo "" | |
echo "or for ubuntu/debian users:" | |
echo " apt-get install python-docopt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <sys/stat.h> | |
#include <sys/mman.h> | |
void print_region(char *ptr, size_t len); | |
// mark a few locations in a pointer | |
void mark(char *ptr, size_t len) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Simple synaptics client save/restore.""" | |
import argparse | |
import sys | |
import os.path | |
from collections import OrderedDict | |
from subprocess import * |