Skip to content

Instantly share code, notes, and snippets.

View enachb's full-sized avatar

Erich Nachbar enachb

  • Stuffy Lab
  • San Francisco
View GitHub Profile
import sys,json,fileinput
# if obj["pageId"] == "AmericanIdol":
for line in fileinput.input():
obj = json.loads(line)
if obj["utc"] > 1359878460000 and obj["utc"] < 1359964740000 and obj["pageId"] == "ironman":
print "%s %s" % (obj["pageId"], obj["utc"])
import sys,json,fileinput
for line in fileinput.input():
try:
obj = json.loads(line)
postId = obj["postId"]
if len(postId) < 3:
print "%s" % (obj["id"])
except:
print "error line: " + line
@enachb
enachb / gist:5687173
Created May 31, 2013 19:03
insert json records into RethinkDB
import sys,json,fileinput
import rethinkdb as r
#python rdbFill.py /data/exports3/rawProd/fbComment/*
r.connect('dcd3', 28015).repl()
t = r.db('test').table('oink')
i = 0
lines = []
@enachb
enachb / TagManager.java
Created October 22, 2013 23:13
Cassandra tag implementation with substring matching
import com.datastax.driver.core.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* CREATE TABLE tag (id uuid, foreignId uuid ,name text, lowerName text,PRIMARY KEY (id) );
*
* create index TagNameIdx on tag(name);
@enachb
enachb / gist:8422734
Created January 14, 2014 18:00
assembly exclude (not working)
<assembly>
<id>deps</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
@enachb
enachb / CMB connect for boto
Created January 21, 2014 23:49
shortcut to connect to a non-AWS SQS install
from boto.sqs import regioninfo
import logging
from boto.sqs.jsonmessage import JSONMessage
# useful for debugging boto connect
#logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
logger = logging.getLogger(__name__)
import boto
import cmb
# erich on velum.io CMB
#export AWS_ACCESS_KEY=UZXEHK0D44TQRY4SI52E
#export AWS_SECRET_ACCESS_KEY=1JfVhGZhvPB2Hw18cHsmaQtZbMXCQOzMWXy1H2q2
conn = cmb.cmb_cxn('UZXEHK0D44TQRY4SI52E', '1JfVhGZhvPB2Hw18cHsmaQtZbMXCQOzMWXy1H2q2', 'cmb' ,'velum.io')
@enachb
enachb / gist:9611133
Created March 18, 2014 00:14
usergrid sample code
//login with client ID & secret but does
val client = new Client(Config.OrgName, Config.AppName)
client.setApiUrl(Config.UserGridUrl)
client.setApplicationId(Config.AppId)
val resp = client.authorizeAppClient(Config.UserGridClientId, Config.UserGridClientSecret)
if(resp.getError != null){
error("Login status: " + resp)
throw new LoginException(resp.getError)
// Compute factor for amps calculation
const float factor = 5.0 / 1023.0 / 5.0 * 600.0
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop()
#!/bin/bash
OUT_DIR=/mnt/scans
TMP_DIR=`mktemp -d`
FILE_NAME=scan_`date +%Y-%m-%d-%H%M%S`
LANGUAGE="eng" # the tesseract language - ensure you installed it
echo 'scanning...'
scanimage --resolution 300 \
--batch="$TMP_DIR/scan_%03d.pnm" \