Skip to content

Instantly share code, notes, and snippets.

View sam-artuso's full-sized avatar
👨‍💻
Hacking away

Sam Artuso sam-artuso

👨‍💻
Hacking away
View GitHub Profile
@sam-artuso
sam-artuso / knock-knock.sh
Created July 25, 2016 22:31
Knock knock, Neo
#!/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
@sam-artuso
sam-artuso / setting-up-babel-nodemon.md
Last active November 3, 2023 08:52
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@sam-artuso
sam-artuso / npm-yarn.md
Last active February 11, 2017 20:02
How I stopped myself typing npm instead of yarn

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 / test.js
Created February 14, 2017 16:17
How to unit test a promise deliberately designed to side-effect?
// demo.js
function f() {
return Promise.resolve(true)
}
function g() {
Promise.resolve(true)
}
module.exports = { f, g }
// flatten a tree of arbitrary depth and complexity
class WalkableTree {
constructor(data) {
this.data = data
}
*[Symbol.iterator]() {
for (let value of this.data) {
if (Array.isArray(value)) {
import { type OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { httpFetchJson } from '@recharge/http';
import tracer from 'dd-trace';
import { AkeneoConfigService } from '../config/akeneo-config.service';
import { type AkeneoAuthenticationResponse } from './entity/akeneo-token-entity';
const refreshTokenDefaultExpiry = 1209600;