Skip to content

Instantly share code, notes, and snippets.

View marcus-grant's full-sized avatar

Marcus Grant marcus-grant

  • Applied Industries
  • Stockholm
View GitHub Profile
RED="\[\e[0;36m\]"
GRAY="\[\e[0;37m\]"
YELLOW="\[\e[0;33m\]"
BLUE="\[\e[0;34m\]"
PURPLE="\[\e[0;35m\]"
GREEN="\[\e[0;32m\]"
WHITE="\[\e[0;37m\]"
BLOODRED="\[\e[1;31m\]"
CYAN="\[\e[1;34m\]"
LIGHT_CYAN="\[\e[0;96m\]"
@marcus-grant
marcus-grant / get-running-shell-script-dir.sh
Last active July 11, 2018 16:07
Get currently running shell script 's directory path
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@marcus-grant
marcus-grant / sh
Last active July 11, 2018 13:17
Single line to save-dev on npm all the things needed to unit test typescript using mocha & chai for typescript specifically
npm install chai mocha ts-node @types/chai @types/mocha --save-dev
@marcus-grant
marcus-grant / remove-file-extension.sh
Created October 13, 2017 00:08
From StackOverflow: http://bit.ly/2gAVase ========================== Here's how to do it with the # and % operators in Bash. $ x="/foo/fizzbuzz.bar" $ y=${x%.bar} $ echo ${y##*/} fizzbuzz ${x%.bar} could also be ${x%.*} to remove everything after a dot or ${x%%.*} to remove everything after the first dot. Example: $ x="/foo/fizzbuzz.bar.quux" $ …
remove-file-extension(){
local FILE_W_EXT=$1
local FILE_WO_EXT=${FILE_W_EXT%.*}
return FILE_WO_EXT
}
@marcus-grant
marcus-grant / 0_reuse_code.js
Created May 4, 2017 20:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@marcus-grant
marcus-grant / .bash_profile
Created December 25, 2015 23:43 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management