Skip to content

Instantly share code, notes, and snippets.

View FrancescaK's full-sized avatar

Francesca Krihely FrancescaK

View GitHub Profile
@FrancescaK
FrancescaK / erh twitter stream
Created December 16, 2011 16:18
Twitter Stream
+import sys
+import pymongo
+import json
+
+import jinja2
+import flask
+
+
+env = jinja2.Environment(loader=jinja2.FileSystemLoader("templates"))
+app = flask.Flask(__name__)
@FrancescaK
FrancescaK / $match
Created December 18, 2011 19:47
Pipeline operations
// simple matching
var m1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $match : { author : "dave" } }
]});
include MongodbLogger:: Base
@FrancescaK
FrancescaK / Find requests
Created December 27, 2011 22:26
get MongoDB from within the Rails Console
collection.find({:runtime => {'$gt' => 1000}})
@FrancescaK
FrancescaK / mongoboot camp
Created January 23, 2012 21:10
MongoDB Lab Boot Camp 1
Product collection
{
_id : ObjectId
name : "myproductname"
attributes
{
color :
part_count
age :
-bash: run: command not found
$:checkin fk$ run (/"checkin.js")
-bash: syntax error near unexpected token `/"checkin.js"'
$:checkin fk$ load (/"checkin.js")
-bash: syntax error near unexpected token `/"checkin.js"'
$ meteor
[[[[[ ~/Desktop/checkin ]]]]]
Running on: http://localhost:3000/
Errors prevented startup:
Exception while bundling application:
Error: Couldn't parse .. um .. some HTML file, on some line. sorry
at Object._scanChunk (/usr/local/meteor/packages/templating/html_scanner.js:83:13)
at Object.scan (/usr/local/meteor/packages/templating/html_scanner.js:7:31)
at /usr/local/meteor/packages/templating/package.js:46:32
@FrancescaK
FrancescaK / gist:3298609
Created August 8, 2012 20:44
worker role
def worker():
while True:
time.sleep(1)
while True:
msg = mongo_db.sendq.find_and_modify(remove=True)
if (msg == None): break
sys.stderr.write("send %s %s\n" % (msg['To'], msg['Body']))
message = twilio_client.sms.messages.create(to=msg['To'],
from_=twilio_fromnum,
body=msg['Body'])
@FrancescaK
FrancescaK / Motor-demo
Created September 3, 2012 13:06
Motor-demo
import tornado.web, tornado.ioloop
import motor
class NewMessageHandler(tornado.web.RequestHandler):
def get(self):
"""Show a 'compose message' form"""
self.write('''
<form method="post">
<input type="text" name="msg">
<input type="submit">
@FrancescaK
FrancescaK / gist11122222
Created October 1, 2012 14:18
mikefgist
Benchmark: timing 10 iterations of datetime, raw, tiny...
datetime: 428 wallclock secs (426.24 usr + 1.22 sys = 427.46 CPU) @ 0.02/s (n=10)
raw: 44 wallclock secs (42.58 usr + 0.52 sys = 43.10 CPU) @ 0.23/s (n=10)
tiny: 66 wallclock secs (64.68 usr + 0.99 sys = 65.67 CPU) @ 0.15/s (n=10)