Skip to content

Instantly share code, notes, and snippets.

View trickpattyFH20's full-sized avatar

Patrick trickpattyFH20

View GitHub Profile

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:

@trickpattyFH20
trickpattyFH20 / iamdisappoint.js
Last active April 18, 2017 14:51
iamdisappoint
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]);
"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];
@trickpattyFH20
trickpattyFH20 / js-observables-binding.md
Created May 17, 2017 23:03 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

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);

@trickpattyFH20
trickpattyFH20 / zeros.js
Last active June 23, 2017 08:38
splice zeros
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) {
@trickpattyFH20
trickpattyFH20 / loaders.js
Created September 14, 2017 20:21 — forked from rbellamy/loaders.js
webpack configuration
'use strict';
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
exports.tslint = {
test: /\.ts$/,
loader: 'tslint',
exclude: [
@trickpattyFH20
trickpattyFH20 / findShadows.js
Last active May 30, 2018 16:14
search dom for shadow roots
(() => {
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 / examples.md
Created February 1, 2023 14:00 — forked from ef4/examples.md
Webpack 5 Node Polyfills Upgrade Cheatsheet

Webpack 5 Node Polyfills Upgrade Cheatsheet

Webpack 4 automatically polyfilled many Node APIs in the browser. This was not a great system, because it could lead to surprisingly giant libraries getting pulled into your app by accident, and it gave you no control over the exact versions of the polyfills you were using.

So Webpack 5 removed this functionality. That means you need to make changes if you were relying on those polyfills. This is a quick reference for how to replace the most common patterns.

List of polyfill packages that were used in webpack 4

For each automatically-polyfilled node package name on the left, this shows the name of the NPM package that was used to polyfill it on the right. Under webpack 5 you can manually install these packages and use them via resolve.fallback.

@trickpattyFH20
trickpattyFH20 / amrating.js
Last active August 17, 2023 14:29
show total amazon review count
Array.from(document.querySelectorAll('[data-a-popover]')).forEach((el) => {
const itemJson = JSON.parse(el.dataset.aPopover);
const { url } = itemJson;
if (url && url.includes('review')) {
fetch(url)
.then((response) => response.text())
.then((html) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const reviewPopupClone = doc.cloneNode(true);
@trickpattyFH20
trickpattyFH20 / rearct-native-app-in-wsl2.md
Created August 1, 2024 06:17 — forked from bergmannjg/rearct-native-app-in-wsl2.md
Building a react native app in WSL2