Skip to content

Instantly share code, notes, and snippets.

View FrancescaK's full-sized avatar

Francesca Krihely FrancescaK

View GitHub Profile
@FrancescaK
FrancescaK / gist:3945341
Created October 24, 2012 10:20
Encapsulating the Login Process
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
bcrypt = require('bcrypt'),
SALT_WORK_FACTOR = 10,
// these values can be whatever you want - we're defaulting to a
// max of 5 attempts, resulting in a 2 hour lock
MAX_LOGIN_ATTEMPTS = 5,
LOCK_TIME = 2 * 60 * 60 * 1000;
var UserSchema = new Schema({
parsed options:
{ nThreads: 32, fileSizeMB: 1000, r: true, mmf: true }
creating test file size:1000MB ...
testing...
new thread, total running : 1
67 ops/sec
110 ops/sec
184 ops/sec
167 ops/sec
174 ops/sec
#inserting documents
t.save( { _id: 1, title: "Physics World", text: "Physics World is the
membership magazine of the Institute of Physics."} );
t.save( { _id: 2, title: "A break away!", text: "'A break away!' is an
1891 painting by Australian artist Tom Roberts."} );
t.save( { _id: 3, title: "Mahim Bora", text: "Mahim Bora (b.1926) is an
Indian writer and educationist from Assam state."});
@FrancescaK
FrancescaK / mongoperfstats
Created January 17, 2013 16:04
mongoperf stats aws server
iops, thousands
threads read test write test
------- --------- ----------
1 4 8
2 8 8
4 16 8
8 32 8
16 64 8
32 70 8
@FrancescaK
FrancescaK / gist:3832812
Created October 4, 2012 10:32
testing passwords
var mongoose = require(mongoose),
User = require(./user-model);
var connStr = mongodb://localhost:27017/mongoose-bcrypt-test;
mongoose.connect(connStr, function(err) {
if (err) throw err;
console.log(Successfully connected to MongoDB);
});
// create a user a new user
@FrancescaK
FrancescaK / gist:3832833
Created October 4, 2012 10:34
Password Testing Scenario
var mongoose = require(‘mongoose’),
Schema = mongoose.Schema,
bcrypt = require(‘bcrypt’),
SALT_WORK_FACTOR = 10;
var UserSchema = new Schema({
username: { type: String, required: true, index: { unique: true } },
password: { type: String, required: true }
});
import com.mongodb.*;
import javax.net.ssl.SSLSocketFactory;
import java.util.Arrays;
public class SSLApp {
public static void main(String args[]) throws Exception {
MongoClient m = new MongoClient(new MongoClientURI("mongodb://gssapitest%40MONGOTEST.COM@rhel64.mongotest.com/?authMechanism=GSSAPI&ssl=true"));
DB db = m.getDB( "test" );
@FrancescaK
FrancescaK / gist:3832893
Created October 4, 2012 10:41
require:mongoose
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
bcrypt = require(bcrypt),
SALT_WORK_FACTOR = 10;
var UserSchema = new Schema({
username: { type: String, required: true, index: { unique: true } },
password: { type: String, required: true }
});
sh.setBalancerState (false)
use config
#adjust lower bound of the "current" range
db.tags.update( { "tag" : "current" }, { "$set" : { "min._id" : 201208140000032543 } } )
#adjust upper bound of the "archive" range
db.tags.update( { "tag" : "archive" }, { "$set" : { "max._id" : 201208140000000000 } } )
sh.setBalancerState(true)
@FrancescaK
FrancescaK / add shards and a shard key
Last active December 30, 2015 23:29
Adding Shards and a shard key to the archive and recent clusters
#add two shards
sh.addShardTag ("shard0000", "archive")
sh.addShardTag ("shard0001", "recent")
#shard database and collection, use "_id" as shard key
sh.enableSharding("mydb")
sh.shardCollection("mydb.mydata", { "_id" : 1 })
#define tag ranges
#first tag range: from the beginning of time until 1 Jan 2013, everything goes to "archive"