Skip to content

Instantly share code, notes, and snippets.

View j2labs's full-sized avatar

The Ghost Of J2 Labs j2labs

View GitHub Profile
@j2labs
j2labs / gist:1088546
Created July 18, 2011 04:31
Concurrent pymongo inserts with Eventlet
#!/usr/bin/env python
###
### Concurrent pymongo inserts
###
import eventlet
pymongo = eventlet.import_patched('pymongo')
### Setup database connection
@j2labs
j2labs / gist:2146589
Created March 21, 2012 12:24
Basic Python Metaclasses with Configurable Options
#!/usr/bin/env python
import inspect
import copy
###
### Options Classes
###
class DocOptions(object):
@j2labs
j2labs / gist:1046726
Created June 25, 2011 18:15
Stream API example in Python using PyCurl
#!/usr/bin/env python
# Example for reading from the Twitter streaming API using pycurl
#
# PyCurl is not installed by default so install it like this:
#
# pip install pycurl
#
# The streaming api methods are documented here:
@j2labs
j2labs / gist:f09b6a2d0cf41b15d797
Last active October 9, 2017 17:25
Swift sudoku solver
#!/usr/bin/env xcrun swift
class Board {
let b = -1 // a blank, written as b so the board below looks nice
let hborder = "-------------\n"
let vborder = "|"
let width = 9
let height = 9
var board: [[Int]]
#!/usr/bin/env python
### Requires latest boto (cuz I checked in code to boto a moment ago)
import uuid
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import Question, QuestionForm, QuestionContent
from boto.mturk.question import AnswerSpecification, FreeTextAnswer
from boto.mturk.question import Overview
#from boto.mturk.qualification import Qualifications # these exist!
@j2labs
j2labs / gist:7875008
Last active December 30, 2015 19:38
Thinking out loud on what Tobin might be like.
from tobin.querysets import RedisQuerySet
from schematics.models import Model
from schematics.types import StringType, IntType
class SomeModel(Model):
s = StringType()
i = IntType()
@j2labs
j2labs / gist:7848611
Last active December 30, 2015 15:29
A Brubeck demo showing how Jinja2 support works with the new plugin system.
#!/usr/bin/env python
from brubeck.servers.web import WebServer
from brubeck.handlers.web import WebMessageHandler
from brubeck.connections import WSGIConnection
from brubeck_templates.plugins import Jinja2Plugin
import sys
@j2labs
j2labs / gist:7132681
Created October 24, 2013 07:19
Hack And Tell wrapup 26
# Subject: Round 26, Wait, really?
Tonight was great. The hacks were awesome. The crowd was awesome.
But I wanna talk about something serious for a moment.
There has been a surge of interest in Hack And Tell and we're not great about handling it yet. The reality is that this community has turned into something bigger and better than we expected and we're learning how to organize it as we go. It was initially a group of 20 of us just hanging out at meetup's offices, where gWoz (Andrew, or GNU Woz which is also Andrew) worked at the time. I'd present twice, he'd present twice, and maybe a couple other folks would show something.
Andrew and I both grew up in punk rock communities, where people did whatever they wanted and everyone just accepted it. If you wanted anyone to care about what you were doing, you had to earn their eyes and their ears by doing something cool. Not too different from how our presenter list is made. We have ten slots to fill so we just pick the stuff we like best. If it's nea
@j2labs
j2labs / gist:7074542
Created October 20, 2013 20:00
Hack And Tell wrap up 25
# Subject: Round 25, by Tom Clancy (RIP)
So, uh... I guess this email would've been easier to write last month. Especially since Mr. Clancy was alive then.
Initially, the name was to joke around with how dramatic things sound if you say they're by Tom Clancy. "The Snow Was Falling, By Tom Clancy", and now you're thinking about snow landing on top of a crashed fighter jet on Christmas.
I guess we'd have a fallen drone and some sad operator. "This is where I lost J2D2 2. The first one was in Dumbo, on a dark and stormy night."
What am I even talking about?
@j2labs
j2labs / gist:5892515
Created June 29, 2013 20:21
Example of using Python's csv module with DictReader
#!/usr/bin/env python
import csv
import json
# Get graffiti_locations.csv from:
# https://nycopendata.socrata.com/Social-Services/Graffiti-Locations/2j99-6h29?
filename = 'graffiti_locations.csv'