This file contains 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 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 |
This file contains 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
__author__ = 'k0emt' | |
class Greeter: | |
def __init__(self): | |
self.message = 'Hello world' | |
# print self.message |
This file contains 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
__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: |
This file contains 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 sys | |
import pika | |
# prerequisites are that you have RabbitMQ installed | |
# create a "darkmatter" named VirtualHost (VHOST) | |
# rabbitmqctl.bat add_vhost darkmatter | |
# create a user APP_USER with associated APP_PASS word | |
# rabbitmqctl add_user darkmatteradmin <password> | |
# give the APP_USER the necessary permissions | |
# rabbitmqctl set_permissions -p darkmatter darkmatteradmin ".*" ".*" ".*" |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
<cities> | |
<state> | |
<name>Alabama</name> | |
<city>Abbeville</city> | |
<number>1</number> | |
</state> | |
<state> | |
<name>Alabama</name> | |
<city>Adamsville</city> | |
<number>1</number> |
This file contains 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/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] |
This file contains 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 bottle | |
@bottle.route('/') | |
def home_page(): | |
return "Hello World\n" | |
@bottle.route('/testpage') | |
def test_page(): | |
return "this is a test page" |
This file contains 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
mkdir \data\rs1 \data\rs2 \data\rs3 | |
start mongod --replSet m101 --logpath "1.log" --dbpath \data\rs1 --port 27017 --smallfiles --oplogSize 64 | |
start mongod --replSet m101 --logpath "2.log" --dbpath \data\rs2 --port 27018 --smallfiles --oplogSize 64 | |
start mongod --replSet m101 --logpath "3.log" --dbpath \data\rs3 --port 27019 --smallfiles --oplogSize 64 |
OlderNewer