Skip to content

Instantly share code, notes, and snippets.

View dylan-chong's full-sized avatar
💧
Elixiring

Dylan Chong dylan-chong

💧
Elixiring
View GitHub Profile
@dylan-chong
dylan-chong / autogen-plantuml.vim
Created May 13, 2018 11:17
Vim auto generate plantuml on save
au BufWritePost *.plantuml :silent !plantuml % &
@dylan-chong
dylan-chong / update-preview.applescript
Created May 19, 2018 03:28
Open Preview.app so that it updates its view on the image then switch back to previous application
on run {input, parameters}
global currentProcess
tell application "System Events"
--set currentProcess to the name of the first process where it is frontmost
set currentProcess to (path to frontmost application as text)
end tell
activate application "Preview"
@dylan-chong
dylan-chong / grab-options.sh
Created June 30, 2018 05:49
Grab --options from a help page
#!/bin/bash
options_for_command() {
git help $1 \
| tr " " "\n" \
| egrep '^\--.*$' \
| egrep -v '/' \
| egrep -v '\-{3,}' \
| egrep -v '{|}' \
| perl -pe 's/\[=.*\]//' \
| perl -pe 's/[^\w=\n\[\]<>-]//' \
-- See the most up to date version here where it says "Download the mrc-converter-suite zip archive" https://discussions.agilebits.com/discussion/30286/mrcs-convert-to-1password-utility/p1
--
-- Exports Safari's saved passwords to a CSV file formatted for use with the convert_to_1p4's csv converter
--
-- Version 1.4
-- mike (at) cappella (dot) us
--
use AppleScript version "2.5" -- runs on 10.11 (El Capitan) and later
use scripting additions
@dylan-chong
dylan-chong / do-not-disturb-toggler-high-sierra.scpt
Last active December 3, 2024 11:52
do-not-disturb-toggler-high-sierra.scpt
(* setDoNotDisturb function based on https://gist.github.com/Sanabria/40d80d84ec94644220489798f3aac930 *)
set workTimeLengthInSeconds to 60 * 10
set breakTimeLengthInSeconds to 60 * 1
on setDoNotDisturb(shouldBeOn)
(* Note 1: The 1 after menu bar may need to be changed to 2 when using multiple monitors *)
(* Note 2: For 10.11 and newer “NotificationCenter” is now spelled “Notification Center”*)
(* Note 3: The alert must be shown before toggling do not disturb mode, as doing the toggling requires pressing the option key, and we don't want to disturb the user's typing *)
tell application "System Events"
@dylan-chong
dylan-chong / download-songs-by-name.rb
Created December 28, 2019 00:44
Download a list of songs by name
# Requires spotdl and youtube-dl to installed with python3
# Should be a list of search query text for spotify (e.g. `Song Name Artist Name`)
SONG_LIST_FILE = '/Users/Dylan/Desktop/songs.txt'.freeze
OUTPUT_FOLDER = '/Users/Dylan/Desktop/songs'.freeze
File.foreach(SONG_LIST_FILE) do |line|
command = [
'spotdl',
'--song',
@dylan-chong
dylan-chong / adguard
Created March 28, 2020 23:51
Adguard blacklist/block time-wasting feed pages
/.*facebook.com\/$/
/.*reddit.com\/$/
/.*youtube.com\/$/
@dylan-chong
dylan-chong / vim-as-bash-scriptable-editor.bash
Last active July 23, 2022 14:31
Bash command to add `, async: true` to a given file
nvim test/hello.exs -c 'execute "normal! gg/use ExUnit.Case\<CR>A, async: true\<Esc>:wq\<CR>"' -u NONE --headless
@dylan-chong
dylan-chong / monitor-directory.sh
Created October 13, 2022 01:11
[MacOS] See what files are getting read/written
sudo fs_usage -f filesys | grep my-directory
find . -type f | while read file; do echo "$(date -r "$file" "+%s %Y-%m-%d %H:%M:%S")" " $file"; done > filechangedates
cat filechangedates | sort -n