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 / 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
@dhbradshaw
dhbradshaw / systemd_services.md
Last active May 4, 2024 03:20 — forked from leommoore/systemd_services.md
Systemd Services 101

Check that your system supports systemd

pidof systemd
2733

If this return a number then your system supports systemd. Most Linux distributions in 2017 support systemd.

Check out the processes currently running.

Since systemd starts the process then all processes will be children of systemd

@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 / 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 / postgres-windows.md
Last active January 28, 2025 11:01
Postgres on WSL (Windows Subsystem for Linux) ubuntu 18.04

Postgres on WSL (Windows Subsystem for Linux) ubuntu 18.04

Hint: it's not different than running it under ubuntu without Windows.

Add postgres package registry

sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

Update apt

@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 / 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 / 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