Skip to content

Instantly share code, notes, and snippets.

View bcoe's full-sized avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
var endtable = require('endtable');
var engine = new endtable.Engine({
database: 'people_example',
username: 'xxxxxx',
password: 'xxxxxx',
host: 'xxxxxx.couchone.com',
});
@bcoe
bcoe / pojo.js
Created November 23, 2010 05:10
var Person = endtable.Object.extend(
{
sayName: function() {
sys.puts('Hello, my name is ' + this.name + '!');
}
},
{
engine: engine,
type: 'person'
}
var ben = new Person({
name: 'Benjamin Coe',
age: 27,
sex: 'male',
interests: ['climbing']
})
ben.interests.push('programming')
@bcoe
bcoe / load.js
Created November 23, 2010 05:15
new Person().load({
keys: 'age',
startkey: 28,
endkey: 50
}, function(error, people) {
for (var i = 0; i < people.length; i++) {
people[i].sayName();
}
})
@bcoe
bcoe / batch_insert.py
Created January 8, 2011 23:15
Performing a batch insertion using mongate.
from mongate.connection import Connection
connection = Connection(
'example.com',
27080,
https=True,
auth=True,
username='auth_username',
password='auth_password'
)
@bcoe
bcoe / nginx.conf
Created January 8, 2011 23:36
Sample configuration for mongate.
upstream mongo_rest {
server 127.0.0.1:xxxx;
server 127.0.0.1:xxxx;
server 127.0.0.1:xxxx;
}
server {
listen xxxxx;
ssl on;
server_name example.com;
import time
def retry(f):
MAXIMUM_RETRIES = 24
SLEEP_TIME = 5
def wrapper(*args):
for tries in range(0, MAXIMUM_RETRIES):
@bcoe
bcoe / email_uuid.py
Created May 10, 2011 13:24
Gmail Message ID
def _get_email_uuid(self, message_id):
try:
typ, data = self.connection.fetch(message_id, '(X-GM-MSGID)')
# 1 (X-GM-MSGID 1363378113778197832)
mid_regex = re.compile(r'^.* \(.* ([0-9]*)\)$')
match = mid_regex.match(data[0])
if match:
raw_hex = hex( int( match.group(1) ) )
# 0x12ebb12bc64aa548L
@bcoe
bcoe / pytoad1.py
Created May 19, 2011 22:33
Example of Pytoad
from pytoad import pytoad_decorator
@pytoad_decorator()
def foobar():
raise Exception('banana')
@bcoe
bcoe / pytoad2.py
Created May 19, 2011 22:34
Example of Pytoad
@pytoad_decorator(monitored_exceptions=[StandardError, LookupError])
def foo():
raise StandardError('banana')