Skip to content

Instantly share code, notes, and snippets.

View alanorozco's full-sized avatar
🗣️

Alan Orozco alanorozco

🗣️
View GitHub Profile
@alanorozco
alanorozco / 0-bundle-size-optimize-obj-str.md
Last active February 12, 2021 21:21
Bundle size using babel-plugin-optimize-obj-str

Using property names 5 to 40 characters long, all referencing two char variable names.

import objstr from "obj-str";
console.log(
  objstr({
    CirDiGpLiuNCMPWVTYnPIbViZiSisMRFNvelzQOT: Q,
    hFBvaSqKZ: P,
    hAwBFwnSSJUPIQkcl: D,
 eQSqFrCBzouDXpUOcimNM: W,
@alanorozco
alanorozco / _README.md
Last active December 12, 2020 02:17
Utilitarian Golf ⛳️
@alanorozco
alanorozco / universal-lit-html.md
Last active June 15, 2019 00:31
Universal `lit-html` two-way aliasing hack

Universal lit-html two-way aliasing hack

This allows running lit-html templates on both a browser and a node context.

Unlike other techniques that may use dependency injection, this makes all the exported units from the lit-html module available directly on the importing module context, so you can write code like:

import {html} from 'lit-html';
@alanorozco
alanorozco / deploy.sh
Created March 8, 2019 08:23
deploy.sh
#!/bin/bash
HOST=_@ssh._.com
PUBLIC=/home/public/
source ~/.nvm/nvm.sh
nvm use default
mkdir -p build
[alias]
a = add
b = branch
c = commit
co = checkout
current = symbolic-ref --short HEAD
d = diff
exclude = "!printf \"%s\\n\" >> .git/info/exclude"
hulksmash = push --force-with-lease
l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
@alanorozco
alanorozco / gif.sh
Last active February 27, 2019 01:21
gif.sh
#!/bin/bash
# Turns videos into gifs
# ======================
# Requires homebrew.
# Usage:
# gif MY.mp4 [(--fps|-f)=25 (--max_colors|-c)=128 (--output|-o)=MY.gif]
red () { echo -e $'\e[1;91m'"$@"$'\e[0m'; }
brew_quite_read () { HOMEBREW_NO_AUTO_UPDATE=1 brew "$@" > /dev/null 2>&1; }
@alanorozco
alanorozco / index.html
Created February 23, 2019 16:49
innerHTML (html) vs cloneNode (cachedHtml) (http://jsbench.github.io/#2d8f12d08697776b66b1cc131e6e506e) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>innerHTML (html) vs cloneNode (cachedHtml)</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@alanorozco
alanorozco / restrictedFxTypesBlownUp.js
Last active February 20, 2019 18:50
Restricted FX Types, symmetric, repeated
// Large, complete
const restrictedFxTypes = {
[FxType.PARALLAX]: [
FxType.FLY_IN_TOP,
FxType.FLY_IN_BOTTOM,
FxType.FLOAT_IN_BOTTOM,
FxType.FLOAT_IN_TOP,
],
[FxType.FLY_IN_TOP]: [
FxType.PARALLAX,
@alanorozco
alanorozco / restrictedFxTypes.csv
Last active February 20, 2019 18:51
Symmetric matrix of restricted amp-fx types
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 10 columns, instead of 4 in line 7.
,FADE_IN,FADE_IN_SCROLL,FLOAT_IN_BOTTOM,FLOAT_IN_TOP,FLY_IN_BOTTOM,FLY_IN_LEFT,FLY_IN_RIGHT,FLY_IN_TOP,PARALLAX
FADE_IN,////////////////////////////////,X,,X,X,,,,
FADE_IN_SCROLL,////////////////////////////////,////////////////////////////////,,X,X,,,,
FLOAT_IN_BOTTOM,////////////////////////////////,////////////////////////////////,////////////////////////////////,X,X,X,X,X,X
FLOAT_IN_TOP,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,X,X,X,X,X
FLY_IN_BOTTOM,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,,,X,X
FLY_IN_LEFT,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,////////////////////////////////,X,,
FLY_IN_RIGHT,////////////////////////////////,////////////////////////////////,//////////
@alanorozco
alanorozco / index.html
Last active February 14, 2019 21:16
innerHTML (html) vs cloneNode (cachedHtml) (http://jsbench.github.io/#c7cf6f598b80392bf4f42c932f703fcd) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>innerHTML (html) vs cloneNode (cachedHtml)</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>