Skip to content

Instantly share code, notes, and snippets.

View ralphholzmann's full-sized avatar

Ralph Holzmann ralphholzmann

View GitHub Profile
{
"uid": 47777, // Dropbox user ID
"stripeId": "cus_xxx", // Stripe customer ID, used for payments
"donationRedeemed": false, // Flag to determine if the user has redeemed a PayPal donation
"isNewPro": true, // Flag to determine if the user should be shown the "new pro" pop up
"joined": "2013-02-06T03:42:28.825Z", // Date the user joined
"lastActivity": "2013-02-06T16:05:47.797Z", // Date of the account's last activity
"pro": true, // Flag to determine if the account is a Pro account
"token": "xxxx", // Dropbox OAuth token
"tokenSecret": "xxxx", // Dropbox OAuth token secret
var EventEmitter = require("events").EventEmitter;
var emitter = new EventEmitter();
emitter.once("foo", function() {
console.log("foo");
});
emitter.on("foo", function() {
console.log("bar");
Stream = require "stream"
class Base64Stream extends Stream
_queue: ""
_emitChunk: ( chunk ) ->
@emit "data", new Buffer chunk, "base64"
write: ( chunk ) ->
@ralphholzmann
ralphholzmann / en.json
Created August 28, 2012 02:31
CanJS and messageformat.js example
{
numMessages: "You have {numMessages, plural, one {one message} other {#{numMessages} messages}}."
}
<script>
// Load browser shims
Modernizr.load([
{
test: window.JSON,
nope: 'libs/shims/json3.js'
},
{
test: Object.getOwnPropertyNames,
nope: "libs/shims/es5-shim.js",
@ralphholzmann
ralphholzmann / _with.js
Created April 25, 2012 19:35
JavaScript with-like function
var obj = {
"ralph" : 1,
"jon" : 2,
"alex" : 3
};
function _with( fn, data ) {
var keys = Object.keys( data ),
values = keys.map(function( key ) {
// This script exploits the fact that if you draw text on a
// canvas with a font stack that contains no available fonts,
// nothing gets drawn at all. So create a font stack with a
// single web font, and we can determine when it has been loaded.
var webfontCallback = (function() {
// Create a detached canvas with 1x1 dimensions
var canvas = document.createElement("canvas"),
context;
@ralphholzmann
ralphholzmann / gist:1872549
Created February 21, 2012 00:29 — forked from rmurphey/gist:1329222
New computer setup notes
var crypto = require('crypto'),
//sha1 = require('./sha1'),
http = require('http'),
https = require('https'),
url = require('url'),
util = require('util'),
querystring = require('querystring'),
_ = require("underscore"),
// OAuth constructor
success: function(data){
setTimeout(function(){
_.each( data.objects, function( obj ) {
var t = new Todo({
id: data.obj.id,
text: data.obj.text,
done: data.obj.done,
order: data.obj.order
});