Skip to content

Instantly share code, notes, and snippets.

View nodesocket's full-sized avatar

Justin Keller nodesocket

View GitHub Profile
@nodesocket
nodesocket / gist:1215691
Created September 14, 2011 02:03
Public Keys
ssh-dss AAAAB3NzaC1kc3MAAACBAOLsyYuyI0/3/UjajY8ljdgkAV2k9jZxjlVGWvHa9afMuO7DqsOcu0o4e5D9TPScsO5XrgTrmcXHkOtM54fOPdXSzonWOXUIn1XEumdHDlv9YRZTCW/A9qajhPR67y+92su9AqeGXI0/q3BXZsZcC1nr1NjgSiz++r+YZFVWfQsNAAAAFQCYBf0KXVLfYUE6cOTbWnBWn5Py9QAAAIEA3WAkAwhR7fhwWpxuwxNnsB8NXwsEs2NWiOaiMu3dmDWyqGRjfOYUchoLelBMpv4oLTZuaGW4/DCWfdh6pgrxs39MXf+FdTir8KeHIIoXEdcXpWqnuyNBdXn5XNY54vc1eMkbm4q3D1i3+IMhNAURasdvFRoDzgH9s68Ik3P5HrMAAACAab+CiT010wXMzv+6v+oWcRWbxhGou/ND+K2QGU1kAW+KuUGmhOgB6XPka7iEsIeA/+Ojh+OiNedFZlJAZq1jarew106YCOrUlbtDk7pAAUJQhIhKFhpNE0UhLRBWOF9LpjDwWu55dlrfLURE32TuMx/NsazWVypbzJqy48d2sg8= justin@mbpro
@nodesocket
nodesocket / hack-with-set-timeout.js
Created September 15, 2011 21:41
How To Refactor This, Without Using SetTimeout
child.on("start", function(forever) {
//A bit of a hack, but we delay before calling the callback because we want to see if error or exit events are fired.
setTimeout(function() {
typeof this.callback === "function" ? this.callback.call() : null;
}.bind({ callback: this.callback }), 500);
}.bind({ callback: callback }));
child.on("exit", function(forever) {
typeof this.callback === "function" ? this.callback.call() : null;
}.bind({ callback: callback }));
diff --git a/lib/net.js b/lib/net.js
index 4af00b4..9565b38 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -350,8 +350,9 @@ Socket.prototype.write = function(data /* [encoding], [fd], [cb] */) {
this._writeQueueCallbacks[last] = cb;
} else {
// awful
+ var original = this._writeQueueCallbacks[last];
this._writeQueueCallbacks[last] = function() {
//Socket not connected
else {
//Not already trying to connect, create a new socket
if(!logify.connecting) {
//Create the socket
logify.connecting = true;
logify.connect();
}
//Write to temporary storage array
//Socket not connected
else {
//Not already trying to connect, create a new socket
if(!logify.connecting) {
//Create the socket
logify.connecting = true;
logify.connect();
}
//Write to temporary storage array
@nodesocket
nodesocket / gist:1396354
Created November 26, 2011 21:52
Bounce With Re-Writes
//Assume this structure storing routes and corresponding host and port
var routes = [ '/app1': { host: '127.0.0.1', port: 3000 },
'/app2': { host: '127.0.0.1', port: 3010 },
'/app3': { host: '127.0.0.1', port: 3020 } ];
http_proxy(function (req, bounce) {
var route = routes[req.url];
if(typeof route === "object") {
//Want to rewrite the url, remove '/app1' or basically the key in the array structure
@nodesocket
nodesocket / gist:1414355
Created December 1, 2011 06:37
Video CSS3 Effect
.vignette {
opacity: 0.55;
filter: alpha(opacity = 55);
-o-transition: opacity 0.30s linear;
-moz-transition: opacity 0.30s linear;
-webkit-transition: opacity 0.30s linear;
transition: opacity 0.30s linear;
}
.vignette:hover {
@nodesocket
nodesocket / gist:1415442
Created December 1, 2011 09:52
GitHub API Wrapper
<?php
////
// Dependencies
////
require_once(dirname(dirname(__FILE__)) . "/classes/Curl.php");
/**
* GitHub
*
* @todo
@nodesocket
nodesocket / gist:1415453
Created December 1, 2011 09:53
Curl Class
<?php
/**
* Curl
*
* @todo
*
* @version 1.0.0
* @date last modified 11/07/2011
*/
class Curl {
@nodesocket
nodesocket / gist:1429527
Created December 4, 2011 07:36
http-proxy re-write
var gear;
var starts_with_slash;
//Get if the request starts with a slash
req.url.substring(0, 1) === '/' ? starts_with_slash = true : starts_with_slash = false;
//Request starts with slash
if(starts_with_slash) {
//The position of the second slash, since the first slash is at index 0
var end = req.url.indexOf('/', 1);