Based on the youtube video How to Undo Mistakes in Git
As a rule of thumb, each commit should have only ONE topic.
$ git diff | /** | |
| * box - turns a value into an array, is nill returns []. | |
| * @param {*} value - some value. | |
| * @return {*[]} | |
| */ | |
| const box = value => { | |
| // already boxed... | |
| if ( Array.isArray(value) ) { | |
| return value; | |
| } |
| const OpaqueWrapper = ({ children }) => ( | |
| children && ( | |
| <Wrapper> | |
| {React.Children.map(children, child => ( | |
| React.cloneElement(child, {style: {...child.props.style, opacity: 0.5}}) | |
| ))} | |
| </Wrapper> | |
| ) | |
| ); |
Based on the youtube video How to Undo Mistakes in Git
As a rule of thumb, each commit should have only ONE topic.
$ git diff cd into the project folder locally, and initialize it git initgit add *git commit -m "My initial commit"git remote add origin git@bitbucket.org:[user]/[my-repo].gitgit push -u origin master| $ # -------------- | |
| $ # How to read a .env file into the current shell, as environment variables. | |
| $ # -------------- | |
| $ export $(egrep -v '^#' .env | xargs) |
| /** | |
| * if you have to support older versions of Express, here is an | |
| * example of working with Async / Await in the controller ( old school ). | |
| **/ | |
| const actionController = function actionController(req, res, next) { | |
| // build async IIFE, returning it. | |
| return (async function asyncActionController() { | |
| try { | |
| // await for a promise, etc. | |
| return res.status(201).json({msg:'hello'}); |
| const Promise = require('bluebird'); | |
| // Just for the record, you should avoid this pattern. | |
| // --------------------------------------------------- | |
| // 1.) it is hard to understand | |
| // 2.) It uses nested promises, which is an anti pattern. | |
| // | |
| (async () => { | |
| return Promise.resolve() | |
| .then(()=>{ |
| #!/usr/bin/env node | |
| /** | |
| * get the CLI arguments | |
| **/ | |
| const [ , , ...args] = process.argv; | |
| console.log(`args=${args}`); | |
| require( 'fs' ).writeFileSync( `${path.join(__dirname,path.basename(__filename,'.js'))}.pid`, process.pid.toString(), { encoding: 'utf-8' } ) |
| /** | |
| * Clean a String of invalid characters - remove all ASCII chars outside of 0-127 | |
| **/ | |
| const cleanString = (input) => { | |
| let output = ""; | |
| for (let i=0; i<input.length; i++) { | |
| if (input.charCodeAt(i) <= 127) { | |
| output += input.charAt(i); | |
| } | |
| } |