Skip to content

Instantly share code, notes, and snippets.

View JamieMason's full-sized avatar

Jamie Mason JamieMason

View GitHub Profile
@JamieMason
JamieMason / get-all-assignees-of-github-milestone.md
Created July 4, 2018 10:13
List all assignees of a GitHub Milestone

List all assignees of a GitHub Milestone

  1. Visit the milestone at eg. https://github.com/USER/REPO/milestone/1
  2. Run this in your console
    [...document.querySelectorAll('.from-avatar')].map(el => el.getAttribute('alt'))
  3. An array of GitHub usernames will be logged.
@JamieMason
JamieMason / lerna-list-peer-dependencies.md
Created July 4, 2018 09:36
List all peerDependencies for packages in a Lerna Monorepo

List all peerDependencies for packages in a Lerna Monorepo

System Requirements

brew install jq
npm install -g glob-exec

Usage

@JamieMason
JamieMason / npm-exact-versions.js
Created May 3, 2018 13:44
Replace semver ranges with exact version numbers in package.json files
const childProcess = require('child_process');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const filePaths = glob
.sync('package.json')
.concat(glob.sync('packages/*/package.json'))
.map(filePath => path.resolve(process.cwd(), filePath));
@JamieMason
JamieMason / find-recently-changed-npm-dependencies.js
Last active January 12, 2018 14:19
Find recently changed npm dependencies
const exec = require('child_process').exec;
const sortBy = (key, reverse) => {
const moveSmaller = reverse ? 1 : -1;
const moveLarger = reverse ? -1 : 1;
return (a, b) => {
if (a[key] < b[key]) {
return moveSmaller;
}
if (a[key] > b[key]) {
function Maybe(x) {
if (this instanceof Maybe === false) {
return new Maybe(x);
}
this.value = x;
}
Maybe.prototype.map = fn => (this.value == null ? this : new Maybe(fn(this.value)));
function Either(left, right) {
@JamieMason
JamieMason / log.js
Created November 14, 2017 11:18
Coloured log.info, log.warning, log.verbose, log.error for Node.js using https://github.com/chalk/chalk
import chalk from 'chalk';
export const info = message => console.log(chalk.blue('i %s'), message);
export const warning = message => console.log(chalk.yellow('! %s'), message);
export const error = message => err =>
console.log(chalk.red('! %s\n\n! %s'), message, String(err.stack).replace(/^/gm, ' '));
export const verbose =
@JamieMason
JamieMason / vs-code.sh
Last active May 5, 2022 07:35
Install favourite VS Code Extensions
code --install-extension akamud.vscode-caniuse && \
code --install-extension andys8.jest-snippets && \
code --install-extension auiworks.amvim && \
code --install-extension bibhasdn.unique-lines && \
code --install-extension christian-kohler.npm-intellisense && \
code --install-extension cssho.vscode-svgviewer && \
code --install-extension dbaeumer.vscode-eslint && \
code --install-extension dzannotti.vscode-babel-coloring && \
code --install-extension eamodio.gitlens && \
code --install-extension eg2.tslint && \
@JamieMason
JamieMason / es6-partial-application.md
Last active September 19, 2020 20:41
ES6 Partial Application in 3 Lines

ES6 Partial Application in 3 Lines

const pApply = (fn, ...cache) => (...args) => {
  const all = cache.concat(args);
  return all.length >= fn.length ? fn(...all) : pApply(fn, ...all);
};

Example

@JamieMason
JamieMason / show-attribute-values.js
Last active June 4, 2018 17:10
bookmarklet to highlight HTML attribute values with CSS
/*
* turn this into a bookmarklet using https://mrcoles.com/bookmarklet/
*/
(function() {
var colors = {
'data-content-id': '#cddc39',
'data-test-id': '#4dd0e1',
default: '#fff176'
};
function showAttribute(attrName) {
@JamieMason
JamieMason / parse-url.md
Last active February 25, 2019 02:48
An easy way to parse URLs in old Browsers is to use this trick with an <a> Element

Parse a URL using an <a> Element

const parseUrl = url => {
  const a = document.createElement('a');
  a.href = url;
  return {
    hash: a.hash,
    host: a.host,
 hostname: a.hostname,