This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geoip = require('[email protected]'); | |
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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}]}}}' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run sockjs server on port 9999 | |
// use an old browser (ex: FF 3.5) which connects via polling transport | |
// frontend on 8888 | |
bouncy(function (req, bounce) { | |
if(headers.hasOwnProperty('upgrade')) { | |
// check if the request for upgrade is for websocket | |
// else just destroy the socket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var sockjs = require('sockjs'); | |
var node_static = require('node-static'); | |
var sockjs_opts = {sockjs_url: "http://127.0.0.1:8888/sockjs.js"}; | |
var sockjs_echo = sockjs.createServer(sockjs_opts); | |
sockjs_echo.on('connection', function(conn) { | |
console.log(conn.id + ' connected'); | |
conn.on('data', function(message) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var os = require('os'); | |
var WebSocketClient = require('websocket').client; | |
var count = 0; | |
function recursion() { | |
var client = new WebSocketClient(); | |
client.on('connectFailed', function(error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZQueue = function() { | |
this.queue = []; | |
this.queued = false; | |
}; | |
ZQueue.prototype.dequeue = function() { | |
this.queued = false; | |
this.shiftQueue(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Route = function(pattern, callback) { | |
this.pattern = pattern; | |
this.callback = callback; | |
}; | |
Route.prototype.matches = function(url) { | |
var params = {}; | |
if(!url.length) return false; | |
if(url[url.length-1] === "/") { | |
url = url.slice(0, url.length-1); |