Skip to content

Instantly share code, notes, and snippets.

View edankwan's full-sized avatar

Edan Kwan edankwan

View GitHub Profile
@edankwan
edankwan / poop.js
Last active August 29, 2015 14:15 — forked from elsassph/poop.js
Array.prototype.poop = function() {
this.pop();
// return nothing, it's poop
}
Array.prototype.shit = function() {
this.shift();
// return nothing, it's shit
}
@edankwan
edankwan / index.js
Created June 12, 2015 18:07
quick patch of glslify to accept api opts
var glslifyBundle = require('glslify-bundle')
var staticModule = require('static-module')
var glslifyDeps = require('glslify-deps')
var glslResolve = require('glsl-resolve')
var through = require('through2')
var nodeResolve = require('resolve')
var path = require('path')
var fs = require('fs')
module.exports = transform
@edankwan
edankwan / index.js
Created July 8, 2015 15:29
requirebin sketch
var raf = require('raf');
var mp = require('mouse-position');
var mpos = mp(window);
var undef;
var sumDeltaX = 0;
var libSumDeltaX = 0;
var curPageX;
var prevPageX;
@edankwan
edankwan / rAF.js
Created October 22, 2012 17:17 — forked from paulirish/rAF.js
Javascript - requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@edankwan
edankwan / reset.css
Created October 22, 2012 17:19
CSS: reset.css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@edankwan
edankwan / lzw_encoder.js
Created October 24, 2012 21:44 — forked from revolunet/lzw_encoder.js
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@edankwan
edankwan / build.js
Created October 26, 2012 15:00 — forked from millermedeiros/build.js
sample node.js build script including RequireJS optimizer (r.js) and copy/delete/filter files
// Combine JS and CSS files
// ---
//
// Make sure you install the npm dependencies
// > cd YOUR_PROJECT_FOLDER
// > npm install
//
// Than run:
// > node build
@edankwan
edankwan / poop.js
Created February 10, 2015 11:55
Array.prototype.poop()
(function(p, l){
var s = '';
function yolo(i) {
return function() {
return this.splice(this.length - i - 2);
};
}
@edankwan
edankwan / console.expand.js
Created January 29, 2013 15:38
A function to allow expanding the object/array in console. NOT working on dom elements or functions as I use JSON.stringify.
if (window.console && window.JSON) console.expand = function () {
var i, j;
var output = '';
var str = JSON.stringify(arguments);
var pos = 0;
var len = str.length;
var indent = ' ';
var newLine = '\n';
var char = '';
for (i = 0; i < len; i++) {
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());