Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Monroe imonroe

View GitHub Profile
@imonroe
imonroe / getGithubFile.php
Created Jul 15, 2022
Fetch the contents of a single file from a Github repo using Guzzle and return as a string
View getGithubFile.php
<?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
Disable the stupid bell sound in WSL
View wsl_disable_bell.sh
#!/usr/bin/env bash
echo "set bell-style none" >> ~/.inputrc
@imonroe
imonroe / drush_user_delete_example.php
Last active Dec 12, 2018
Drush - Delete a group of users in Drupal 7 from the command line
View drush_user_delete_example.php
<?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 Jul 28, 2018
Handy Git tricks
View git_tricks.sh
## 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 Jul 15, 2018
Convert all the docx files in a directory to markdown, and concatenate
View docx2md.sh
#!/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
View gist:633e1cf1443fbef0b7b60cc4df3e5bbf
### 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: