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 / CONTRIBUTING.md
Created January 5, 2018 11:22
Nice contribution commit guidelines

Contributing Guidelines

Some basic conventions for contributing to this project.

General

Please make sure that there aren't existing pull requests attempting to address the issue mentioned. Likewise, please check for issues related to update, as someone else may be working on the issue in a branch or fork.

  • Non-trivial changes should be discussed in an issue first
  • Develop in a topic branch, not master
@jpwilliams
jpwilliams / Git Version Log.md
Last active November 30, 2017 16:49
Git Version Log

Useful (but shittily written) bash function to log out commits between given commit-ish values in a git repository.

Outputs a simple log that can be pasted into some GitHub markdown for a dirty changelog.

~/remit : gl 2.0.4
- 📦 fix(package): update eventemitter3 to version 3.0.0 (#60): 250143ab02f7cb7b40e370909d56303730999ee4
- 🔥 Kill old TODO comment: df7b922c1ae9b1908f9f60b1767775bb832b0c9d
- 🔀 Handler values (#62): c2d19d82cf407690bdafc0c88e0499c9faee7ecd
@jpwilliams
jpwilliams / client.js
Created October 19, 2017 13:58
HTTP2 services - ~4,000 req/sec (0.25ms per req)
const http2 = require('http2')
function makeReq (client) {
return new Promise((resolve, reject) => {
const req = client.request({':path': '/'})
let data = ''
req.setEncoding('utf8')
req.on('data', (d) => { data += d })
req.on('end', () => resolve(data))
@jpwilliams
jpwilliams / style.css
Created October 6, 2017 09:59
Mac system fonts in CSS
/* System Fonts as used by GitHub */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
/* System Fonts as used by Medium and WordPress */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
@jpwilliams
jpwilliams / bci.js
Created October 2, 2017 08:10
Binary Combination Identifier
// Use binary to display all possible combinations of n booleans.
function bci (n) {
const prefix = '0'.repeat(n)
for (let i = 0; i < 2**n; i++) {
console.log((prefix + i.toString(2)).slice(-n))
}
}
javascript:(function () {
if (typeof crugoSalesScript !== 'undefined') {
return;
}
socketIoScript = document.createElement('script');
socketIoScript.type = 'text/javascript';
socketIoScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.slim.js';
document.getElementsByTagName('head')[0].appendChild(socketIoScript);
@jpwilliams
jpwilliams / 1-README.md
Last active September 12, 2017 11:06
EventEmitter with a cache

StoreEmitter

A super-basic EventEmitter that helps track state across components by letting you follow events.

See the code below.

Usage

  • emit now caches values after each emission,
  • get retrieves the last value emitted for the given eventName,
@jpwilliams
jpwilliams / tree.md
Last active August 7, 2023 20:57
Tree using .gitignore

Uses tree along with a .gitignore file to filter results. Defaults to ignoring node_modules if no .gitignore can be found in the current directory or in the git repo's root directory.

Would be cooler if we knew exacty where .gitignore files made a difference. Even nicer if the output showed the status of files in Git (modified, unchanged, new, deleted etc).

Package?

@jpwilliams
jpwilliams / 0-readme.md
Last active September 19, 2017 23:08
EventEmitter that outputs data on emission

This isn't even really a fair benchmark (testing testing), as the hacky version does more than the proxy, but even without the benchmarks ended up within the same region.

The bottleneck for the Proxy is most definitely the Proxy itself; it ends up plateauing at ~1m ops/sec.

Past that, the next bottleneck is cloning the results array when returning emit. If we ignore the result there and return null, we end up getting around 8-9m ops/sec. Slicing with 0 index is the fastest solution I could find, but there may be ways around this where we create custom arrays for each emission.

@jpwilliams
jpwilliams / git-branch-merging.md
Last active August 3, 2017 13:12
Guide for pulling from->to git branches

Pulling the same branch

If you're pulling the same branch from origin (origin/develop -> develop):

git checkout develop
git fetch origin
git pull --no-commit --log --rebase origin develop