Skip to content

Instantly share code, notes, and snippets.

# Iterate through Git directories and display their branch
# Use-case: check if we are all on master or not
function showcurrentbranch () {
find ${1:-.} -type d -path '*/.git' -printf '%h\n' -prune | xargs -I{} zsh -c \
"echo {} ; pushd {} && git branch --show-current ; popd"
}
@olive42
olive42 / allowPaste.js
Created February 2, 2022 07:22
Allow paste in websites that disable it (useful when creating passwords with your password manager)
// From https://www.cyberciti.biz/linux-news/google-chrome-extension-to-removes-password-paste-blocking-on-website/
var allowPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
@olive42
olive42 / gitupdate.sh
Last active January 28, 2022 09:18
Figured an easy way to update a lot of checked out Git repositories in a given subtree (or whatever default you set in line 3).
# This assumes I am using zsh, and git config --global pull.rebase true
function gitupdate () {
# https://unix.stackexchange.com/questions/333862/how-to-find-all-git-repositories-within-given-folders-fast
find ${1:-.} -type d -path '*/.git' -printf '%h\n' -prune | xargs -t -I{} zsh -c "pushd {} && git fetch -p && git rev-parse --abbrev-ref --symbolic-full-name @{u} &&
git pull ; popd"
git fetch -p && git pull
}
function gclone () {
@olive42
olive42 / .zprofile
Created March 25, 2020 10:54
Automatically attach to tmux session or create one if non-existent
# Add to ~/.zprofile - ZSH-specific? Not sure
tmux has -t scratch &> /dev/null
if [ $? != 0 ]; then
tmux -2 new-session -s scratch -D -d
fi
if [ -z $TMUX ]; then
tmux attach -t scratch -d
fi
@olive42
olive42 / cloudSettings
Last active September 3, 2019 08:22
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-03-23T15:01:05.134Z","extensionVersion":"v2.9.0"}
@olive42
olive42 / json-slurper.groovy
Created January 31, 2017 10:20
JsonSlurper parses wrong JSON
Groovy Shell (2.4.7, JVM: 1.8.0_121)
Type ':help' or ':h' for help.
---------------------------------------------------------------------------------------------------------------------------------------
groovy:000> import groovy.json.JsonSlurper
===> groovy.json.JsonSlurper
groovy:000> import groovy.json.JsonParserType
===> groovy.json.JsonSlurper, groovy.json.JsonParserType
groovy:000> parser = new JsonSlurper().setType(JsonParserType.INDEX_OVERLAY)
===> groovy.json.JsonSlurper@36060e
groovy:000> parser.parseText('''\
@olive42
olive42 / oth-split-and-balance.el
Created June 8, 2012 07:20
Emacs Lisp: split frame in 3 balanced windows horizontally
(defun oth-split-and-balance ()
"Split frame in 3 balanced windows horizontally."
(interactive)
(split-window-horizontally)
(split-window-horizontally)
(balance-windows))
(global-set-key [f5] 'oth-split-and-balance)