Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / lcd2LineDisplay.ino
Created May 12, 2016 16:47
lcd2LineDisplay Function
void lcd2LineDisplay(String UpString, String DownString, int delaytime) {
//LiquidCrystal_I2C lcd(0x27, 16, 2); //Create a new LiquidCrystal_I2C object if one hasn't been globally created
//lcd.backlight(); //Turn on backlight everytime the function runs
lcd.clear();
delay(500);
lcd.setCursor(0, 0);
lcd.print(UpString);
lcd.setCursor(0, 1);
lcd.print(DownString);
@emmanuelnk
emmanuelnk / GitHub-Forking.md
Created November 9, 2017 03:25 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

Useful Git commands

This is just stuff that I have put down that I find I use a lot of the time for my own reference.

Latest changes from repo to your machine

$ git pull
# first install npx (https://github.com/zkat/npx)
npm install -g npx
# set your npm defaults if you havent already
npm set init.author.name "Your name"
npm set init.author.email "your@email.com"
npm set init.author.url "https://your-url.com"
npm set init.license "MIT"
@emmanuelnk
emmanuelnk / safePromiseAllHandler.js
Last active February 13, 2019 08:19
Handling the fast-fail behavior of Promise.all when using async/await
// TL,DR :
// here is a wrapper for PromiseAll that handles rejection and avoids fast fail behavior
const softPromiseAll = arr => {
return Promise.all(arr.map(
promise => new Promise(
resolve => promise.then(resolve).catch(resolve)
)
)).then(results => results)
}
@emmanuelnk
emmanuelnk / git_clean.bash
Created July 4, 2019 08:17
Git: Clean out branches merged to master branch from local git repository (without deleting master branch)
git branch --merged master | grep -v "\master" | xargs -n 1 git branch -d
@emmanuelnk
emmanuelnk / fizzbuzz_in_ES6.js
Last active August 1, 2019 09:46
FizzBuzz but with ES6!
const fizzbuzz = (min, max) => new Array(max-min+1)
.fill(0)
.map((f,i) => console.log(`${((i+1)%3 === 0) ? 'fizz' : ''}${((i+1)%5 === 0) ? 'buzz' : ''}` || i+1))
fizzbuzz(1, 100)
@emmanuelnk
emmanuelnk / timestampUpdate.js
Last active August 14, 2019 03:01
Recursively update all timestamps in a document to current timestamps based on when the document/fixture was created (Moment.js, Node.js)
// great for fixtures used in tests that need to stay up to date
// needs moment.js
const moment = require('moment')
const updateTimestamps = (entity, baseTimestamp, path = '', tsFields) => {
// usage: recusrively updates all Timestamps in a json fixture for tests
const nowTs = moment().clone().startOf('hour')
const diff = Math.abs(nowTs.diff(baseTimestamp, 'hours'))
@emmanuelnk
emmanuelnk / argument_parser.bash
Created November 21, 2019 03:12
Parse command-line arguments in bash easily
# ./my_script.sh --arg1 value1 --arg2 value2 --arg3 value3
# ./my_script.sh -a value1 -b value2 -c value3
#!/usr/bin/env bash
while [[ "$#" -gt 0 ]]; do case $1 in
-a|--arg1) var1="$2"; shift;;
-b|--arg2) var2="$2"; shift;;
-c|--arg3) var3="$2"; shift;;
*) echo "Unknown parameter passed: $1"; exit 1;;
esac; shift; done
@emmanuelnk
emmanuelnk / parse_dotenv.bash
Last active January 6, 2020 07:09 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)