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/python | |
""" | |
Tyler Brock for Five Stars - 2011 | |
Write function f in python, that given a list of numbers | |
L returns i, j such that L[i:j] has maximal sum. | |
For example, if L = [1, -2, 3, 4, 5, -1] then f(L) should return (2, 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
from piston.handler import AnonymousBaseHandler | |
from django.http import HttpResponse, HttpResponseBadRequest | |
from django.db.models import Count | |
from decorators import status_response, json_data | |
from exceptions import JSONException | |
from utils import * | |
from userutils import * | |
from authentication.token import * | |
from settings import BASE_URL | |
from django.forms.models import model_to_dict |
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
db.logs.remove() | |
db.logs.insert( | |
{"name":"James Carr", | |
"log" : [ | |
{ | |
"comment" : "", | |
"time" : ISODate("2011-11-01T21:37:44.897Z"), | |
"user" : "Brad ************", | |
"action" : "Call", |
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 sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
/* | |
* | |
* orphanage.js -- Utility to find and remove orphaned documents | |
* 10gen 2012 -- Tyler Brock | |
* | |
* Script Orphan Finder Procedure: | |
* - Set up a connection to each shard | |
* - Turn of the balancer | |
* - For each chunk of data | |
* - Query each shard that is not in config |
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
OS Setup | |
- Install VMs (base OS = Ubuntu 11.04) | |
- 6GB disk is not enough. Probably 20-40GB would be good. Mongo has a lot of compression and cleanup features coming. | |
- Create user to run MongoDB as | |
- Get DNS or Hosts file set up so all nodes in the cluster can talk to each other | |
- Generate ssh-keygen -t rsa | |
- Copy ssh public keys from each node to node01. Then cat all keys to authorized_keys. Then copy that file to each node. Each node will have ssh key trust now. You will also want to ssh from node01 to 02,03,04; from node02 to 01,03,04 etc to test it out. | |
- Create an initial architecture: | |
node01: master (replica set 1) | |
node02: slave (replica set 1) |
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 https://stream.twitter.com/1/statuses/sample.json -u<login>:<password> | mongoimport -d test -c live |
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 https://stream.twitter.com/1/statuses/sample.json -u<login>:<password> | mongoimport -d twitter -c in |
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 ruby | |
require 'mongo-hadoop' | |
MongoHadoop.map do |document| | |
{ :_id => document['user']['time_zone'], :count => 1 } | |
end |
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 ruby | |
require 'mongo-hadoop' | |
MongoHadoop.reduce do |key, values| | |
count = sum = 0 | |
values.each do |value| | |
count += 1 | |
sum += value['num'] | |
end |
OlderNewer