Skip to content

Instantly share code, notes, and snippets.

View shripadk's full-sized avatar
🎯
Working

Shripad Krishna shripadk

🎯
Working
View GitHub Profile
Db = require('mongodb').Db
Connection = require('mongodb').Connection
Server = require('mongodb').Server
EventEmitter = require('events').EventEmitter
sys = require('sys')
colors = require('colors')
host = if process.env['MONGO_NODE_DRIVER_HOST'] then process.env['MONGO_NODE_DRIVER_HOST'] else 'localhost'
port = if process.env['MONGO_NODE_DRIVER_PORT'] then process.env['MONGO_NODE_DRIVER_PORT'] else Connection.DEFAULT_PORT
db = []
Db = require('mongodb').Db
Connection = require('mongodb').Connection
Server = require('mongodb').Server
EventEmitter = require('events').EventEmitter
sys = require('sys')
colors = require('colors')
host = if process.env['MONGO_NODE_DRIVER_HOST'] then process.env['MONGO_NODE_DRIVER_HOST'] else 'localhost'
port = if process.env['MONGO_NODE_DRIVER_PORT'] then process.env['MONGO_NODE_DRIVER_PORT'] else Connection.DEFAULT_PORT
db = []
// [~/Documents/code/node/myapp](master)$ ./bin/node -v
// => v0.2.1
// [~/Documents/code/node/myapp](master)$ ./bin/express -v
// => 1.0.0rc4
/**
* Module dependencies.
*/
require.paths.unshift(__dirname + '/lib/node');
@shripadk
shripadk / post-receive
Created December 25, 2010 03:07
post-receive hook
#!/usr/bin/env node
var user = process.ENV['USER'],
sys = require('sys'),
exec = require('child_process').exec;
console.log("Push complete on user: " + user);
exec('cd .. && git clone testbarerepo pingpong --recursive', function(e, stdout, stderr){
if(stderr) {
exec('cd .. && cd pingpong && git pull && git submodule init && git submodule update', function(e, stdout, stderr) {
➜ dingdong git:(master) git push origin master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 230 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
remote: Push complete on user: shripadk
remote: error : Error: Command failed: fatal: Not a git repository: '.'
remote:
#!/usr/bin/perl
## REDIS REMOTE CONNECTOR
##
## Edit these values to reflect the authentication credentials for the
## server running the instance with which you wish to
## modify the `$remote_port` value. You should not need to modify the
## `$remote_ip` value.
##
#!/usr/bin/perl
## mongodb REMOTE CONNECTOR
##
## Edit these values to reflect the authentication credentials for the
## server running the instance with which you wish to
## modify the `$remote_port` value. You should not need to modify the
## `$remote_ip` value.
##
var f=this;function g(a,c,b){a=a.split(".");b=b||f;!(a[0]in b)&&b.execScript&&b.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)if(!a.length&&c!==undefined)b[d]=c;else b=b[d]?b[d]:b[d]={}}var h=Date.now||function(){return+new Date},i,j,k,l;function m(){return f.navigator?f.navigator.userAgent:null}l=k=j=i=false;var n;if(n=m()){var o=f.navigator;i=n.indexOf("Opera")==0;j=!i&&n.indexOf("MSIE")!=-1;k=!i&&n.indexOf("WebKit")!=-1;l=!i&&!k&&o.product=="Gecko"}var p=j,q=l,r=k,s="",t;
if(i&&f.opera){var u=f.opera.version;s=typeof u=="function"?u():u}else{if(q)t=/rv\:([^\);]+)(\)|;)/;else if(p)t=/MSIE\s+([^\);]+)(\)|;)/;else if(r)t=/WebKit\/(\S+)/;if(t){var v=t.exec(m());s=v?v[1]:""}}var w=/\s*;\s*/;
function x(a,c,b,d,e){if(/[;=\s]/.test(a))throw Error('Invalid cookie name "'+a+'"');if(/[;\r\n]/.test(c))throw Error('Invalid cookie value "'+c+'"');b!==undefined||(b=-1);e=e?";domain="+e:"";d=d?";path="+d:"";b=b<0?"":b==0?";expires="+(new Date(1970,1,1)).toUTCString():";expires="+(new Date(h()+b*1E3)).toUTCSt
@shripadk
shripadk / scrollIntoView.js
Created February 25, 2011 09:03
scrollIntoView
var h=null,i=this;function j(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};var k,l,m,n;function s(){return i.navigator?i.navigator.userAgent:h}n=m=l=k=false;var t;if(t=s()){var u=i.navigator;k=t.indexOf("Opera")==0;l=!k&&t.indexOf("MSIE")!=-1;m=!k&&t.indexOf("WebKit")!=-1;n=!k&&!m&&u.product=="Gecko"}var v=k,w=l,x=n,y=m,z;
a:{var A="",B;if(v&&i.opera){var C=i.opera.version;A=typeof C=="function"?C():C}else{if(x)B=/rv\:([^\);]+)(\)|;)/;else if(w)B=/MSIE\s+([^\);]+)(\)|;)/;else y&&(B=/WebKit\/(\S+)/);if(B){var D=B.exec(s());A=D?D[1]:""}}if(w){var E,F=i.document;E=F?F.documentMode:undefined;if(E>parseFloat(A)){z=String(E);break a}}z=A}var G={};
function H(){if(!G["9"]){for(var a=0,b=String(z).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),c=String("9").replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(b.length,c.length),g=0;a==0&&g<e;g++){var d=b[g]||"",f=c[g]||"",o=RegExp("(\\d*)(\\D*)","g"),p=RegExp("(\\d*)(\\D*)","g");do{var q=o.exec(d)||["","",""],r=p.exec(f)||["","",""];if(q[0].length==0&&r[
@shripadk
shripadk / gist:972909
Created May 15, 2011 06:12
GeoIP 0.3.4-1
var geoip = require('[email protected]');
var ip = '50.19.121.109';
var data = geoip.open('/usr/local/share/GeoIP/GeoLiteCity.dat');
var result = geoip.City.record_by_addr(data, ip);
console.log(result);
/**
RESULT:
{ country_code: 'US',