Skip to content

Instantly share code, notes, and snippets.

@rhydlewis
rhydlewis / redact-jira-export.py
Created December 7, 2023 13:42
Redact Jira JSON export File
import json
# TODO - redact jira instance name
def redact_data(data):
if isinstance(data, dict):
for key, value in data.items():
if key in ['name', 'emailAddress', 'displayName', 'summary', 'description']:
data[key] = 'redacted'
elif key in ['fromString', 'toString']:
@rhydlewis
rhydlewis / tsv2table.rb
Created October 19, 2020 10:21
Ruby code to convert table of data copied from spreadsheet into a Markdown table
require 'csv'
query = ARGV[0] # Alfred
if query
col_sep = query
else
col_sep = "\t"
end
clipboard = `pbpaste`
alias yd='youtube-dl -x --audio-format m4a'
alias slime='open -a "Sublime Text"'
alias ax='chmod a+x'
alias ff='open -a Finder ./'
alias p='ps aux| grep -v grep| grep -i'
alias h='history'
function cdf
set target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
if [ $target ]
cd $target
@rhydlewis
rhydlewis / useful-bash.sh
Created November 1, 2016 14:24
Useful Bash commands
# Find and count file extensions in a directory
find . -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -rn
# Rename group of files
for old in \*.txt; do mv $old `basename $old .txt`.md; done
# Resize group of images
for f in \*.jpg; do convert $f $f.pdf; done
# Download youtube playlist video
@rhydlewis
rhydlewis / network_days.rb
Created August 20, 2015 22:30
Network days function (ruby)
require 'date'
def network_days(start_date, end_date)
days_between = (end_date - start_date).to_i
whole_weeks, extra_days = days_between.divmod(7)
unless extra_days.zero?
extra_days -= if (start_date + 1).wday <= end_date.wday
[(start_date + 1).sunday?, end_date.saturday?].count(true)
else
@rhydlewis
rhydlewis / switch
Created July 17, 2015 12:00
useful-snippets
data=$(pbpaste)
if [ $(echo "$data" | wc -l) -gt 1 ];
then
change=${data//
/ }
else
change=${data// /
}
fi
echo -e "$change" | pbcopy