This file contains 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
+++ Statistics Dump +++ (1393879884) | |
++ Incoming Requests ++ | |
7122195 QUERY | |
1 IQUERY | |
4 STATUS | |
1 NOTIFY | |
++ Incoming Queries ++ | |
5189989 A | |
81035 NS | |
1754 CNAME |
This file contains 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 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 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 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 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 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 * |
This file contains 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
# parallelize a function n ways, automatically spliting a big list | |
# of arguments into n roughly equal sized groups | |
import math | |
from multiprocessing import Pool | |
def split(iterable, n): | |
"""Splits an iterable up into n roughly equally sized groups.""" | |
groupsize = int(math.floor(len(iterable) / float(n))) | |
remainder = len(iterable) % n |
This file contains 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
# twitter oauth example using urllib | |
# | |
# Many uses of the twitter api don't require authenticating as other users, | |
# but the documentation centers around it. In this example, we're using the | |
# twitter-provided access key & secret (keys['token']) rather than going | |
# through the handshake. | |
import json | |
import urllib2 |
This file contains 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 -*- | |
"""post stats on amit just because""" | |
import re | |
import urllib2 | |
from lxml import html | |
url = 'http://omlettesoft.com/newjournal.php3?topic=On+the+Waterfront&who=Lord+Omlette' |
OlderNewer