Skip to content

Instantly share code, notes, and snippets.

Justin Bennett zephraph

View GitHub Profile
@zephraph
zephraph / implicit_return_component.jsx
Last active Jan 29, 2020
Example of component with implicit return
View implicit_return_component.jsx
// Don't allow this
export const ArrowComponent = () => (
<div>
<h1>My special implicit arrow function</h1>
</div>
)
// This is okay
export const SimpleComponent = () => <h1>This is fine</h1>
View webpack-config-timing.md
repeat
5

Baseline

yarn webpack
@zephraph
zephraph / npm-canary.md
Last active Dec 6, 2019 — forked from schmich/npm-prerelease.md
Publish a canary package on NPM
View npm-canary.md
  • Update package.json, set version to a canary version, e.g. 2.0.0-canary-<PR#>, 3.1.5-canary-<PR#>, ...
  • Run npm publish --tag canary to publish the package under the canary tag
  • Run yarn add @artsy/reaction@canary to install canary package

Running npm dist-tag ls can be helpful to see what tagged packages are available

@zephraph
zephraph / github-event-router.ts
Created Oct 25, 2019
A ziet now router for github webhooks
View github-event-router.ts
import { NowRequest, NowResponse } from "@now/node";
import { http, https } from "follow-redirects";
import { URL } from "url";
export = (request: NowRequest, response: NowResponse) => {
console.log(request.headers);
const event = request.headers["x-github-event"];
if (!event) return response.status(404).end();
const url = new URL(`https://${request.headers.host}/${request.url}`);
@zephraph
zephraph / color-test.js
Created Jul 3, 2019
Test color algorithms
View color-test.js
// uses mocha
const { rgb } = require("wcag-contrast");
const fromHex = require("@fantasy-color/from-hex").default;
const fs = require("fs");
const assert = require("assert");
const parsedColors = fs
.readFileSync(__dirname + "/../parsed-colors.txt")
.toString()
.split("\n")
@zephraph
zephraph / parse-colors.js
Last active Jul 3, 2019
Parsed GitHub label colors
View parse-colors.js
const fs = require("fs");
const fromRGB = require("@fantasy-color/from-rgb").default;
const hex = color => color.toString(16).padStart(2, "0");
const rgbToHex = rgb => {
const { red, green, blue } = fromRGB(rgb);
return `#${hex(red)}${hex(green)}${hex(blue)}`;
};
const colors = fs
@zephraph
zephraph / fetch-colors.js
Last active Jul 3, 2019
Github label color scrape
View fetch-colors.js
// Uses wdio to run
const fs = require("fs");
const colors = fs
.readFileSync("./colors.txt")
.toString()
.split("\n");
const pages = colors.map(color => `https://github.com/zephraph/test/labels/preview/TEXT?color=${color.slice(1)}`);
@zephraph
zephraph / colors.txt
Created Jul 3, 2019
Color test range
View colors.txt
#000000
#000f17
#001e1c
#002b00
#0037ca
#004473
#005160
#005e53
#006b3d
#007800
@zephraph
zephraph / clean_node_modules.sh
Last active Apr 1, 2020
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
View clean_node_modules.sh
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
View SketchSystems.spec
TabTimerState
NotStarted
tabActivated -> SetTimer
TabTimerTicking
tabDeactivated -> TimerPaused
timerExpired -> TimerWaitingToReset
timerReset -> TabTimerTicking
deactivateTimers -> NotStarted
TimerPaused
tabActivated -> TabTimerTicking
You can’t perform that action at this time.