Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / composing-software.md
Created April 8, 2020 09:11 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@emmanuelnk
emmanuelnk / master-javascript-interview.md
Created April 8, 2020 09:11 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
@emmanuelnk
emmanuelnk / README.md
Created April 17, 2020 07:36 — forked from boneskull/README.md
example of how to debug mocha v4 if hanging

Here's an example of how to debug Mocha v4 if it hangs.

Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).

If you run your test, you'll notice it hangs:

$ mocha test.js
@emmanuelnk
emmanuelnk / cleanEmpty.js
Created May 13, 2020 08:07
Clean js object by recursive removal of undefined, null, NaN and empty strings
// A SO answer to https://stackoverflow.com/questions/286141/remove-blank-attributes-from-an-object-in-javascript
// based off the recursive cleanEmpty function by @chickens.
// This one can also handle Date objects correctly
// and has a defaults list for values you want stripped.
const cleanEmpty = function(obj, defaults = [undefined, null, NaN, '']) {
if (defaults.includes(obj)) return
if (Array.isArray(obj))
return obj
@emmanuelnk
emmanuelnk / ui_select_widget.sh
Created August 12, 2020 16:00
Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#!/bin/bash
# CREDITS
# Author: Markus Geiger <mg@evolution515.net>
# Permission to copy and modify is granted under the Creative Commons Attribution 4.0 license
# Updated by Bluerayne: https://gist.github.com/blurayne/f63c5a8521c0eeab8e9afd8baa45c65e
# INSPIRED BY
# - https://serverfault.com/questions/144939/multi-select-menu-in-bash-script
# https://www.bughunter2k.de/blog/cursor-controlled-selectmenu-in-bash
@emmanuelnk
emmanuelnk / docker_docker_compose_non_root_install.md
Last active October 21, 2020 07:23
Install and use docker and docker-compose on Linux, Ubuntu without SUDO (NON-ROOT)

Are you tired of having to run docker as root? Well look no further, the solution is here. The instructions below were tested on Ubuntu 20.04

First, if you haven't already, install and enable docker:

    sudo apt update && sudo apt install docker.io --yes 
    sudo systemctl enable --now docker

Download latest docker compose (or replace latest in url with desired version number):

@emmanuelnk
emmanuelnk / docker-compose.yml
Created October 22, 2020 14:29 — forked from devzer01/docker-compose.yml
docker-compose mongodb
version: '3'
services:
database:
image: 'mongo'
container_name: 'my-mongo-container' # give your contatner a name
environment:
- MONGO_INITDB_DATABASE=your-database-name # database name you want to make
- MONGO_INITDB_ROOT_USERNAME=my-container-root-username # set your container root username
- MONGO_INITDB_ROOT_PASSWORD=secret # set your contatner root password
volumes:
@emmanuelnk
emmanuelnk / slack_fedora_install.sh
Created November 6, 2020 11:15
Install the latest version of Slack on Linux from the Terminal
# Fedora
# If you need an international version of Slack, use this URL:
# e.g. Korean:
# https://slack.com/intl/ko-kr/downloads/instructions/fedora
wget -q https://slack.com/downloads/instructions/fedora -O - \
| tr "\t\r\n'" ' "' \
| grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' \
| sed -e 's/^.*"\([^"]\+\)".*$/\1/g' \
@emmanuelnk
emmanuelnk / koa-context.ts
Last active June 7, 2022 16:32
Simple Koa Context for testing in Typescript (Mocha-chai, Jest) etc
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
// Ripped from https://github.com/koajs/koa/blob/master/test/helpers/context.js
// Solution courtesy of user @fl0w. See: https://github.com/koajs/koa/issues/999#issuecomment-309270599
// I've disabled type checking in this file but you are free to add types if you wish
// if you want more comprehensive Koa Context object to test stuff like Cookies etc
// then use https://www.npmjs.com/package/@shopify/jest-koa-mocks (requires Jest)
@emmanuelnk
emmanuelnk / getAmiID.ts
Created November 20, 2020 15:05
Get latest Amazon EC2 AMI image ID just like in the AWS EC2 quick launch console using Node.js
import * as AWS from "aws-sdk"
export const getAMIImageID = async(imageName: string): Promise<string | undefined> => {
AWS.config.update({ region: "us-west-2" })
const ec2 = new AWS.EC2()
// see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeImages-property
const params = {
Filters: [
{