Skip to content

Instantly share code, notes, and snippets.

View shripadk's full-sized avatar
🎯
Working

Shripad Krishna shripadk

🎯
Working
View GitHub Profile
/* SockJS client, version 0.1.1, http://sockjs.org, MIT License
Copyright (C) 2011 VMware, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@shripadk
shripadk / gist:1381446
Created November 21, 2011 02:36
secret. do not fork it!
/* SockJS client, version 0.1.1, http://sockjs.org, MIT License
Copyright (C) 2011 VMware, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@shripadk
shripadk / gist:1159182
Created August 20, 2011 14:41
Fixed handling error event in cradle.
var path = require('path');
require.paths.unshift(path.join(__dirname, 'cradle'));
var sys = require("sys"),
http = require("http"),
https = require("https"),
events = require('events'),
fs = require("fs"),
url = require('url'),
@shripadk
shripadk / gist:1146977
Created August 15, 2011 15:16
Cradle + Couchbase Server 2.0
Error: { error: 'badmatch',
reason: '{badrpc,{\'EXIT\',{{badmatch,{not_found,missing}},\n [{capi_crud,\'-get_doc_rev/4-fun-0-\',3},\n {capi_crud,open_db,3},\n {capi_crud,update_doc,4},\n {rpc,local_call,3},\n {couch_httpd_db,db_req,2},\n {couch_httpd,handle_request_int,6},\n {mochiweb_http,headers,5},\n {proc_lib,init_p_do_apply,3}]}}}' }
@shripadk
shripadk / gist:972913
Created May 15, 2011 06:14
GeoIP 0.4.0beta1
var geoip = require('geoip@0.4.0beta1');
var ip = '50.19.121.109';
var city = new geoip.City('/usr/local/share/GeoIP/GeoLiteCity.dat');
city.lookup(ip, function(data) {
console.log(data);
});
/**
RESULT:
{ country_code: 'US',
@shripadk
shripadk / gist:972909
Created May 15, 2011 06:12
GeoIP 0.3.4-1
var geoip = require('geoip@0.3.4-1');
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',
@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[
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
#!/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.
##
#!/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.
##