Skip to content

Instantly share code, notes, and snippets.

View shaunmolloy's full-sized avatar

Shaun Molloy shaunmolloy

View GitHub Profile
for session in $(tmux ls | grep prefix | awk '{ print $1 }' | sed -e 's/:$//'); do tmux kill-session -t $session; done
@shaunmolloy
shaunmolloy / upstream-merge
Created June 5, 2023 13:38
upstream-merge - merge in changes from upstream
#!/usr/bin/env bash
# Checkout to upstream-merge branch if we're not on one
BRANCH="$(git branch --show-current)"
if [[ ! "$BRANCH" =~ "upstream-merge" ]]; then
git checkout -b feature/upstream-merge
fi
# Fetch latest from upstream
git fetch upstream
@shaunmolloy
shaunmolloy / vim-session
Last active June 1, 2023 14:34
vim-session - fzf vim session from aliases
#!/usr/bin/env bash
vim_session() {
if [ ! -f ~/.bash_aliases ]; then
echo "No ~/.bash_aliases file found"
return 1
fi
# Source aliases
shopt -s expand_aliases
#!/usr/bin/env bash
# time-npm-start
URL="http://localhost:3000/"
spinner() {
I=$(( (I+1) %4 ))
printf "\r${SPIN:$I:1} $1"
}
@shaunmolloy
shaunmolloy / short-uuid
Last active July 29, 2022 11:11
short-uuid - generate a short uuid in bash
#!/usr/bin/env bash
# short-uuid
UUID=$(cat /proc/sys/kernel/random/uuid)
SHORT_UUID=$(echo $UUID | sed "s/-//g")
SHORT_UUID=${SHORT_UUID:0:10}
echo $SHORT_UUID
@shaunmolloy
shaunmolloy / uuid
Created July 29, 2022 11:07
generate a uuid in bash
#!/usr/bin/env bash
# uuid
UUID=$(cat /proc/sys/kernel/random/uuid)
echo $UUID
@shaunmolloy
shaunmolloy / TrimText.js
Last active March 3, 2021 10:36
Trim Text - Google Apps Script
function TrimText() {
var sheet = SpreadsheetApp.getActive();
sheet.getActiveRange().trimWhitespace();
};
@shaunmolloy
shaunmolloy / CopyDown.js
Created March 3, 2021 10:28
Copy Down - Google Apps Script
function CopyDown() {
var sheet = SpreadsheetApp.getActive();
sheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
var currentCell = sheet.getCurrentCell();
currentCell.activateAsCurrentCell();
var rangeEnd = (sheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).getLastRow()) - currentCell.getRow();
var range = sheet.getActiveSheet().getRange(currentCell.getRow(), currentCell.getColumn(), rangeEnd);
currentCell.copyTo(range, SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
@shaunmolloy
shaunmolloy / isup
Last active January 8, 2021 14:09
isup - check if websites (args passed) are up
#!/usr/bin/env bash
# check if websites (args passed) are up
for site in $@
do
echo
echo $site
curl -I -s $site | head -n 1 | grep -q "404" && echo down || echo up