Skip to content

Instantly share code, notes, and snippets.

Sam Artuso sam-artuso

Block or report user

Report or block sam-artuso

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sam-artuso
sam-artuso / test.js
Created Feb 14, 2017
How to unit test a promise deliberately designed to side-effect?
View test.js
// demo.js
function f() {
return Promise.resolve(true)
}
function g() {
Promise.resolve(true)
}
module.exports = { f, g }
@sam-artuso
sam-artuso / npm-yarn.md
Last active Feb 11, 2017
How I stopped myself typing npm instead of yarn
View npm-yarn.md

Yarn is the new fancy NPM client by Facebook. Compared to the good ol' npm command line client, Yarn is faster and provides by default what you can achieve with npm shrinkwrap. It's even got fancier output. Emojis apart, its output is more succinct than npm's, which spits out a lot of things I don't really want to know about.

After switching to Yarn I found out how much I rely on muscular memory when typing on my keyboard. I found myself typing by mistake npm install when I should've typed yarn add When this happens, the yarn.lock file stops reflecting what is installed in the node_modules/ directory.

My solution to this problem was to alias npm like below. This alias will check if yarn.lock exists, stop me and even tell me off.

npm='test -e yarn.lock && >&2 echo "yarn.lock found in current directory. Use yarn instead." || npm'
@sam-artuso
sam-artuso / setting-up-babel-nodemon.md
Last active Nov 12, 2019
Setting up Babel and nodemon
View setting-up-babel-nodemon.md

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
View knock-knock.sh
#!/bin/bash
foo='Follow the white rabbit.'
# sleep 3
sudo echo > /dev/tty1
for (( i=0; i<${#foo}; i++)); do
sudo echo -n "${foo:$i:1}" > /dev/tty1; sleep .1
done;
sudo echo > /dev/tty1
You can’t perform that action at this time.