Skip to content

Instantly share code, notes, and snippets.

View imonroe's full-sized avatar

Ian Monroe imonroe

View GitHub Profile
imonroe /
Created June 27, 2023 14:48
Bash Script template
# Three-fingered Claw Technique
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
# Do the thing.
imonroe / getGithubFile.php
Created July 15, 2022 16:05
Fetch the contents of a single file from a Github repo using Guzzle and return as a string
use \GuzzleHttp\Client;
use \GuzzleHttp\Psr7;
use \GuzzleHttp\Exception\RequestException;
* Use guzzle to get a single file from github and return it as a string.
* @param string $url The path of the file to fetch
* @return string
imonroe /
Created May 18, 2021 14:42
Disable the stupid bell sound in WSL
#!/usr/bin/env bash
echo "set bell-style none" >> ~/.inputrc
imonroe / drush_user_delete_example.php
Last active December 12, 2018 18:03
Drush - Delete a group of users in Drupal 7 from the command line
// We want to preserve all accounts from a selection of email domains.
// We want to preserve system accounts with UIDs 0 and 1
// We want to delete all other accounts which are:
// - disabled, AND
// - have never been used, AND
// - have never been logged into
// We also want to use Drupal's user_delete_multiple() function so that
// all the necessary hooks are called throughout the system.
imonroe /
Last active July 28, 2018 17:30
Handy Git tricks
## discard modifications in a directory
git checkout -- Gemfile # reset specified path
git checkout -- lib bin # also works with multiple arguments
## Undo local commits
git reset HEAD~2 # undo last two commits, keep changes
git reset --hard HEAD~2 # undo last two commits, discard changes
## Remove a file from the repo, but keep it in the filesystem
git reset filename # or git remove --cached filename
imonroe /
Created July 15, 2018 12:58
Convert all the docx files in a directory to markdown, and concatenate
#!/usr/bin/env bash
find . -name "*.docx" | while read file; do
pandoc -s "$file" -t markdown -o "./converted/$"
cat ./converted/*.md > ./converted/
### Keybase proof
I hereby claim:
* I am imonroe on github.
* I am imonroe ( on keybase.
* I have a public key ASD8yUdUlLyYC3kCM_YZb0J0FPfcNYyzHIucefCQlJ188Qo
To claim this, I am signing this object: