Skip to content

Instantly share code, notes, and snippets.

@donpark
donpark / webrtc-canary.md
Created February 7, 2012 20:28
Notes on Chrome Canary implementation of WebRTC

Version: 19.0.1032.0 canary

getUserMedia

According to current getUserMedia spec, getUserMedia function is:

navigator.getUserMedia({audio: true, video: true}, gotStream, gotError);

which didn't work. What worked was:

@donpark
donpark / perlincanvas.js
Created February 11, 2012 04:45
Rendering Perlin Noise Fast to HTML5 Canvas
/* Following canvas-based Perlin generation code originates from
* iron_wallaby's code at: http://www.ozoneasylum.com/30982
*/
function randomNoise(canvas, x, y, width, height, alpha) {
x = x || 0;
y = y || 0;
width = width || canvas.width;
height = height || canvas.height;
alpha = alpha || 255;
var g = canvas.getContext("2d"),
@donpark
donpark / kafka.md
Created February 14, 2012 02:58
Running Kafka 0.7

Running Apache Kafka 0.7

Download Initial Package

wget http://people.apache.org/~nehanarkhede/kafka-0.7.0-incubating/kafka-0.7.0-incubating-src.tar.gz
tar xvzf kafka-0.7.0-incubating-src.tar.gz
cd kafka-0.7.0-incubating-src

Build Kafka

@donpark
donpark / mate2subl.md
Created February 24, 2012 22:18
TextMate to Sublime Text 2 Migration Notes for Node.js Developers

TextMate to Sublime Text 2 Migration Notes for Node.js Developers

Copy existing Jade and Stylus bundles from TextMate

From @csanz's gist

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
mkdir Jade Stylus
cp -rf ~/Library/Application\ Support/TextMate/Bundles/Jade.tmbundle ./Jade/

cp -rf ~/Library/Application\ Support/TextMate/Bundles/Stylus.tmbundle ./Stylus/

@donpark
donpark / sdp2json.coffee
Created March 15, 2012 00:05
Parse SDP to JSON in Coffee
parseSDP = (text) ->
return if not text
lines = text.split('\r\n')
readSession lines
readSession = (lines) ->
session = {}
line = null
while line = lines.shift()
name = line.charAt(0)
@donpark
donpark / tlc.lua
Created March 28, 2012 18:24 — forked from fjolnir/tlc.lua
LuaJIT ObjC bridge
-- TLC - The Tiny Lua Cocoa bridge
-- Note: Only tested with LuaJit 2 Beta 9 on x86_64 with OS X >=10.7.3 & iPhone 4 with iOS 5
-- Copyright (c) 2012, Fjölnir Ásgeirsson
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@donpark
donpark / resizer.coffee
Created May 3, 2012 18:08
Deferred Resizer in CoffeeScript
# Delayed resize task runner
class DeferredResizer
constructor: ->
@timer = null
@tasks = []
addTask: (task) ->
@tasks.push(task) if @tasks.indexOf(task) is -1
doTasks: =>
@timer = null
@donpark
donpark / timing.coffee
Created August 22, 2012 00:08
Simple high-resolution timing wrapper module in CoffeeScript
if process.hrtime
console.log "using process.hrtime for timing"
clock = process.hrtime
else
console.log "using microtime for timing"
Microtime = require('microtime')
clock = (s) ->
t = Microtime.nowStruct()
t[1] *= 1000 # microseconds to nanoseconds
if s
@donpark
donpark / fabfile.py
Created August 28, 2012 01:07
fabric/python script for launching node-inspector
import os
import time
def terminal(cmd):
local("osascript -e 'tell application \"Terminal\" to do script \"%s\"'" % cmd)
def debugger(opts):
url = "http://0.0.0.0:8080/debug?port=5858"
build()
terminal("node %(opts)s %(cwd)s/app.js" % { "opts": opts, "cwd": os.getcwd() })
@donpark
donpark / npm-debug.log
Created April 12, 2013 02:16
npm-debug.log for npm issue #3339
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ]
2 info using npm@1.2.18
3 info using node@v0.10.4
4 verbose publish [ '.' ]
5 verbose read json /Users/don/dev/github/node-tld/package.json
6 verbose cache add [ '.', null ]
7 verbose cache add name=undefined spec="." args=[".",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url slashes: null,