Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael M. rafaelmaeuer

View GitHub Profile
View detect-os.sh
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
View git-delete-branch.sh
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
View shallow-deep-copy.js
// Shallow Copy (with reference)
var objectIsNew = objectIsOld;
// Name will change in both objects
objectIsNew.name = 'NameChanged';
// Deep Copy e.g. with JSON functions
var objectIsNew = JSON.parse(JSON.stringify(objectIsOld));
// Name will only change in new object
objectIsNew.name = 'NameChanged';
View postman-sha256.js
const message = pm.variables.replaceIn('{{$randomCatchPhrase}}')
var sha256Hash = CryptoJS.SHA256(message).toString();
//Method used to add Query params via script
pm.request.addQueryParams("sha256Hash=" + sha256Hash + "&infoData=" + pm.collectionVariables.get("infoData"));
console.log("sha256Hash :: " + sha256Hash)
View git-gpg-singing.sh
# Option 1 (local repo-wide configuration):
# https://confluence.atlassian.com/sourcetreekb/setup-gpg-to-sign-commits-within-sourcetree-765397791.html
# Option 2 (global system-wide configuration):
# https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key
# list gpg signing keys
gpg --list-secret-keys --keyid-format=long
# global add keyid of gpg-key
View brew-node-nvm.sh
brew install nvm
mkdir ~/.nvm
# Add to .zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && . "$(brew --prefix)/opt/nvm/nvm.sh" # This loads nvm
[ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && . "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
nvm install 18
View build-ios-cmd.sh
xcodebuild
-workspace ProjectName.xcworkspace
-scheme ProjectName
-configuration Debug
-sdk iphonesimulator
-destination 'platform=iOS Simulator,name=iPhone 13,OS=15.5'