Skip to content

Instantly share code, notes, and snippets.

View kasperlewau's full-sized avatar

Kasper Lewau kasperlewau

View GitHub Profile
@kasperlewau
kasperlewau / index.js
Last active May 22, 2017 10:13
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const HyperList = require('hyperlist')
const root = document.createElement('div')
const data = ['a', 'b', 'c', 'd']
const conf = {
height: 160,
@kasperlewau
kasperlewau / index.js
Created May 22, 2017 10:03
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const HyperList = require('hyperlist')
const root = document.createElement('div')
const data = ['a', 'b', 'c', 'd']
const conf = {
height: 160,
@kasperlewau
kasperlewau / esdoc-ngclasslist-plugin.js
Created June 9, 2016 13:12
primitive AST modifier for export default function + class declaration
exports.onHandleAST = function (ev) {
/**
* The topmost body of the given AST.
*/
var outerBody = ev.data.ast.body;
/**
* If the file is empty, return early.
*/
if (outerBody.length === 0) {
@kasperlewau
kasperlewau / functional-utils.js
Created April 7, 2016 18:47 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@kasperlewau
kasperlewau / idleDigest.js
Created February 17, 2016 08:42
angular snippets
/**
* Pass rootElement ($0), and rounds. Default amount of rounds is 1000.
*
* Don't bump it up to say a million rounds over a set of 5000 watchers, it will take a *long* time.
*/
function idleDigestTime (root, rounds) {
var results = [];
angular.element(root).injector().invoke(function ($rootScope) {
@kasperlewau
kasperlewau / counter.js
Created January 29, 2016 14:35
angular watch count
/**
* getWatchers().length - all the watchers on your page
* getWatchers($0).length - all the watchers within your selected element
*/
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
@kasperlewau
kasperlewau / Brewfile
Last active January 9, 2016 13:09
Brewfile
tap phinze/cask
tap caskroom/versions
tap KevinSjoberg/formulas
install brew-cask
install git
# install node
install imagemagick
install m
install n
/**
* Directive, '@' properties isolate scope, not passing any values.
* commit: https://github.com/angular/angular.js/pull/11628/files
*/
var obj = { fbHref: undefined, fbLayout: undefined, fbAction: undefined, fbShowFaces: undefined, fbShare: undefined };
var keys = Object.keys(obj);
# 1.4.2
LOG: 'obj.keys', ['fbHref', 'fbLayout', 'fbAction', 'fbShowFaces', 'fbShare']
@kasperlewau
kasperlewau / lazy.module.js
Last active August 29, 2015 14:19
ui-sref-lazy lazy module
/** lazy module **/
function config ($stateProvider) {
$stateProvider.state('root.about', {
url: '/about'
});
});
export default angular
.module('lazyModule', ['ui.router'])
.config(config);
@kasperlewau
kasperlewau / app.js
Created April 14, 2015 10:18
ui-sref-active lazy
import { default as stateMachine } from './stateMachine';
var internalDeps = [ ];
var thirdPartyDeps = [ 'ui.router', 'oc.lazyLoad' ];
function config ($locationProvider, $stateProvider) {
$stateProvider.state('root', {
url: '',
abstract: true,
});