Skip to content

Instantly share code, notes, and snippets.

View ralphholzmann's full-sized avatar

Ralph Holzmann ralphholzmann

View GitHub Profile
class UserDetail extends Base {
render () {
let { user } = this.props;
return (
<strong>{user.name}</strong>
);
}
}
something.then(function() {
throw new Error(“lel”);
}, function(error) {
// lol you think I’ll catch, but I wont
}).then(null, function(error) {
// Actually gets caught here.
console.error(error); // "lel"
});
(function ($) {
var keys = [], code = '38,38,40,40,37,39,37,39,66,65';
var konami = function (e) {
keys.push(e.which);
if (keys.length >= 11 && keys.slice(-11).toString() !== code) {
keys = [];
/* do your konami thing here */
} else if (keys.length > 11) {
keys.length = 11;
}
define(["ember"], function (Ember) {
return {
load: function(name, require, onload, config) {
require(["text!/js/templates/" + name + ".hbs"], function (template) {
Ember.TEMPLATES[name] = Ember.Handlebars.compile(template);
onload();
});
}
};
});
{
"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 ) {