Open ~/.bash_profile
in your favorite editor and add the following content to the bottom.
# Git branch in prompt.
parse_git_branch() {
/** | |
* Performs a deep merge of `source` into `target`. | |
* Mutates `target` only but not its objects and arrays. | |
* | |
* @author inspired by [jhildenbiddle](https://stackoverflow.com/a/48218209). | |
*/ | |
function mergeDeep(target, source) { | |
const isObject = (obj) => obj && typeof obj === 'object'; | |
if (!isObject(target) || !isObject(source)) { |
// You can find the last commit which deleted file as follows: | |
git rev-list -n 1 HEAD -- [file_path] |
module.exports = { | |
key1: () => 'Key 1', | |
key2: () => 'Key 2', | |
}; | |
import all, { key1 } from 'index'; | |
// Result | |
// all = { key1, key2 } | |
// key1 = () => {} |
// Month here is 1-indexed (January is 1, February is 2, etc). This is | |
// because we're using 0 as the day so that it returns the last day | |
// of the last month, so you have to add 1 to the month number | |
// so it returns the correct amount of days | |
function daysInMonth (month, year) { | |
return new Date(year, month, 0).getDate(); | |
} | |
// July | |
daysInMonth(7,2009); // 31 |
<div> | |
<input autocomplete="new-password" /> | |
<input autocomplete="new-username" /> | |
</div> | |
<!-- Reference: https://stackoverflow.com/questions/18531437/stop-google-chrome-auto-fill-the-input --> |
/** | |
* util-types could be used to replace some methods of lodash such as: | |
* _.isObject | |
* _.isString | |
* _.isNumber | |
* _.isFunction | |
* _.isBoolean | |
* _.isArray | |
* _.isRegExp | |
*/ |
function _stringToPath(path) { | |
const containsBracketNotation = /\[[0-9]+\]/g; | |
if (path.match(containsBracketNotation)) { | |
path = path.replace(containsBracketNotation, s => `.${s.substring(1, s.length - 1)}`); | |
} | |
return path.split('.'); | |
} | |
function get(source, path, defaultArgument) { | |
return _stringToPath(path).reduce((nestedObject, key) => { |
travis encrypt --com '<SLACK_ACCOUNT>:<SLACK_TOKEN>#<SLACK_CHANNEL>' -r <REPO_USER>/<REPO_NAME> | |
travis encrypt --com '<SLACK_ACCOUNT>:<SLACK_TOKEN>#<SLACK_CHANNEL>' |
#!/usr/bin/env bash | |
source ~/.bash_functions; | |
alias project='project $1' |