Skip to content

Instantly share code, notes, and snippets.

Avatar

Dominic Tarr dominictarr

View GitHub Profile
@dominictarr
dominictarr / test-methods.js
Created Jul 17, 2011 — forked from stagas/test-methods.js
node-http-proxy methods not working
View test-methods.js
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
View gist:853820
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) {
View server.js
//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 Jul 29, 2011 — forked from fjakobs/index.html
node-http-proxy bug #70
View client.js
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)
View through_vs_duplex.md

through stream

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

duplex stream (across a network)

@dominictarr
dominictarr / header.js
Created Nov 7, 2012 — forked from substack/header.js
this script does nothing
View header.js
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()
View data-channel.js
/* 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")
View index.html
<canvas width=800 height=600></canvas>
<script>
var id
var mem = new Uint8ClampedArray(1024*1024 * 4)
function resize () {
canvas.width = window.innerWidth
canvas.height = window.innerHeight
id = new ImageData(mem.slice(0, canvas.width*canvas.height*4), canvas.width, canvas.height)
@dominictarr
dominictarr / readme.md
Created Nov 26, 2018
statement on event-stream compromise
View readme.md

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu

View style_guide.md

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

You can’t perform that action at this time.