Skip to content

Instantly share code, notes, and snippets.

View lencioni's full-sized avatar

Joe Lencioni lencioni

  • Airbnb
  • Northfield, Minnesota, USA
  • X @lencioni
View GitHub Profile
@lencioni
lencioni / COMMIT_EDITMSG
Created February 21, 2015 17:01
Tim Pope's model commit message
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
@lencioni
lencioni / waitUntilSettled.ts
Last active October 20, 2023 14:43
cy.waitUntilSettled()
/**
* We often run into a problem with functions that select DOM nodes like
* `cy.get`, where in between the `cy.get` call and the next item in the chain,
* the DOM element that `cy.get` found ends up being removed from the DOM. This
* can affect code as simple as:
*
* cy.get('button').click();
*
* When it fails sporadically, it uses the following error message:
*
@lencioni
lencioni / autocomplete.vim
Created November 17, 2014 17:17
UltiSnips and YouCompleteMe configuration
" YouCompleteMe and UltiSnips compatibility, with the helper of supertab
" (via http://stackoverflow.com/a/22253548/1626737)
let g:SuperTabDefaultCompletionType = '<C-n>'
let g:SuperTabCrMapping = 0
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:ycm_key_list_select_completion = ['<C-j>', '<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<C-p>', '<Up>']
@lencioni
lencioni / css-perf-metrics.csv
Created May 20, 2022 17:31
Comparison of perf metrics of various libraries
react-with-styles (control) Emotion Treat Linaria
Total Blocking Time (ms) 276 189 (-87) 122 (-154) 144 (-132)
JS bundle size (KiB) 666 677 (+11) 581 (-85) 596 (-70)
CSS bundle size (KiB) 8 8 (+0) 12 (+4) 13 (+5)
Update layout tree count 2.84 2.96 (+0.12) 2.00 (-0.84) 2.00 (-0.84)
Update layout tree duration (ms) 7,594 3,225 (-4,369) 3,313 (-4,281) 3,380 (-4,214)
Composite layers count 5.43 5.22 (-0.21) 4.05 (-1.38) 4.04 (-1.39)
Composite layers duration (ms) 660 379 (-281) 306 (-354) 292 (-368)
@lencioni
lencioni / tarjan.test.ts
Last active July 8, 2022 16:07
Tarjan's strongly connected components algorithm in TypeScript. Adapted from https://gist.github.com/chadhutchins/1440602
import { Graph, Vertex, Tarjan } from '../tarjan';
it('handles simple cases', () => {
const v0 = new Vertex('0');
const v1 = new Vertex('1');
const v2 = new Vertex('2');
v0.connections.add(v1);
v1.connections.add(v2);
@lencioni
lencioni / tsserverWithEventsPlugin.ts
Last active May 20, 2021 15:59
TypeScript Server Plugin with custom project event handler
import * as ts_module from 'typescript/lib/tsserverlibrary';
/** Log to the TS Server log */
function log(info: ts.server.PluginCreateInfo, message: string) {
info.project.projectService.logger.info(`[My TS Server Plugin] ${message}`);
}
// https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
export default function init({ typescript: ts }: { typescript: typeof ts_module }) {
return {
@lencioni
lencioni / pi.js
Created March 14, 2021 20:51
Calculate pi
// See "Unbounded Spigot Algorithms for the Digits of Pi," by Jeremy Gibbons,
// Math. Monthly, April 2006, pages 318-328.
// Adapted from https://gustavus.edu/mcs/max/pi/
let app;
let q = BigInt(1);
let r = BigInt(0);
let t = BigInt(1);
let k = BigInt(1);
@lencioni
lencioni / story.js
Created May 18, 2017 20:17
Building Storybook stories with allExamples.js
import { storiesOf, action } from '@kadira/storybook';
import { browserDLSExamples } from '../examples/allExamples';
import fixtures from '../examples/fixtures';
const { DLSExamples, DLSComponents } = browserDLSExamples();
Object.entries(DLSExamples).forEach(([name, examplesFunc]) => {
let story = storiesOf(name, module);
@lencioni
lencioni / find-nearly-empty-directories.sh
Created August 31, 2017 17:10
Script to help find nearly empty directories
#!/bin/sh
# Find directories that only contain a single .eslintrc file.
# Adapted from https://superuser.com/a/727070
# Enable double glob to find hidden files
shopt -s dotglob
# Loop through every subdirectory.
# Currently need to tweak this line and run it for every level of directory
@lencioni
lencioni / javascript.snippets
Last active May 28, 2020 20:03
module.exports snippet
snippet me "module.exports" b
module.exports = ${1:`!p snip.rv = ''.join(x.title() for x in re.sub('\.js$', '', snip.basename or 'ModuleName').split('_'))`};$0
endsnippet