Skip to content

Instantly share code, notes, and snippets.

View josephmisiti's full-sized avatar

Joseph Misiti josephmisiti

View GitHub Profile
@josephmisiti
josephmisiti / gist:2373049
Created April 13, 2012 02:22 — forked from redpony/gist:2341487
Constant time sampling from multinomials (linear time initialization)
#ifndef _ALIAS_SAMPLER_H_
#define _ALIAS_SAMPLER_H_
#include <vector>
#include <limits>
// Placed in the public domain by Chris Dyer <[email protected]>
// April 9, 2012
//
// R. A. Kronmal and A. V. Peterson, Jr. (1977) On the alias method for
/mnt/database
/mnt/logs/mongodb/mongodb.log
$ sudo apt-get update
$ mkdir -p /mnt/database
$ mkdir -p /mnt/logs/mongodb
$ chmod -R 777 /mnt/
$ sudo chown mongodb:mongodb /db/database
$ sudo chown mongodb:mongodb /mnt/logs/mongodb
$sudo chmod 777 /etc/apt/sources.list
$sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" >> /etc/apt/sources.list
$sudo apt-get update
$sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
$sudo apt-get update
mongod --dbpath /mnt/database --port 27017 --replSet sqset --oplogSize 50 --logpath /mnt/logs/mongodb/mongodb.log &
mongod --dbpath /mnt/database --port 27017 --replSet sqset --oplogSize 50 --logpath /mnt/logs/mongodb/mongodb.log &
config = {id: 'sqset', members: [ {id: 0, host: 'db01:27017'}, {_id: 1, host: 'db02:27017'} ] }
rs.initiate(config);
rs.initiate(config);
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
PRIMARY>
SECONDARY>