Skip to content

Instantly share code, notes, and snippets.

@trickpattyFH20
trickpattyFH20 / findShadows.js
Last active May 30, 2018
search dom for shadow roots
View findShadows.js
(() => {
function walkDom(node, func) {
var children = node.childNodes;
for (var i = 0; i < children.length; i++) {
walkDom(children[i], func);
}
func(node);
}
walkDom(document.body, (node) => {
if (node.shadowRoot) {
@trickpattyFH20
trickpattyFH20 / loaders.js
Created Sep 14, 2017 — forked from rbellamy/loaders.js
webpack configuration
View loaders.js
'use strict';
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
exports.tslint = {
test: /\.ts$/,
loader: 'tslint',
exclude: [
View zeros.js
var a = [0, 0, 1, 0, 2, 3, 0, 4, 0, 5];
var idx;
function findIdx() {
idx = a.indexOf(0);
return idx;
}
while (findIdx() !== -1) {
View js-observables-binding.md

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5
setN(10);
View gist:7a907a2a24a7a4341f6f8bd953333855
"use strict";
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite
.add('for', function() {
const a = [1, 2, 3];
const b = [4, 5, 6];
View iamdisappoint.js
console.error = (function() {
const cached_function = console.error;
return function(...args) {
cached_function('%c ',
`background-image: url("http://goo.gl/UBH9ZT");
background-repeat: no-repeat;
background-size: 40px, auto;
font-size: 40px`
);
cached_function.apply(console, [...args]);
View keybase.md

Keybase proof

I hereby claim:

  • I am trickpattyfh20 on github.
  • I am trickpatty (https://keybase.io/trickpatty) on keybase.
  • I have a public key ASBoswRiuxXfg8WN2oO8JwI5aDEVOIih5JL00ABLVG3wqwo

To claim this, I am signing this object: