Skip to content

Instantly share code, notes, and snippets.

View KoryNunn's full-sized avatar

Kory Nunn KoryNunn

View GitHub Profile
@KoryNunn
KoryNunn / gist:9380511
Created March 6, 2014 01:39
Print the stack for console logs in node. Good if you can't find where a log is coming from.
var oldlog = console.log;
console.log = function(){
oldlog.call(this, new Error().stack);
oldlog.apply(this, arguments);
}
@KoryNunn
KoryNunn / index.js
Created March 12, 2014 05:56
requirebin sketch
// require something
window.WM1 = require('weakmap');
window.WM2 = require('weak-map');
@KoryNunn
KoryNunn / gist:9699502
Last active August 29, 2015 13:57
gaffa clipboard action
var Gaffa = require('gaffa');
function Clipboard(){}
Clipboard = Gaffa.createSpec(Clipboard, Gaffa.Action);
Clipboard.prototype.type = 'clipboard';
Clipboard.prototype.trigger = function(parent, scope, event){
scope = scope || {};
scope.data = this.source.value;
if (window.clipboardData && window.clipboardData.setData) {
clipboardData.setData("Text", this.source.value);
@KoryNunn
KoryNunn / gist:9880205
Created March 30, 2014 21:32
requirebin peerDep issue.
var Gaffa = require('gaffa');
var gaffa = new Gaffa();
// Has gaffa as a peerDependency.
var Textbox = require('gaffa-textbox');
gaffa.registerConstructor([
Textbox
]);
@KoryNunn
KoryNunn / gist:9881655
Created March 30, 2014 23:23
peerDependency styles
// Original
var Gaffa = require('gaffa'),
Container: require('gaffa-container'),
Heading: require('gaffa-heading'),
List: require('gaffa-list'),
Form: require('gaffa-form'),
Label: require('gaffa-label'),
Text: require('gaffa-text'),
Button: require('gaffa-button'),
var x = '';
var b = browserify();
b.add(someModulePath);
b.bundle().pipe(through(function(chunk){
x+=chunk;
})).on('end', function(){
var result = eval(x);
// get what someModule exported.
});
@KoryNunn
KoryNunn / gist:ce1a15c4fc263cf2b762
Last active August 29, 2015 14:01
create a handler for (error, data...) passing in two handlers
function handle(successCallback, errorCallback){
if(!successCallback){
throw "You must provide a success callback";
}
return function(error){
if(error){
if(!errorCallback){
throw error;
}
@KoryNunn
KoryNunn / index.js
Created July 8, 2014 07:55
requirebin sketch
var WhatChanged = require('what-changed');
var state = new WhatChanged();
var change = state.update(1);
console.log(change);
var change = state.update(2);
@KoryNunn
KoryNunn / index.js
Created July 14, 2014 06:16
requirebin sketch
var crel = require('crel');
var select = crel('select',
crel('option', 'a'),
crel('option', 'b'),
crel('option', 'c')
),
message = crel('span', '<- should not be set, value is: ' + select.value);
select.value = null;
@KoryNunn
KoryNunn / gist:2e40f5bb64cb22a0f97a
Last active August 29, 2015 14:05
Things that don't work in mobile browsers

IOS

General

More than one request to the same domain at a time This kills long-poll.

Css

position: fixed; while the keyboard is open.