Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dominictarr's full-sized avatar

Dominic Tarr dominictarr

View GitHub Profile
@dominictarr
dominictarr / test-methods.js
Created July 17, 2011 12:51 — forked from stagas/test-methods.js
node-http-proxy methods not working
var http = require('http')
, httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
//
// Put your custom server logic here
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000
var http = require('http'),
fs = require('fs'), // to load html/js templates
window = require("jsdom").jsdom().createWindow(), // DOM/BOM
jQuery = require('jquery'), // for selectors
$p = require('pure').$p//FIX
templates = {};
http.createServer(function (req, res) {
//npm install http-proxy socket.io@0.6.17
var server = require("http").createServer(function(req, res) {
res.writeHead(200, {"content-type": "text/html"});
res.end("<html><body><script src='/socket.io/socket.io.js'></script>\
<script>\
var socket = new io.Socket(null, {transports: ['xhr-multipart']});\
socket.connect();\
</script></body></html>");
})
@dominictarr
dominictarr / client.js
Created July 29, 2011 08:18 — forked from fjakobs/index.html
node-http-proxy bug #70
var http = require('http')
function log (str) {
console.log('' + str)
}
http.get({host: 'localhost', port:6666, path: '/xhr'}, function (res) {
res.on('data', log)
res.on('end', log)

through stream

.----------------------------------------.
| write(data)-------->emit('data', data`)|
`----------------------------------------`

duplex stream (across a network)

@dominictarr
dominictarr / header.js
Created November 7, 2012 00:26
this script does nothing
var convoy = require('convoy-stream');
var split = require('event-stream').split
var through = require('through');
var header = convoy();
var h = header.createStream();
h.write('beep\n');
var _header = convoy()
/* WebRTC consist of a few moving pieces
- A signal mechanism for peers
- A signal mechanism to send offers & answers
- A simplified peerConnection function
*/
var uuid = require("node-uuid")
, assert = require("assert")
@dominictarr
dominictarr / git-commit-prefixes
Created May 23, 2011 23:02 — forked from Marak/git-commit-prefixes
Short list of Git commit prefixes used at Nodejitsu
[api]: New apis / changes to apis
[test]: Update test/* files
[dist]: Changes to submodules, version bumps, updates to package.json
[minor]: Small changes
[doc]: Updates to documentation
[ux]: Updates to UX
[fix]: Bug fixes
[bin]: Update binary scripts associated with the project
[merge]: Resolved git merge from upstream or otherwise
[refactor]: Refactor of existing code with no external API changes
@dominictarr
dominictarr / scuttlebutt_muxdemux_test.js
Last active December 14, 2015 15:59 — forked from mjohnsullivan/scuttlebutt_muxdemux_test.js
fix a few common stream/scuttlebutt gotchas
var MuxDemux = require('mux-demux');
var net = require('net');
var Model = require('scuttlebutt/model');
var aModel = new Model
var bModel = new Model
//the scuttlebutt's must have 1 stream per connection,
//therefore they must be created inside the server handler.
var browserify = require('./');
var through = require('through');
var stream = through(function(data) {
var self = this;
self.resume();
self.emit('data', data);
});
var bundle = browserify();