Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active July 15, 2024 20:29
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@wesbos
wesbos / download-shows.ts
Created November 11, 2020 02:07
deno syntax episode downloader
// deno run --allow-net --allow-write download-shows.ts
import { download } from "https://deno.land/x/download/mod.ts";
const showList = 'https://syntax.fm/api/shows';
async function getShowList(): Promise<Show[]> {
const list = await (await fetch(showList)).json();
return list;
}
@nmccready
nmccready / recurseRename.sh
Created August 7, 2020 13:55
recusive rename mult files
$ find . -name 'index.go' -type f -exec rename 's/index\.go/main\.go/' '{}' \;
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$MY_DIR"
cd ../ # normalize to a known working directory could be ../../
@nmccready
nmccready / arguments.sh
Created April 23, 2019 20:16
argument collector
#!/bin/sh
set -e
set -o pipefail
# collect arguments to forward on
while [[ "$#" > 0 ]]; do case $1 in
# example to save value
# -v|--data-volume) shift; dataVolume=$1;; # --data-volume someval
*) args[${#args[@]}]=$1;;
esac; shift; done
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active July 19, 2024 17:53
Conventional Commits Cheatsheet

Conventional Commit Messages

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@nmccready
nmccready / gitSubmodulesUnFuck.sh
Last active March 22, 2024 15:09
unfuck git submodules
rm -rf $@ && git checkout origin/master $@ && git submodule update --init
@mafintosh
mafintosh / bitcoin-for-laypeople.md
Last active April 1, 2020 12:46
Blog post about how Bitcoin works in a way non computer people can understand it

Bitcoin for laypeople

(Chinese version available here, courtesy of @jiangplus

(This is an English translation of my Danish blog post, Bitcoin for voksne)

Bitcoin is a digital currency that has no central authority. It's a currency where you do not have to rely on anyone to know it's worth it. As a concept, it's similar to gold. Gold has a value in itself, as opposed to, say a $100 note that only has value if the U.S. government says it has value. Similarly, the idea of ​​Bitcoins is that they have value by themselves.

Let's try to understand how Bitcoin works.

@nmccready
nmccready / emitter.js
Created August 16, 2017 21:38
emitter extension
var Promise = require('bluebird');
var EventEmitter = require('events');
function toPromise(emitterLike) {
return new Promise(function(resolve, reject) {
emitterLike.once('finish', resolve);
emitterLike.once('end', resolve);
emitterLike.once('close', resolve);
return emitterLike.once('error', reject);
});