Skip to content

Instantly share code, notes, and snippets.

View 3rd-Eden's full-sized avatar
💭
I have approximate knowledge of many things

Arnout Kazemier 3rd-Eden

💭
I have approximate knowledge of many things
View GitHub Profile
Listener.prototype.cleanup = function(){
var k = Object.keys(this.clients),
i = k.length,
clientCount = i,
readyStates = {},
requestStates = {};
while( i-- ){
if(this.clients[k[i]]){
if( this.clients[k[i]].connection && !!this.clients[k[i]].connection.readyState ){
@3rd-Eden
3rd-Eden / gist:644520
Created October 25, 2010 06:51
debug.log
Caught exception: Error: ETIMEDOUT, Connection timed out
[ 'Error: ETIMEDOUT, Connection timed out'
, ' at IOWatcher.callback (net:854:22)'
, ' at node.js:764:9'
]
Caught exception: Error: ETIMEDOUT, Connection timed out
[ 'Error: ETIMEDOUT, Connection timed out'
, ' at IOWatcher.callback (net:854:22)'
, ' at node.js:764:9'
]
@3rd-Eden
3rd-Eden / reconnect.js
Created November 2, 2010 22:04
reconnect.js
io.on("disconnect", function(){
setTimeout(function(){
if( io.connected ){
return io.fire("reconnect");
}
ignite.io.connect();
setTimeout( arguments.callee, 15000 )
}, 15000 );
});
# project noname (0.0.1) configured on Fri Nov 5 20:44:35 2010 by
# waf 1.5.16 (abi 7, python 20601f0 on darwin)
# using /usr/local/bin/node-waf configure build
#
----------------------------------------
Checking for program g++ or c++
find program=['g++', 'c++'] paths=[] var='CXX'
-> '/usr/bin/g++'
@3rd-Eden
3rd-Eden / socket.io.broadcast.http.url.js
Created November 30, 2010 21:20
Broadcast messages through socket.io based on server urls.
var http = require("http"), io = require("socket-io")
.. do your require stuff
var server = http.createServer(function(req,res){
.. determine the location, and if its the same use the socket.io broadcast fn to send a message
if( req url is the same as /ping )
socketio.broadcast("pong")
});
{ '0': 'restart',
'1': 'ws',
'2': null,
'3':
{ stdout:
{ path: 'log/ws-out.log',
fd: 8,
writable: true,
flags: 'a+',
[{"name":"Adobe Photoshop CS2","category":"Digital Imaging","boximage":"images/photoshop.gif","bkgimage":{},"descheader":"The professional standard in desktop digital imaging","desc":"Adobe® Photoshop® CS2 software, the professional image-editing standard and leader of the Photoshop digital imaging line, delivers more of what you crave. Groundbreaking creative tools help you achieve extraordinary results. Unprecedented adaptability lets you custom-fit Photoshop to the way you work. And with more efficient editing, processing, and file handling, there's no slowing you down.","features":{"feature":["Revolutionary Vanishing Point","Multiple layer control","Smart Objects","Multi-image digital camera raw file processing","Image Warp"]}},{"name":"Adobe Illustrator CS2","category":"Print Publishing","boximage":"images/illustrator.gif","bkgimage":{},"descheader":"Vector graphics reinvented","desc":"Adobe® Illustrator® CS2 software gives you new creative freedom that lets you realize your ideas quickly
@3rd-Eden
3rd-Eden / server.js
Created December 12, 2010 22:36
Running HTTPS and HTTP over the same route using the EventEmitter
// Include required modules
var crypto = require( "crypto" )
, http = require( "http" )
, fs = require( "fs" );
// Build our default app, just like would normally do
var app = http.createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/plain" } );
res.end( "Double http server, over http and https\n" );
});
var mongo = require("mongodb");
var connection = new mongo.Db( "database-namehere", new mongo.Server( "the host of your db", "the port number" ) );
// open the connection
connection.open(function(err){
if( err ) console.error( err );
connection.authenticate( "user", "password", function( err ){
if( err ) console.error( err );
@3rd-Eden
3rd-Eden / reconnect_chat.html
Created March 5, 2011 20:58
A reconnect enabled chat.html for socket.io
<!doctype html>
<html>
<head>
<title>socket.io client test</title>
<script src="/json.js"></script> <!-- for ie -->
<script src="/socket.io/socket.io.js"></script>
</head>
<body>