Skip to content

Instantly share code, notes, and snippets.

@donpark
donpark / lazy.go
Created July 25, 2015 00:49
Abstract lazy connection with optional auto disconnect on idle timeout
package lazy
import (
"sync"
"time"
)
type Connection struct {
sync.Mutex
conn interface{}
@donpark
donpark / Capfile
Created September 9, 2010 18:32 — forked from nstielau/Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
##################################
# Edit these
set :application, "stoned"
set :node_file, "app.js"
set :host, "ec2-204-236-143-54.us-west-1.compute.amazonaws.com"
ssh_options[:keys] = [File.join(ENV["HOME"], ".ec2", "default.pem")]
set :repository, "git://gist.github.com/572292.git"
set :branch, "master"
@donpark
donpark / PBKDF2Async.js
Created March 7, 2011 05:59
async PBKDF2 with optional progress callback
// original, synch version, is at:
// http://code.google.com/p/crypto-js/source/browse/branches/2.0.x/src/PBKDF2.js
(function(){
// Shortcuts
var C = Crypto,
util = C.util,
charenc = C.charenc,
UTF8 = charenc.UTF8,
@donpark
donpark / mongeese.coffee
Created April 1, 2011 12:03
stupid node.js module written in coffee-script to handle multiple Mongoose database seamlessly
mongoose = require('mongoose')
exports.create = ->
instance = new mongoose.Mongoose()
# copy over extras Mongoose users expects
instance.Collection = mongoose.Collection
instance.Connection = mongoose.Connection
instance.version = mongoose.version
instance.Mongoose = mongoose.Mongoose
instance.Schema = mongoose.Schema
@donpark
donpark / session-mongeese.coffee
Created May 17, 2011 21:34
Mongoose-based node.js connect session store implementation in CoffeeScript
mongoose = require('mongoose')
mongeese = new mongoose.Mongoose()
mongeese[key] = value for key, value of mongoose when not mongeese[key]? and mongoose.hasOwnProperty(key)
Schema = mongeese.Schema
SessionSchema = new Schema({
sid: { type: String, required: true, unique: true }
data: { type: String, default: '{}' }
expires: { type: Date, index: true }
@donpark
donpark / gist:1070097
Created July 7, 2011 17:50
WebRTC OS X Notes

*This file is a placeholder to collect notes from building WebRTC on OS X

Base SDK Problem

By default, WebRTC generates Xcode project files requiring OSX 10.5 SDK which is not shipped with Xcode 4+ and result in missing SDK errors.

Using OS X 10.6 SDK

Change following line in trunk/build/common.gypi file

@donpark
donpark / layout.coffee
Created August 5, 2011 04:53
Rough first cut of integration-friendly layout library in coffeescript
###
Rewrite of Bram Stein's [jLayout](http://www.bramstein.com/projects/jlayout/)
which uses [new BSD license](http://www.bramstein.com/licenses/BSD.txt).
jLayout license summary:
jLayout is completely free for commercial and non-commercial use and
you can do with it whatever you want, except claim it as your own work.
---
@donpark
donpark / process_ntriple_gz.coffee
Created February 1, 2012 09:36
Example code for processing Gzipped file in Node.js using node-bufferstream
fs = require('fs')
zlib = require('zlib')
# see: https://github.com/dodo/node-bufferstream
BufferStream = require('bufferstream')
input = fs.createReadStream inputPath,
flags: 'r'
mode: 0666
@donpark
donpark / outdated-ux.md
Created February 6, 2012 20:50
Noise from outdated submodules
$ npm outdated -g
hook.io@0.8.7 /usr/local/lib/node_modules/hook.io current=0.8.6
qs@0.4.1 /usr/local/lib/node_modules/qs current=0.4.0
qs@0.4.1 /usr/local/lib/node_modules/serve/node_modules/connect/node_modules/qs current=0.4.0
yamlish@0.0.3 /usr/local/lib/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish current=0.0.2
request@2.9.100 /usr/local/lib/node_modules/npm/node_modules/request current=2.9.3
which@1.0.3 /usr/local/lib/node_modules/npm/node_modules/which current=1.0.2
fstream@0.1.12 /usr/local/lib/node_modules/npm/node_modules/fstream current=0.1.11
minimatch@0.1.5 /usr/local/lib/node_modules/npm/node_modules/minimatch current=0.1.3

fstream@0.1.12 /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/fstream current=0.1.11

@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: