Skip to content

Instantly share code, notes, and snippets.

View rndme's full-sized avatar

dandavis rndme

View GitHub Profile
@rndme
rndme / gist:7187854975a8f53ebf54
Created October 12, 2014 07:14
count to 10 the iterative way
Object.keys(Object(Array(10)+0)).map(Number)
@rndme
rndme / gist:506f1a4f9f30890125d7
Created October 12, 2014 07:15
count to 10 the functional way
[].map.call( Array(10)+1, Function.call.bind(Number) )
@rndme
rndme / gist:3f3f8a959053921c6876
Created January 21, 2016 03:10
building classNames from values, like npm's ClassNames
function classes(){
return [].filter.call(arguments, Boolean).map(function(a){
return typeof a === "object" ?
(Array.isArray(a) ?
cn.apply(0,a) :
Object.keys(a).filter(function(k){return a[k];}).join(" ")) :
a;
}).filter(String).join(" ");
}
@rndme
rndme / gist:0badd138f9bda10de327
Created January 28, 2016 07:45
ES6 micro templater
var r=[
{url:"/Steel/Steel%20Band%20Music%20Of%20The%20Carribbean-09-Native%20Mambo.mp3",
name:"Steel Band Music Of The Carribbean-09-Native Mambo",src:"ZM3xplefSl"},
{url:"/Steel/Steel%20Band%20Music%20Of%20The%20Carribbean-08-Jungle.mp3",
name:"Steel Band Music Of The Carribbean-08-Jungle",src:"ZM3xplefSl"},
{url:"/Steel/Steel%20Band%20Music%20Of%20The%20Carribbean-07-LaPaloma.mp3",
name:"Steel Band Music Of The Carribbean-07-LaPaloma",src:"ZHdf478Dwd"},
{url:"/Steel/Steel%20Band%20Music%20Of%20The%20Carribbean-06-Zulu%20Chant.mp3",
name:"Steel Band Music Of The Carribbean-06-Zulu Chant",src:"ZM3xplefSl"},
{url:"/Steel/Steel%20Band%20Music%20Of%20The%20Carribbean-05-Spear%20Dance.mp3",
function isSorted(arr, fn){
return !arr.some(function(a,b,c){
if(!b) return;
return fn(a, c[b-1])!==1;
});
}
function ViewModel(rootElement){
rootElement = rootElement || document;
var model = Object.create(null);
function updateElement(elm){
var key = elm.getAttribute("bind"),
pre = elm.getAttribute("pre") || "",
var counter=1;
addEventListener("plus", function(e){
console.log(counter++);
});
dispatchEvent(new Event("plus"));
dispatchEvent(new Event("plus"));
dispatchEvent(new Event("plus"));
var screenShotDialog = document.createElement("DIALOG");
document.body.appendChild(screenShotDialog).innerHTML="Hello World";
screenShotDialog.showModal();
function cache(size, duration) {
// an object cache, where you can set max size or time or both, and it maintains shit for you, and quickly too
var index = {}, stack = [],
count = 0;
size = size || 100;
duration = duration || 1000 * 60 * 5;
function add(key, val) {
count++;
@rndme
rndme / gist:f7242b26df5aeebcfa62
Created February 23, 2016 08:27
list of path and values of a deep object
function survey(object) {
function scan(ob, p, x) {
var k, v;
for(k in ob) {
if(!ob.hasOwnProperty(k)) continue;
v=ob[k];
if(typeof v === "object" && v && !+v) {
scan(v, p + "." + k, x);
} else {