Skip to content

Instantly share code, notes, and snippets.

@LeZuse
LeZuse / gitlab-env-copy.sh
Last active April 22, 2020 19:05
Copy ENV vars from one GitLab project to another
GL_TOKEN=xxxxxxx-xxxxxxx
ID_FROM=00001
ID_DESTINATION=00002
PREFIX=
[ "$1" == "--dry-run" ] && PREFIX=echo
download_page () {
DATA=`curl --header "PRIVATE-TOKEN: $GL_TOKEN" "https://gitlab.com/api/v4/projects/$ID_FROM/variables?per_page=100&page=$c"`
@LeZuse
LeZuse / mute.applescript
Last active April 17, 2020 14:53
Mac OS un/mute with notification using Automator
-- Credits: https://superuser.com/a/937488/44834
-- https://apple.stackexchange.com/a/346995/62041
set inputVolume to input volume of (get volume settings)
-- Zoom does not allow the input volume to drop to 0, so we check by "lower than"
if inputVolume < 10 then
set inputVolume to 100
set displayNotification to "Microphone Unmuted"
else
set inputVolume to 0
set displayNotification to "Microphone Muted"
@LeZuse
LeZuse / services.bash
Last active October 5, 2021 07:31
brew services list/start/stop fzf ui
function services() {
brew services \
`echo -e 'list\nstart\nstop' | fzf --header 'brew services'` \
`brew services list | tail -n +2 | \
fzf -d' ' --with-nth=1 --preview='brew services list | grep {}' --preview-window=up:1 | \
cut -d' ' -f1`
}
@LeZuse
LeZuse / parse.js
Created November 8, 2019 16:24
Parse out details of enqueued jobs from recovered ElastiCache backup
#!/usr/bin/env node
const fs = require('fs')
const FILE = './bulk.csv';
const data = fs.readFileSync(FILE, 'utf8');
console.log('bytes', data.length)
const lines = data.split('\n');
console.log('lines', lines.length);
@LeZuse
LeZuse / zoom.5m.sh
Created November 4, 2019 12:22
BitBar plugin for listing today's meetings with a Zoom quick join option
#!/usr/local/bin/bash
# Prerequisites:
# mkdir gcalcli-local && cd !$
# pip3 install virtualenv
# virtualenv venv
# source venv/bin/activate
# pip3 install gcalcli
# which gcalcli # use this as command path in this script below
# deactivate
@LeZuse
LeZuse / prss.sh
Last active October 11, 2019 16:33
GitHub PR view & checkout
# prerequisites: brew install fzf hub
function prss() {
hub issue --include-pulls --color \
--since=`date -u -v-1m +"%Y-%m-%dT%H:%M:%SZ"` \
--format="%Cyellow%i%Creset %t %Cwhite@%au%Creset %l %Cyellow%cr%Creset%n" | \
fzf --ansi --preview="echo {} | cut -d' ' -f1 | tr -d '#' | xargs -I % hub issue show %" | \
cut -d' ' -f1 | tr -d '#' | \
xargs -I {} sh -c 'git rev-parse --verify pr-{} || git fetch origin pull/{}/head:pr-{} && git checkout pr-{}'
}
@LeZuse
LeZuse / zoom-mute.scpt
Created September 27, 2019 10:21
Zoom (un)mute
tell application "System Events" to tell process "zoom.us"
tell window 1
set buttonTitle to description of button 1
# needs "Window > Always show meetings controls" enabled
if buttonTitle = "Unmute My Audio" then
click button 1
"unmuted"
else if buttonTitle = "Mute My Audio" then
click button 1
"muted"
@LeZuse
LeZuse / elements.scpt
Last active August 19, 2019 17:44
Inspecting the UI elements in AppleScript
# Source: https://macscripter.net/viewtopic.php?pid=189593#p189593
# example: inspecting the contents of the Notes window
tell application "System Events" to tell process "Notes"
class of UI elements
tell window 1
class of UI elements
tell splitter group 1
class of UI elements
# get name of button 1
tell splitter group 1
@LeZuse
LeZuse / mrs.bash
Last active July 30, 2019 14:31
List My GitLab Merge Requests
function mrs() {
[ -z "$GITLAB_TOKEN" ] && \
echo 'Missing GITLAB_TOKEN env var. See https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token' && \
return 1
# download from GL API, process with jq and colorize with sed replace
curl https://gitlab.com/api/v4/merge_requests?private_token=$GITLAB_TOKEN\&state=opened\&sort=desc\&scope=assigned_to_me 2>/dev/null | \
jq --raw-output '.[] | "#" + (.iid | tostring) + " " + .title + " @" + .author.username + " | " + (.labels | join(", ")) + " \n 👉 " + .web_url + "\n"' | \
sed "s,.*https.*,$(tput setaf 6)&$(tput sgr0)," | \
sed -e "s/\(#[0-9]*\)\(.*\)\(@[a-zA-Z0-9-]*\) |\(.*\)/$(tput setaf 220)\1$(tput sgr0)\2$(tput setaf 7)\3 $(tput setab 4)\4$(tput sgr0)/g"
@LeZuse
LeZuse / helpers.sh
Created February 22, 2019 17:36
Heroku app helpers
function staging() {
echo -e "\e[2m\$ heroku $@ -a heroku-staging-app\e[0m"
heroku $@ -a heroku-staging-app
}
function prod() {
echo -e "\e[2m\$ heroku $@ -a heroku-production-app\e[0m"
heroku $@ -a heroku-production-app
}
alias prapps='heroku pipelines:info heroku-pipeline | grep review'
function prapp (){