Skip to content

Instantly share code, notes, and snippets.

View quantizor's full-sized avatar
🦾
👁️👄👁️

Evan Jacobs quantizor

🦾
👁️👄👁️
View GitHub Profile
@quantizor
quantizor / Home.js
Last active March 25, 2018 19:32
Buttermilk Holistic Example
export default () => "Home";
@quantizor
quantizor / svgEmbed.js
Last active February 22, 2018 17:03
SVG -> Data URI for CSS embedding
function prepareSVGAsDataURI(rawSVG) {
const prefix = 'data:image/svg+xml,';
let svg = encodeURIComponent(rawSVG.replace(/\n+/g, ''));
// restore ASCII-safe characters
svg = svg.replace(/%20/g, ' '); // spaces
svg = svg.replace(/%3D/g, '='); // equal signs
svg = svg.replace(/%3A/g, ':'); // colons
svg = svg.replace(/%2F/g, '/'); // slashes
@quantizor
quantizor / server.js
Created February 16, 2018 17:31
Isomorphic webpack HMR
/**
* initial setup:
*
* npm i babel-register chalk compression express lodash node-persist openport react-dev-utils@~0.5.2 webpack webpack-dev-middleware webpack-hot-middleware
*/
import 'babel-register';
import chalk from 'chalk';
import compression from 'compression';
@quantizor
quantizor / events.json
Last active February 14, 2018 04:19
example profiling plugin gist
This file has been truncated, but you can view the full file.
[{"ts":369004336107,"pid":49314,"tid":49314,"ph":"I","name":"TracingStartedInPage","id":1,"cat":"disabled-by-default-devtools.timeline","args":{"data":{"sessionId":"-1","page":"0xfff","frames":[{"frame":"0xfff","url":"webpack","name":""}]}}},
{"ts":369004336197,"pid":49314,"tid":49314,"ph":"I","name":"TracingStartedInBrowser","id":2,"cat":"disabled-by-default-devtools.timeline","args":{"data":{"sessionId":"-1"}}},
{"ts":369004405590,"pid":49314,"tid":49314,"ph":"b","name":"EntryOptionPlugin","id":3,"cat":"blink.user_timing"},
{"ts":369004405891,"pid":49314,"tid":49314,"ph":"e","name":"EntryOptionPlugin","id":3,"cat":"blink.user_timing"},
{"ts":369004606717,"pid":49314,"tid":49314,"ph":"b","name":"NodeSourcePlugin","id":4,"cat":"blink.user_timing"},
{"ts":369004606945,"pid":49314,"tid":49314,"ph":"e","name":"NodeSourcePlugin","id":4,"cat":"blink.user_timing"},
{"ts":369004606963,"pid":49314,"tid":49314,"ph":"b","name":"AMDPlugin","id":5,"cat":"blink.user_timing"},
{"ts":369004607020,"pid":49314,"tid":49314,"ph
@quantizor
quantizor / events.json
Created January 28, 2018 02:16
example profiling plugin gist
This file has been truncated, but you can view the full file.
[{"ts":210342517955,"pid":84888,"tid":84888,"ph":"I","name":"TracingStartedInPage","id":1,"cat":"disabled-by-default-devtools.timeline","args":{"data":{"sessionId":"-1","page":"0xfff","frames":[{"frame":"0xfff","url":"webpack","name":""}]}}},
{"ts":210342518021,"pid":84888,"tid":84888,"ph":"I","name":"TracingStartedInBrowser","id":2,"cat":"disabled-by-default-devtools.timeline","args":{"data":{"sessionId":"-1"}}},
{"ts":210342596877,"pid":84888,"tid":84888,"ph":"b","name":"EntryOptionPlugin","id":3,"cat":"blink.user_timing"},
{"ts":210342597223,"pid":84888,"tid":84888,"ph":"e","name":"EntryOptionPlugin","id":3,"cat":"blink.user_timing"},
{"ts":210342786095,"pid":84888,"tid":84888,"ph":"b","name":"NodeSourcePlugin","id":4,"cat":"blink.user_timing"},
{"ts":210342786350,"pid":84888,"tid":84888,"ph":"e","name":"NodeSourcePlugin","id":4,"cat":"blink.user_timing"},
{"ts":210342786357,"pid":84888,"tid":84888,"ph":"b","name":"AMDPlugin","id":5,"cat":"blink.user_timing"},
{"ts":210342786418,"pid":84888,"tid":84888,"ph

Notes

A loop isn't needed here at all. Just tail call parseDeclarationFlags as needed to replay the logic.

function parseDeclarationFlags(): StatementFlags {
    switch (token) {
        case SyntaxKind.VarKeyword:
@quantizor
quantizor / blah.js
Created January 10, 2017 21:27
JS to get the slack emoji contributors by handle
/* Execute this on https://{your-team}.slack.com/customize */
Array.from(document.querySelectorAll('.emoji_row a[href^="/team"]')).reduce((counts, node) => {const name = node.getAttribute('href').slice(6);return (counts[name] = (counts[name] || 0) + 1), counts}, {});
@quantizor
quantizor / elastic_cheat_sheet.md
Last active January 6, 2017 00:42
Elastic Cheat Sheet
@quantizor
quantizor / elasticsearch-bulk-ingestion.md
Last active December 27, 2016 17:57
ElasticSearch Bulk Ingestion Tips

ElasticSearch Bulk Ingestion Tips

Change the IPs to the cluster's master node (has a star next to the name in kibana.) Most of the suggestions below come from the official Elastic ingestion performance guidelines.

Before starting

Disables throttling of segment merges in Lucene.

If you are doing a bulk import and don’t care about search at all, you can disable merge throttling entirely. This will allow indexing to run as fast as your disks will allow.

@quantizor
quantizor / keybase.md
Created December 12, 2016 17:03
Keybase Proof

Keybase proof

I hereby claim:

  • I am yaycmyk on github.
  • I am glitterbyte (https://keybase.io/glitterbyte) on keybase.
  • I have a public key ASCA4vHIMvP3KeypJPEbAUcO1nFRCFuOwAbSBvSdK5OUBwo

To claim this, I am signing this object: