Skip to content

Instantly share code, notes, and snippets.

View dhbradshaw's full-sized avatar

Douglas H. Bradshaw dhbradshaw

  • Harvest Alabama
View GitHub Profile
@dhbradshaw
dhbradshaw / morse.js
Last active January 6, 2021 17:09 — forked from eholk/morse.js
A Morse Code generator in Java Script
function MorseNode(ac, rate) {
// ac is an audio context.
this._oscillator = ac.createOscillator();
this._gain = ac.createGain();
this._gain.gain.value = 0;
this._oscillator.frequency.value = 750;
this._oscillator.connect(this._gain);
@dhbradshaw
dhbradshaw / reviewable_bindings.json
Last active November 2, 2020 18:40
Reviewable Key Bindings
[
["f", "Show next/latest diffs", "setProposedDiffBounds()"],
["n", "Next unreviewed file", "nextUnreviewedFile()"],
["p", "Previous unreviewed file", "prevUnreviewedFile()"],
[null, "Next personally unreviewed file", "nextPersonallyUnreviewedFile()"],
[null, "Previous personally unreviewed file", "prevPersonallyUnreviewedFile()"],
["shift+n", "Next changed file", "nextChangedFile()"],
["shift+p", "Previous changed file", "prevChangedFile()"],
[null, "Next visible file", "nextVisibleFile()"],
@dhbradshaw
dhbradshaw / save-heroku-config-vars-to-env.sh
Created May 13, 2020 16:31 — forked from tibawatanabe/save-heroku-config-vars-to-env.sh
Command line to save Heroku config vars into .env file
heroku config | sed 's/: */=/g; /^=/d' >> .env
@dhbradshaw
dhbradshaw / pagerDutyResolver.md
Created February 10, 2020 14:28
PagerDuty Resolver Bot

Resolving my pagerduty problems with a simple js script

No user deletions for you!

Recently I had to delete a user from pagerduty, but the interface blocked me from doing so, saying that I couldn't complete the deletion until all of that users issues were resolved.

Slog ahead

I looked at the unresolved issues and there were thousands.

@dhbradshaw
dhbradshaw / rust_setup.md
Created December 5, 2019 12:43
Rust setup

Rust setup

More often than one might expect, I find myself setting up a new environment for rust development.
Here are some things that I end up doing repeatedly.

Summary

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cargo-watch

sudo apt install libpq-dev
cargo install diesel_cli --no-default-features --features postgres
@dhbradshaw
dhbradshaw / pkill.sh
Last active November 27, 2019 11:52
pkill example: kill guake process
# Try listing the processes associated with a term, for example guake.
$ pgrep guake
8494
# Kill guake processes without bothering looking at them.
$ pkill guake
@dhbradshaw
dhbradshaw / no-rebase.sh
Last active September 19, 2019 15:08
Better than rebase
# Source: https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit
# Switch to the master branch and make sure you are up to date.
git checkout master
git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
git pull
# Merge the feature branch into the master branch.
git merge feature_branch
@dhbradshaw
dhbradshaw / gnu_encryption.sh
Last active January 24, 2019 13:23
gnu encryption
# Encrypt file
gpg -c --cipher-algo AES256 private-file.txt
# Decrypt it
gpg private-file.txt.gpg
# !!Don't forget the passphrase!!
@dhbradshaw
dhbradshaw / imgSources.js
Last active December 17, 2018 16:51
Array of img urls from JS console
// Get html collection of images:
var imgs = document.getElementsByTagName('img')
// Convert to array
imgs = Array.from(imgs)
// Map to urls
var urls = imgs.map(img => img.src)
// Copy to clipboard
In [1]: %load_ext autoreload
In [2]: %autoreload 2
In [3]: from core.courses import questions
In [4]: questions.meaning_of_life()
Out[4]: 42
In [5]: "Rewriting method"