Skip to content

Instantly share code, notes, and snippets.

{"EN/abc":"abc in EN ! Woohoooo !","version":3,"NL/abc":"abc in NL wooooohooooo ! chchchchcha"}
@samyakbhuta
samyakbhuta / webterminal.js
Created December 13, 2011 12:02
A way to provide input to REPL enviroment like 'node' and 'mongo'
var util = require('util');
var express = require('express');
var spawn = require('child_process').spawn;
var argv = require('optimist').argv;
var command = spawn(argv.command);
// mongo.stdin.write("db.mycoll.save(a:'a');");
command.stdout.on('data', function (data) {
console.log('stdout: ' + data);
@samyakbhuta
samyakbhuta / Error_IRCTC.co.in
Created December 8, 2011 05:38
Error log while booking a ticket at IRCTC.co.in
javax.servlet.jsp.JspException
at org.apache.struts.taglib.template.InsertTag.doEndTag(InsertTag.java:133)
at booking._0002fbooking_0002fplanner_0002ejspplanner_jsp_0._jspService(_0002fbooking_0002fplanner_0002ejspplanner_jsp_0.java:541)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:274)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:387)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.broadvision.servlet.ServletContainer.service(ServletContainer.java:404)
@samyakbhuta
samyakbhuta / MongoDBAndNull.js
Created November 18, 2011 08:07
The importance ( presence + consequence ) of null in mongodb
//Consider this as base collection. It is important to know how the MongoDB interprets 'null'.
> db.items.find();
{ "_id" : ObjectId("4ec60c984f5c08053610772f"), "attr1" : "a" }
{ "_id" : ObjectId("4ec60cb14f5c080536107730"), "attr1" : "b" }
{ "_id" : ObjectId("4ec60cb44f5c080536107731"), "attr1" : "c" }
{ "_id" : ObjectId("4ec60d0c4f5c080536107732"), "attr2" : "d" }
{ "_id" : ObjectId("4ec60d444f5c080536107733"), "attr2" : "d", "attr1" : null }
{ "_id" : ObjectId("4ec60fc34f5c080536107734"), "attr1" : "" }
@samyakbhuta
samyakbhuta / my_server_usingForever.js
Created August 12, 2011 09:07
A possible forever issue !!!
var express = require('express');
console.log("Server starting ...");
process.on('uncaughtException', function (err) {
console.log( "[Inside 'uncaughtException' event!] " + err.stack || err.message );
process.exit(1);
});
if (Math.random() > 0.5) throw new Error('Failed, 50:50');
@samyakbhuta
samyakbhuta / my_server.js
Created August 12, 2011 06:28
Catching an uncaughtException in express.js based server
var express = require('express');
process.on('uncaughtException', function(err) {
console.log( " UNCAUGHT EXCEPTION " );
console.log( "[Inside 'uncaughtException' event] " + err.stack || err.message );
});
anHTTPServer = express.createServer(function (req,res){
if (Math.random() > 0.9) throw new Error('fail!');
res.send("Hello World : Express!!");
});
@samyakbhuta
samyakbhuta / my_server.js
Created August 11, 2011 07:04
A very basic cluster.js example, giving "Error in unix_dgram bind of .." and "Error: stream not writable"
var http = require("http");
var cluster = require("cluster");
anHTTPServer = http.createServer(function (req,res){
res.write("Hello");
res.end();
});
//anHTTPServer.listen(3000);
cluster(anHTTPServer)
@samyakbhuta
samyakbhuta / connectingToMongoDB.js
Created July 19, 2011 15:21
Connecting to MongoDB
//some code avoided ....
getDatabase = function(host,port,dbname,isAutoReconnect,isStrict) {
if (logger) logger.info("Creating database. Details ... host: " + host +", port: "+ port + ", dbname: " + dbname + ". Auto Reconnect: " + isAutoReconnect + ", Strict Mode: " + isStrict);
var db = new mongo.Db(dbname, new mongo.Server(host,port, {'auto_reconnect':isAutoReconnect,poolSize: 4}),{strict:isStrict});
return db;
}
module.exports.getCollection = function (db,collectionName,callback){
@samyakbhuta
samyakbhuta / load-google-spreadsheet.js
Created July 11, 2011 06:51
Laoding Google Spreadsheet
var sys = require("sys");
var Spreadsheet = require("spreadsheet");
// Instantiate a spreadsheet using the key directly.
var sheet = new Spreadsheet("0AkUwNDE9ftXvdGMxQ2hMS2oySG9HeV9OeUtkZ2xoM1E"); //Works
//var sheet = new Spreadsheet("0Aiorqa2o8GY9dGk1MVNIMmhpZGR5YmRfTzlfdzNwZHc");
// Load the worksheets, callback will be called for each worksheet
sheet.worksheets(function(err,ws){
[60550.147454] node invoked oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
[60550.147473] node cpuset=/ mems_allowed=0
[60550.147480] Pid: 6638, comm: node Not tainted 2.6.35.11-83.9.amzn1.x86_64 #1
[60550.147488] Call Trace:
[60550.147503] [<ffffffff8108e818>] ? cpuset_print_task_mems_allowed+0x98/0xa0
[60550.147514] [<ffffffff810bb327>] dump_header.clone.1+0x77/0x1a0
[60550.147525] [<ffffffff8131fd99>] ? _raw_spin_unlock_irqrestore+0x19/0x20
[60550.147535] [<ffffffff811b119f>] ? ___ratelimit+0x9f/0x120
[60550.147543] [<ffffffff810bb4c6>] oom_kill_process.clone.0+0x76/0x140
[60550.147551] [<ffffffff810bb6a8>] __out_of_memory+0x118/0x190