Skip to content

Instantly share code, notes, and snippets.

View bnoguchi's full-sized avatar

Brian Noguchi bnoguchi

View GitHub Profile
git clone http://github.com/bnoguchi/redis/tree/sort_get_hash_all_keys
cd redis
make
sudo make install
make test
sudo redis-server
git clone http://github.com/bnoguchi/redis-rb/tree/sort_get_hash_all_keys
cd redis
ruby sample.rb
diff --git a/bin/nodeprofile b/bin/nodeprofile
index 608872f..9f4cba1 100755
--- a/bin/nodeprofile
+++ b/bin/nodeprofile
@@ -11,29 +11,34 @@ var command = 'node --prof --log-snapshot-positions --logfile='+logName+' '+proc
console.log('Running: '+command);
-exec(command, function (error, stdout, stderr) {
- exec('locate linux-tick-processor.py', function(err, stdout, stderr) {
File "~/sources/github/node/deps/v8/tools/linux-tick-processor.py", line 78, in <module>
Main()
File "~/sources/github/node/deps/v8/tools/linux-tick-processor.py", line 73, in Main
cmdline_processor.RunLogfileProcessing(tick_processor)
File "~/sources/github/node/deps/v8/tools/tickprocessor.py", line 567, in RunLogfileProcessing
self.separate_ic, self.call_graph_json)
File "~/sources/github/node/deps/v8/tools/tickprocessor.py", line 216, in ProcessLogfile
for row in logreader:
_csv.Error: newline inside string
var sys = require("sys");
var HashRing = require("../lib/hash_ring");
var nodes = {
"127.0.0.1:8080": 1,
"127.0.0.2:8080": 1,
"127.0.0.3:8080": 1
};
var givens = {};
var Given = function (pattern, topicGenerator) {
givens[pattern] = topicGenerator;
};
var whens = {};
var When = function (pattern, topicGenerator) {
whens[pattern] = topicGenerator;
};
@bnoguchi
bnoguchi / express_with_ejs.js
Created December 10, 2010 04:11
Using ejs with express
var ejs = require('ejs')
, app = require('express').createServer();
app.set('view engine', 'ejs');
app.get('/', function (req, res) {
res.render('index'); // Where index.ejs is your ejs template
});
app.listen(3000);
@bnoguchi
bnoguchi / bug-334.js
Created April 26, 2011 21:24
Reply to mongoose GH-334
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, assert = require('assert');
var subSchema = new Schema({
name : String ,
subObj : { subName : String }
});
var schema = new Schema ({ name : String , arrData : [ subSchema] });
@bnoguchi
bnoguchi / enum-access.js
Created May 3, 2011 09:19
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
@bnoguchi
bnoguchi / GH-247.js
Created June 8, 2011 23:28
Correct example for GH-247
// Example works also works if you swap the commented lines into the code, and comment
// the corresponding uncommented lines.
var mongoose = require('mongoose')
, Schema = mongoose.Schema ;
mongoose.connect('mongodb://localhost/test');
var Item = new Schema({
cat_id: Number
@bnoguchi
bnoguchi / GH-248.js
Created June 8, 2011 23:36
GH-248 Working Example
// This shows that GH-248 is no longer relevant
var mongoose = require('mongoose')
, Schema = mongoose.Schema ;
mongoose.connect('mongodb://localhost/test');
var EmbeddedDocSchema = new Schema({
inner_label: String
});