Skip to content

Instantly share code, notes, and snippets.

View o0101's full-sized avatar
🏖️
Netscaping

Cris o0101

🏖️
Netscaping
View GitHub Profile
@o0101
o0101 / record format
Last active August 28, 2020 10:31
format
recordname:product-detail
repeatall:nextpage click:.nav-nxt-btn
name:string innerText:.name-prd
price:float innerText:.sale-price
pageuri:url attr:href:.detail-view-lnk
@o0101
o0101 / global_error_catcher.js
Created March 29, 2018 15:17
Add this 1 liner to your front end code to catch and display errors when debugging on mobile.
window.onerror = (m,u,l,c,e) => (alert(`Exception: ${m} @ ${u} line ${l} column ${c}\n${e ? e.stack : ''}`), true);
@o0101
o0101 / redact.js
Last active August 28, 2020 10:30
"use strict";
{
const forbidden = new Set(["Facebook", "Zuckerberg", "Trump", "alt-left", "Syria", "Trump's", "racist", "liberal", "alt-right"]);
const tw = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); const actions = [];
while( tw.nextNode() ) {
const text = tw.currentNode;
if ( text.parentElement.tagName !== 'SCRIPT' && text.parentElement.tagName !== 'STYLE' ) {
actions.push( () => redact( text, forbidden ));
}
}; actions.forEach( a => a() );
@o0101
o0101 / explanation.md
Created April 18, 2018 10:03
Switch Branch + Block Scope : ECMAScript

Block scope can be used in switch statements. It's sort of a nice syntax that allows you to defined same-named variables without getting 'already defined' errors.

The example is not so great because data could be rewritten to be let data; at the top of the function, rather than in each case block.

Blocking scoping is pretty useful.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@o0101
o0101 / racked.js
Created June 29, 2018 06:39
Better React - AKA REACT FUCK YOU - AKA RACT
/**
In react we do
function Component(props) {
return <h1> Hello, {props.name}</h1>;
}
**/
// in RACT, racked we do
"use strict";
{
const version = 'v1';
const service = 'olo-order-analytics';
const DEFAULT = Object.freeze({
TOP_COUNT : 20,
TIMEOUT: 15000
});
@o0101
o0101 / classchange.js
Last active July 27, 2018 12:31
'classchange' Event - with watchClassChange and addEventListener('classchange', ...)
"use strict";
{
const config = {attributes: true};
const observer = new MutationObserver(sendEvent);
const listDiff = new WeakMap();
Object.assign(self,{watchClassChange});
function sendEvent(attrChanges) {
attrChanges
#region Instructions
/*
* this as a secret gist:
* https://gist.github.com/dosyago-coder-0/83fd043e9f8e8f06fba95f93a8a1d6a4
*
*/
/*