View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View startdevmongodb.bat
mongod --smallfiles --oplogSize 16 --nojournal
View Enron_to_Mongo.py
import os
import datetime
from pymongo import MongoClient
__author__ = 'k0emt'
MAIL_DIR_PATH = '/Users/k0emt/Projects/enron/enron_mail_20110402/maildir'
PREFIX_TRIM_AMOUNT = len(MAIL_DIR_PATH) + 1
MAX_USER_RUN_LIMIT = 50
MAX_USER_EMAILS_PER_FOLDER_FILE_LIMIT = 2
counter = 1
View Arguments.py
__author__ = 'k0emt'
class Greeter:
def __init__(self):
self.message = 'Hello world!'
# print self.message
class GreeterOverloaded:
def __init__(self, greeting=None):
if greeting is None:
View mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: "/var/lib/mongodb"
journal:
enabled: true
View pymongo_work_with_document.py
from pymongo import MongoClient
import pymongo
import sys
# establish a connection to the database
connection = MongoClient("mongodb://localhost", safe=True)
# get a handle to the school database
db = connection.school
scores = db.scores
View updating_docs.py
from pymongo import MongoClient
import sys
# code example to show updating individual records in a loop
# initialize the database with:
# mongoimport -d school -c scores --type json grades.js
# verify no records with "added"
# db.scores.find({"added":{$exists:true}}) // returns nothing
View cities.xml
<cities>
<state>
<name>Alabama</name>
<city>Abbeville</city>
<number>1</number>
</state>
<state>
<name>Alabama</name>
<city>Adamsville</city>
<number>1</number>
View mongoGetKeys.py
#!/usr/local/bin/python
import sys
from pymongo import MongoClient
if len(sys.argv) < 3:
print 'usage is: ' + sys.argv[0] + ' databaseName collectionName'
sys.exit()
dbName = sys.argv[1]
View hello_world_bottle.py
import bottle
@bottle.route('/')
def home_page():
return "Hello World\n"
@bottle.route('/testpage')
def test_page():
return "this is a test page"