I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis onto
the box and here's how I did it and some things to look
out for.
To install:
| // usage: node vending.js > transitions | |
| var coins = [5, 10, 25, 100]; | |
| var _sum = 125; | |
| var validTransitions = []; | |
| coins.forEach(function (c) { check(0, c); }) | |
| function check(sum, coin, transitions) { | |
| transitions = transitions || []; | |
| var newSum = sum + coin; |
| var cp = require('child_process'); | |
| if (!process.send) { | |
| // master | |
| var child = cp.fork('./test.js'); | |
| child.on('message', function (msg) { | |
| process.stdout.write(msg); | |
| }); | |
| } else { | |
| // child |
| var mongodb = require('mongodb'); | |
| var server = new mongodb.Server('127.0.0.1', 27017, { auto_reconnect: false }); | |
| var db = new mongodb.Db('tester', server, { native_parser: true }); | |
| var insertCount = 0; | |
| db.open(ready); | |
| function ready(err, db) { | |
| process.nextTick(function () { | |
| db.collection('statuses', function (err, coll) { |
| // depth first in-order | |
| function traverse(node) { | |
| console.log(node.value); | |
| node.children.forEach(function (child) { | |
| traverse(child); | |
| }); | |
| } |
| [user] | |
| name = Mihai Tomescu | |
| email = [email protected] | |
| [core] | |
| excludesfile = ~/.gitignore | |
| [alias] | |
| st = status | |
| ci = commit |
| class Buckets(object): | |
| """ | |
| Buckets items by timestamp and counts the items in each bucket. | |
| """ | |
| def __init__(self, since, interval=300): | |
| """ | |
| :param since: Starting timestamp in seconds. | |
| :type since: int | |
| :param interval: The bucket size in seconds. |
| var Twit = require('twit'); | |
| var t = new Twit({ | |
| consumer_key: 'a', | |
| consumer_secret: 'b', | |
| access_token: 'c', | |
| access_token_secret: 'd' | |
| }); | |
| t.get('user/timeline', function (err, result) { |
| var stream = hub.sendAll('check-temp'); | |
| stream.on('error', function (err) { | |
| // called when there are errors - ex: missing ack / reply timeout | |
| console.log(err); | |
| }); | |
| stream.on('ack', function (ackMsg) { | |
| // not sure how useful this is | |
| }); |
| from flask import request | |
| from flask.ext.restful.reqparse import Argument, RequestParser | |
| class NestedArgument(Argument): | |
| def __init__(self, name, **kwargs): | |
| pieces = name.split('.') | |
| self.full_name = name |