Skip to content

Instantly share code, notes, and snippets.

View imonroe's full-sized avatar

Ian Monroe imonroe

View GitHub Profile
@imonroe
imonroe / bash_script.sh
Created June 27, 2023 14:48
Bash Script template
#!/bin/bash
# Three-fingered Claw Technique
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
# Do the thing.
@imonroe
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
<?php
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
imonroe / wsl_disable_bell.sh
Created May 18, 2021 14:42
Disable the stupid bell sound in WSL
#!/usr/bin/env bash
echo "set bell-style none" >> ~/.inputrc
@imonroe
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
<?php
// 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
imonroe / git_tricks.sh
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
imonroe / docx2md.sh
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/$file.md"
done
cat ./converted/*.md > ./converted/compiled.md
### Keybase proof
I hereby claim:
* I am imonroe on github.
* I am imonroe (https://keybase.io/imonroe) on keybase.
* I have a public key ASD8yUdUlLyYC3kCM_YZb0J0FPfcNYyzHIucefCQlJ188Qo
To claim this, I am signing this object: