Skip to content

Instantly share code, notes, and snippets.

View shaunmolloy's full-sized avatar

Shaun Molloy shaunmolloy

View GitHub Profile
@shaunmolloy
shaunmolloy / git-merged
Last active October 26, 2022 13:45
git-merged - Delete local branches that have been merged in
#!/usr/bin/env bash
# git-merged
# Delete local branches that have been merged in
# Compare against current branch
branch="$(git branch --show-current)"
# Compare to branch, when merged in
head="$(git reflog show HEAD -1 | tail -n1 | awk '{ print $1 }')"
@shaunmolloy
shaunmolloy / docker-ps
Last active August 22, 2019 07:37
docker-ps - Filter docker ps by service to get url
#!/usr/bin/env bash
# docker-ps
# Filter docker ps by service to get url
if [ "$#" -gt 0 ]
then
copy="$(\
docker ps | \
grep -n $@ | \
perl -lne 'print "$1" while /[, ]?(0\.0\.0\.0:[0-9]{1,})/g;' | \
@shaunmolloy
shaunmolloy / spellcheck
Last active June 13, 2019 09:32
spellcheck - use aspell to dump list of spell-checked words
#!/usr/bin/env bash
# spellcheck
# use aspell to dump list of spellchecked words
cat $1 | # stdin
aspell -a -l en | # spellcheck with aspell
cut -d ' ' -f 2 |
grep -v '*' | # clean up aspell output
awk NF | # remove blank lines
sort | # sort
@shaunmolloy
shaunmolloy / git-changed
Last active May 28, 2020 15:06
git-changed - List changes from branch to master
#!/usr/bin/env bash
# git-changed
branch="master"
name_only=""
has_branch=0
args=""
if [ $# -gt 0 ]
then
@shaunmolloy
shaunmolloy / pass.py
Last active February 23, 2020 10:59
pass - Generate password, with custom length
#!/usr/bin/env python
# pass
# Generate password, with custom length
import sys
import secrets
import string
if not len(sys.argv) > 1:
length = 16
@shaunmolloy
shaunmolloy / secret-key.py
Last active May 14, 2024 07:34
secret-key - Generate an app secret key
#!/usr/bin/env python
# secret-key
# Generate an app secret key
from base64 import b64encode
from os import urandom
random_bytes = urandom(64)
token = b64encode(random_bytes).decode()
#!/usr/bin/env sh
# get-stream
youtube-dl -f best --get-url $1
@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
@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 / TrimText.js
Last active March 3, 2021 10:36
Trim Text - Google Apps Script
function TrimText() {
var sheet = SpreadsheetApp.getActive();
sheet.getActiveRange().trimWhitespace();
};