Skip to content

Instantly share code, notes, and snippets.

@stckcrsh
stckcrsh / machine.js
Last active February 11, 2022 16:45
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
export const deepMerge = (target, ...sources) => {
if (!sources.length) {
return target;
}
// making sure to not change target (immutable)
const output = { ...target };
sources.forEach(source => {
if (isObject(source)) {
Object.keys(source).forEach(key => {
if (isObject(source[key])) {
@stckcrsh
stckcrsh / terminal-git-branch-name.md
Created November 5, 2019 21:52 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
this.toBeScanned$
.scan(() => do something)
.takeUntil(this.reset$)
.repeat();
@stckcrsh
stckcrsh / restore.txt
Created August 1, 2017 17:49
Restoring deleted files in git
Find the last commit that affected the given path. As the file isn't in the HEAD commit, this commit must have deleted it.
git rev-list -n 1 HEAD -- <file_path>
Then checkout the version at the commit before, using the caret (^) symbol:
git checkout <deleting_commit>^ -- <file_path>
Or in one command, if $file is the file in question.
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
@stckcrsh
stckcrsh / .bashrc
Created July 31, 2017 20:50
Autosourcing .env files (found in stackoverflow user 'gsf' )
# .env loading in the shell
dotenv () {
set -a
[ -f .env ] && . .env
set +a
}
# Run dotenv on login
dotenv