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 / allExamples.js
Created May 18, 2017 20:17
Slurping up all examples and components with webpack
// Keep track of all DLS components:
const DLSComponents = {};
// Keep track of all DLS examples:
const DLSExamples = {};
function requireComponent(srcFile, requireFn) {
// Extract the component name from the file name:
let componentName = path.basename(srcFile, '.jsx');
// Handle ComponentName/index.jsx:
@lencioni
lencioni / Button_example.jsx
Last active May 18, 2017 20:57
Button example file
import React from 'react';
export default ({ Button }, { action, fixtures }) => ({
// Optional property that can be used to mark related components in Storybook
tags: ['tag1', 'tag2'],
// Optional property for some Markdown that will show up in the Usage tab in
// Storybook
usage: `
Button documentation in Markdown.
@lencioni
lencioni / AsyncComponent.jsx
Created January 8, 2017 17:09
<AsyncComponent> at Airbnb used for Webpack code splitting
// Usage:
//
// function loader() {
// return new Promise((resolve) => {
// if (process.env.LAZY_LOAD) {
// require.ensure([], (require) => {
// resolve(require('./SomeComponent').default);
// });
// }
// });
@lencioni
lencioni / find-dead-js-modules.sh
Last active June 26, 2017 18:51 — forked from trotzig/find-dead-js-modules.sh
This script will find javascript modules that aren't currently used in your application.
#!/bin/bash
# Make the script fail on the first error encountered.
set -euo pipefail
# Create a temp folder that we can use to store files in.
if [ "$(uname -s)" = "Darwin" ]; then
tmp_dir=$(mktemp -d -t find-dead-modules.XXXXXXXX)
else
tmp_dir=$(mktemp -d --tmpdir find-dead-modules.XXXXXXXX)
@lencioni
lencioni / countTests.sh
Last active May 31, 2016 21:37
Count the number of JavaScript tests in a git repo every day
#!/bin/bash
echo '"days ago","tests"' > testCounts.csv
for i in $(seq 1 365);
do
git checkout "$(git rev-list -n 1 --before="$i days ago" origin/master)"
matches=$(\
find spec/javascripts -name "*.js" -o -name "*.jsx" | \
@lencioni
lencioni / us-states-simplified.json
Last active March 9, 2018 19:30
US states without counties TopoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lencioni
lencioni / slow_reporter.js
Created July 18, 2015 18:14
Jasmine slow spec reporter
// A custom Jasmine reporter that logs slow specs.
const warnThresholdMs = 300;
const slowSpecsToPrint = 10;
function now() {
return (new Date()).getTime();
}
const slowReporter = {
@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 / 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 / gist:a96982de399985141fa1
Created November 16, 2014 17:29
Cricket wireless Nexus 5 setup
1.Tap Settings > Mobile Networks
(or Mobile Data) > Access Point Names > New APN (may have to tap
Menu button to see this option).
2.Enter the following APN info:
Name: Internet
APN: ndo
Proxy: Not Set
Port: Not Set
Username: Not Set
Password: Not Set