Skip to content

Instantly share code, notes, and snippets.

faye = require 'faye'
client = new faye.Client 'http://josephgentle.com:4321/bayeux'
client.subscribe '/msg', (message) ->
console.timeEnd message
.callback ->
console.log 'Connected!'
seq = 0
@josephg
josephg / gist:1330141
Created November 1, 2011 08:19
echo server & client
connect = ->
clientio = require 'socket.io-client'
client = clientio.connect 'http://localhost:8999'
client.on 'connect', ->
console.warn 'Connected'
setInterval ->
console.time 'message'
client.send 'hi'
@josephg
josephg / output.txt
Created November 1, 2011 09:04
Connect is broken in 0.5.10
connect = require 'connect'
request = require 'request'
connect(
connect.logger()
connect.static __dirname
).listen 3000, ->
request "http://localhost:3000/c.coffee", (err, resp, body) ->
console.warn err.stack if err
@josephg
josephg / node0.5.10.txt
Created November 1, 2011 10:11
http client behaviour under 0.5.0
$ coffee cc.coffee
Error: socket hang up
at createHangUpError (http.js:1083:15)
at Socket.<anonymous> (http.js:1166:27)
at Socket.emit (events.js:88:20)
at Array.0 (net.js:280:10)
at EventEmitter._tickCallback (node.js:194:26)
@josephg
josephg / gist:1520465
Created December 26, 2011 03:10
Chipmunk js v8 profile (PyramidStack test)
Statistical profiling result from /Users/josephg/src/chipmunkjs/v8.log, (6853 ticks, 46 unaccounted, 0 excluded).
[Unknown]:
ticks total nonlib name
46 0.7%
[Shared libraries]:
ticks total nonlib name
[JavaScript]:
@josephg
josephg / gist:1531674
Created December 29, 2011 03:41
v8 bench.js --trace-opt --trace-bailout --trace-deopt on PyramidStack, chipmunkjs
[marking exports.Vect 0x1b70ac6a3de8 for recompilation]
[optimizing: exports.Vect / 1b70ac6a3de9 - took 0.623 ms]
[marking mymin 0x3ebe7f51e08 for recompilation]
[optimizing: mymin / 3ebe7f51e09 - took 0.141 ms]
[marking exports.collideShapes 0x1b70ac6a68c8 for recompilation]
[optimizing: exports.collideShapes / 1b70ac6a68c9 - took 0.335 ms]
[marking Arbiter.applyImpulse 0x1b70ac6a67f0 for recompilation]
[optimizing: Arbiter.applyImpulse / 1b70ac6a67f1 - took 3.078 ms]
[marking apply_impulse 0x109a8cf2d358 for recompilation]
[optimizing: apply_impulse / 109a8cf2d359 - took 0.285 ms]
@josephg
josephg / bench.c
Created January 1, 2012 01:52
Running the chipmunk benchmarks in C
void runBenchmarks(void){
for(int i = 0; i < bench_count; i++){
{
int i = 16;
ChipmunkDemo bench = bench_list[i];
printf("%s\n", bench.name);
fflush(stdout);
bench.initFunc();
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
@josephg
josephg / gist:1786829
Created February 10, 2012 05:03
Mutation Observer record log for paste operation
Given a contenteditable div containing this html:
<p>a paragraph with some <b>bold text</b> and <i>italics text</i></p>
I copy+pasted a duplicate of the 'h' character at the end of 'paragraph'. This is the mutation records:
Got 35 mutation record(s)
added text node with 'a paragraphh'
changed text from 'a paragraph with some ' to ' with some '
added element <p></p>
sephsmac:~ josephg$ git clone https://github.com/slembcke/Chipmunk-Physics.git
Cloning into 'Chipmunk-Physics'...
remote: Counting objects: 5761, done.
remote: Compressing objects: 100% (1382/1382), done.
remote: Total 5761 (delta 4350), reused 5479 (delta 4089)
Receiving objects: 100% (5761/5761), 1.19 MiB | 153 KiB/s, done.
Resolving deltas: 100% (4350/4350), done.
sephsmac:~ josephg$ cd Chipmunk-Physics/xcode
sephsmac:xcode josephg$ xcodebuild
=== BUILD NATIVE TARGET ChipmunkStatic OF PROJECT Chipmunk6 WITH THE DEFAULT CONFIGURATION (Release) ===
#include "stdafx.h"
#include "SDL.h"
#include "SDL_video.h"
enum Ingredients
{
CARROT = 1,
CHEDDAR = 2,
CAPSICUM = 4,
FETTA = 8,