Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@OliverJAsh
OliverJAsh / foo.js
Last active September 20, 2022 18:18
GitHub PR snippets
// Expand all collapsed commits
$$('.js-timeline-progressive-disclosure-button').forEach(el => el.click());
// Expand all collapsed conversations
$$('button')
.filter(el => el.innerText === 'Load more…')
.forEach(el => el.click());
@OliverJAsh
OliverJAsh / example.md
Created May 4, 2022 06:37
`intlc` example

Given this JSON + ICU Message:

{
  "uploaded": {
    "message": "Your <photoLink>photo</photoLink> has been uploaded.",
    "backend": "tsx"
  }
}
@OliverJAsh
OliverJAsh / foo.ts
Created April 26, 2022 07:39
`no-observable-pipe` ESLint rule
const { getTypeServices } = require('eslint-etc');
const {
ESLintUtils,
TSESTree,
TSESLint,
} = require('@typescript-eslint/experimental-utils');
const ruleCreator = ESLintUtils.RuleCreator(
(_name) =>
// This should be the URL of the docs for this rule, but since this is a custom/local rule, we
@OliverJAsh
OliverJAsh / README.md
Last active February 24, 2022 05:26
Flexbox gutters

Flexbox gutters

Problem

  • We use flexbox for our layout.
  • We want to add horizontal and vertical gutters inbetween these items.
  • Items wrap according to contents (flex-wrap: wrap), therefore we can't decide when/where to apply gutters using breakpoints.

Solution

@OliverJAsh
OliverJAsh / prettier-diff.sh
Created January 14, 2022 08:59
prettier-diff
#!/bin/bash
# Exit immediately if a command exits with a non-zero status, amongst other improvements
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -eux
#
# Example usage:
# ./prettier-diff.sh --no-index my-minified-file-before.js my-minified-file-after.js
#
@OliverJAsh
OliverJAsh / script.js
Last active January 14, 2022 11:39
webpack: list reasons why a given module was included (dependents)
// @ts-check
const treeify = require('treeify');
/**
* @param {import('webpack').StatsCompilation} stats
* @param {string | number} id
*/
const getModuleById = (stats, id) => stats.modules.find((module) => module.id === id);
@OliverJAsh
OliverJAsh / new-jsx-transform.js
Created January 14, 2022 08:51
Old vs new JSX transform
return (0, a.jsxs)(
ae.im,
{
id: s,
style: { marginLeft: -ve },
popoverProps: c,
children: [
(0, a.jsx)(
ae.xz,
{ showDropdownSymbol: !0, className: (0, ne.Bt)({}), children: t(d) },
@OliverJAsh
OliverJAsh / foo.js
Last active October 22, 2021 09:45
Async iterators with map, skipWhile, and takeUntil
class FunctifiedAsync {
constructor(iterable) {
this.iterable = iterable;
}
async *[Symbol.asyncIterator]() {
for await (const value of this.iterable) {
yield value;
}
}
import { pipe } from 'fp-ts/function';
import * as NonEmptyArray from 'fp-ts/NonEmptyArray';
import * as O from 'fp-ts/Option';
const runMain = () => {
require('./main');
};
const createTimeoutPromise = (timeout: number): Promise<void> =>
new Promise<void>((resolve) =>
@OliverJAsh
OliverJAsh / _git-merge-pr
Last active September 15, 2021 19:30
git-merge-pr
#compdef git-merge-pr
_git-merge-pr () {
# Multiple lines = -l
# compadd -l -d "('foo:a b c' 'bar:d e f')" foo bar
# lines=('foo:a b c' 'bar:d e f')
# compadd -l -d lines foo bar
# lines=('foo:a b c' 'bar:d e f')