Skip to content

Instantly share code, notes, and snippets.

View jpwilliams's full-sized avatar
🟪
Building Inngest

Jack Williams jpwilliams

🟪
Building Inngest
View GitHub Profile
@jpwilliams
jpwilliams / tricks.md
Created July 31, 2017 16:20
Git Tricks

Reset file(s)/folder(s) to a specific commit

Directories are relative to the current directory.

git checkout c5f567 -- file1/to/restore file2/to/restore
git checkout c5f567 -- ./folder ../other/file.js

You can see what's changed in these specific places by using diff instead:

@jpwilliams
jpwilliams / Bouncer.js
Created March 31, 2017 10:44
"Bouncer" for temporarily "banning" things in-memory
function Bouncer () {
this.bans = {}
return this
}
Bouncer.prototype.ban = function ban (key, time) {
if (!key || !time) return
if (this.bans[key]) clearTimeout(this.bans[key])
this.bans[key] = setTimeout(this.unban.bind(this, key), time)
@jpwilliams
jpwilliams / valid-breaks.js
Last active March 16, 2017 10:22
Valid places to break chained and function calls
// Always break for args > 2
// All of the following are valid examples
// usual
myFunc(one, two)
// > 2 args
myFunc(
one,
two,
@jpwilliams
jpwilliams / glog.md
Last active March 16, 2017 09:19
Log recent git commits

Installation

# For realpath, gfind and emojify
brew install coreutils findutils emojify
echo "alias glog='~/glog.sh'" >> ~/.bashrc

Usage

@jpwilliams
jpwilliams / semver-prerelease.md
Created January 8, 2017 18:43
A good description of how to use Semver for major pre-release versions

TLDR

I have not seen prelease versions utilized pre-1.0.0. It seems fairly pointless since the public API is not finalized yet. They become useful after 1.0.0 is released.

So when are prelease versions useful?

From semver.org:

Version 1.0.0 defines the public API. The way in which the version number is incremented after this release is dependent on this public API and how it changes.

@jpwilliams
jpwilliams / EMPLOYER.md
Last active April 16, 2018 14:43
Versioned and revised ideas for how to run a good tech company.

EMPLOYER.md

Versioned and revised ideas for how to run a good tech company.

Edits can just be plain edited. Redactions must be turned into strikethrough and a comment added stating why the text/point is being removed.

Contents

@jpwilliams
jpwilliams / treeView.sh
Created December 12, 2016 16:18
List node.js apps all pretty, like
# Requires http://brewformulas.org/Tree
alias t="tree -I node_modules -C"
@jpwilliams
jpwilliams / increment-dates.js
Created December 9, 2016 14:33
Add methods to the Date class to allow incrementing and decrementing dates
var types = [
'Date',
'FullYear',
'Hours',
'Milliseconds',
'Minutes',
'Month',
'Seconds',
'UTCDate',
'UTCFullYear',
@jpwilliams
jpwilliams / scramble.js
Last active November 23, 2016 17:05
Scramble strings, retaining their readability. This is pointless.
function scramble (message) {
message = message || ''
var ret = ''
var re = /([a-zA-Z]+)|([^a-zA-Z]+)/g
var match
while (match = re.exec(message)) {
if (match[2]) {
ret += match[2]
@jpwilliams
jpwilliams / infiniteObject.js
Last active August 11, 2016 11:13
For if you ever wanted to do something insane and pointless.
function proxy () {
return new Proxy(function () {
return proxy()
}, {
apply (target, name) {
return proxy()
},
get (target, name) {
switch (name) {