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
$ curl http://localhost:6767/todo/ | python -m json.tool | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 241 100 241 0 0 54463 0 --:--:-- --:--:-- --:--:-- 117k | |
[ | |
{ | |
"_cls": "Todo", | |
"_id": "84b38d14-4a11-439a-8e3f-bbe5a499714b", | |
"_types": [ | |
"Todo" |
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 | |
from brubeck.request_handling import Brubeck, AutoAPIBase, WebMessageHandler | |
from brubeck.queryset import DictQueryset | |
from brubeck.templating import Jinja2Rendering, load_jinja2_env | |
from dictshield.document import Document | |
from dictshield.fields import StringField, IntField, BooleanField |
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
$ ./embedded_documents.py | |
Traceback (most recent call last): | |
File "./embedded_documents.py", line 130, in <module> | |
class Order(EmbeddedDocument): | |
File "./embedded_documents.py", line 133, in Order | |
line_items = ListField(EmbeddedDocumentField(Product)) | |
File "/Users/jd/Projects/dictshield/dictshield/fields/compound.py", line 194, in __init__ | |
'WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORD') | |
dictshield.base.ShieldException: Invalid embedded document class provided to an EmbeddedDocumentField - <class '__main__.Product'>:WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORD |
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
>>> import time | |
>>> def time_it(fun): | |
... start = time.time() | |
... fun() | |
... end = time.time() | |
... print 'Time:', end - start | |
... | |
>>> def foo(): | |
... import logging | |
... import multiprocessing |
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
exports.arity_decorator = function(fun) { | |
function wrapped() { | |
if(arguments.length != fun.length) | |
throw new Error("Y U NO USE RIGHT?!") | |
fun.apply(this, arguments) | |
} | |
return wrapped; | |
} | |
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
function arity_decorator(fun) { | |
function wrapped() { | |
if(arguments.length != fun.length) | |
throw new Error("Y U NO USE RIGHT?!") | |
fun.apply(this, arguments); | |
} | |
return wrapped; | |
} | |
function foo(x, y) { |
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
> function foo(x,y) { | |
... args = Array.prototype.join.call(arguments, ","); | |
... console.log('X:' + x + ' Y:' + y + ' Args:' + args) | |
... } | |
> foo(1,2) | |
X:1 Y:2 Args:1,2 | |
> foo(1,2,3,4,5) | |
X:1 Y:2 Args:1,2,3,4,5 |
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 | |
### | |
### Settings | |
### | |
ZMQ_VERSION="zeromq-2.1.9" | |
MONGREL2_VERSION="mongrel2-1.7.5" | |
PREV_DIR=$PWD | |
SRC_DIR=$HOME/src |
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 | |
from greenlet import greenlet | |
def test1(coro): | |
print 'test1: 1' | |
coro_self = greenlet.getcurrent() | |
coro.switch(coro_self) | |
raise Exception('Hey you cant do this!') |
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 | |
### | |
### Concurrent pymongo inserts | |
### | |
import eventlet | |
pymongo = eventlet.import_patched('pymongo') | |
### Setup database connection |