Skip to content

Instantly share code, notes, and snippets.

View domfarolino's full-sized avatar

Dominic Farolino domfarolino

View GitHub Profile
:host {
font-family: sans-serif;
}
div.card {
width: 100%;
max-width: 300px;
display: inline-block;
box-shadow: 0px 1px 3px rgba(0, 0, 0, .6);
margin: 10px;
<link rel="stylesheet" href="styles.css"> <!-- For the daring (Chrome 54+) -->
<div class="card">
<slot name="card-header">Fallback Header</slot>
<slot name="card-body">Fallback card-body text</slot>
<p class="card-footer">
Written by <slot name="card-author"></slot>
</p>
</div>
class CoolButton extends HTMLButtonElement {
constructor() {
super(); // must call as usual
}
connectedCallback() {
this.addEventListener('click', this._onClick);
// Woohoo, we've been connected
}
@domfarolino
domfarolino / forEachObject.js
Created December 12, 2016 21:17
Demonstrating how Array.prototype.forEach(...) works by using it on Objects
Object.prototype["0"] = "test0";
let obj = {"1": "test1", "2": "test2"};
for (let k in obj) console.log(k); // 1, 2, 0
Object.defineProperty(obj, 'length', {
value: 3,
enumerable: false,
writable: true,
configurable: false
/usr/bin/notify-send --app-name=Ok "Dom Farolino is lit"
/usr/local/bin/terminal-notifier -title Mozilla Build System -group mozbuild -message Build complete
-- Customer relation (strong entity)
CREATE TABLE domfarolino.customer, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL
(
custID int NOT NULL,
custName char(25)
)
UNIQUE PRIMARY INDEX(custID);
-- Technician relation (strong entity)
CREATE TABLE domfarolino.technician, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL
@domfarolino
domfarolino / meta.html
Created June 5, 2017 21:28
The classic meta tag I always forget how to write
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
@domfarolino
domfarolino / syncTimer.js
Created April 3, 2018 06:50
Synchronous timer in JavaScript
/**
* I often find myself needing a synchronous timer
* in JavaScript to test various browser things so here
* is a canonical timer that can be used so I don't have to
* keep trying to remember "What was that static function I
* was using on the Date class again?"
*/
end = Date.now() + 3000;
while (Date.now() < end) {}
console.log("3 seconds later :)")
<h1>Hello</h1>
<script>
fetch("extra.metadata")
fetch("non-important.metadata")
fetch("superfluous.metadata")
// imagine like 20 of these, all "high" in priority
</script>
<!-- This represents some content, making the script
appearing below it "late" which gets "medium" priority
@domfarolino
domfarolino / 01-Explainer.md
Last active May 16, 2018 08:23
Priority Hints importance=high benefit on HTTP 1.0-1.1

Explainer

Site: http://159.89.227.14/

What happens without priority hints is:

  • All 7 requests are made at low priority
  • When layout is done, all (that aren't finished yet) re-prioritize to high priority (in-viewport).
  • Since a max of 6 connections are allowed to be made, the first 6 are fetched right away. 7th is queued & stalled until one of the previously-made connections is free/done and we can allocate one for the last image.