Skip to content

Instantly share code, notes, and snippets.

View n8henrie's full-sized avatar

Nathan Henrie n8henrie

View GitHub Profile
@n8henrie
n8henrie / congress.ipynb
Last active December 20, 2019 04:26
A quick look at congress bills in recent history by unified or divided congress
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
"""Send files to MacOS trash bin via applescript."""
import os
from pathlib import Path
import sys
import subprocess
from typing import Iterable, Union
def trash(paths: Iterable[Union[str, Path]]) -> int:
@n8henrie
n8henrie / mount-image.sh
Created May 6, 2019 22:04
Script to mount all partitions from an image file into a temporary directory
#!/bin/bash
set -Eeuf -o pipefail
if [ ! "$(whoami)" = root ]; then
echo "Please run as root"
exit 1
fi
TMP="$(mktemp -d)"
@n8henrie
n8henrie / repair.sh
Last active July 7, 2021 00:16
Fix time machine backup
#!/usr/bin/env bash
# http://tonylawrence.com/post/unix/fixing-corrupted-time-machine-backups/
set -euf -o pipefail
set -x
if [[ $(whoami) != 'root' ]]; then
echo "Please run as root" > /dev/stderr
exit 1
fi
@n8henrie
n8henrie / setup_linux.sh
Last active November 10, 2017 23:43
Set up basic Linux preferences and settings
#! /bin/bash
echo '# Begin n8henrie settings' >> "${HOME}"/.inputrc
echo '" Begin n8henrie settings' >> "${HOME}"/.vimrc
echo '# Begin n8henrie settings' >> "${HOME}"/.bash_aliases
echo '# Begin n8henrie settings' >> "${HOME}"/.bashrc
curl 'https://gist.githubusercontent.com/n8henrie/c69de3e3c9d99668965473d1d315c855/raw' >> "${HOME}"/.inputrc
curl 'https://gist.githubusercontent.com/n8henrie/3e251bfe9ac9d5ce7421/raw' >> "${HOME}"/.vimrc
curl 'https://gist.githubusercontent.com/n8henrie/6cf7785d0ae025e706522e6e64c3fba2/raw' >> "${HOME}"/.bash_aliases
@n8henrie
n8henrie / .bashrc
Last active October 31, 2019 12:41
My basic .bashrc for Linux systems
# ~/.bashrc: executed by bash(1) for non-login shells.
# Reset path (or else it gets longer each time this is sourced)
export PATH=$(getconf PATH)
# http://unix.stackexchange.com/questions/40678/can-i-make-there-are-stopped-jobs-harder-to-kill
prompt_command() {
job_count=$(jobs | wc -l | tr -d ' ')
if [ $job_count -gt 0 ] ; then
prompt_job="[$job_count]"
@n8henrie
n8henrie / .bash_aliases
Created November 6, 2017 00:17
My basic bash_aliases for a Linux system
aur_download() {
aur_url="https://aur.archlinux.org$(curl -s "https://aur.archlinux.org/packages/$1" | ack -o "(?<=href=\").*?tar.gz(?=\">)")"
echo "$aur_url"
read -p "Download the above url? [yn] " response
case $response in
[Yy])
wget "$aur_url"
echo "You still need to do the usual: tar -xvf; cd; makepkg -s; pacman -U;"
;;
*)
@n8henrie
n8henrie / get_opencv3.sh
Last active June 19, 2018 02:53
Download, build, and install opencv on Raspberry Pi 3
#! /bin/bash
set -euf -o pipefail
function cleanup {
for pid in "${opencv_download_pid:-''}" "${contrib_download_pid:-''}" "${pip_install_pid:-''}"; do
if [ -z "${pid}" ]; then
kill "${pid}"
fi
done
@n8henrie
n8henrie / 2017-09-07-raspbian-stretch.txt
Created September 17, 2017 13:54
Default packages on fresh image of Raspbian Stretch 2017-09-07 SHA-256: a64d742bc525b548f0435581fac5876b50a4e9ba1d1cd6433358b4ab6c7a770b
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================================-==================================-============-==================================================================================================
ii adduser 3.115 all add and remove users and groups
ii adwaita-icon-theme 3.22.0-1+deb9u1 all default icon theme of GNOME
ii alacarte 3.11.91-2+rpi5 all easy GNOME menu editing tool
ii alsa-base 1.0.27+1 all dummy package to ease purging of obsolete conffiles
ii alsa-utils 1.1.3-1
@n8henrie
n8henrie / 2017-09-07-raspbian-stretch-lite.txt
Created September 17, 2017 13:52
Default packages on fresh image of Raspbian Stretch Lite 2017-09-07 SHA-256: bd2c04b94154c9804cc1f3069d15e984c927b750056dd86b9d86a0ad4be97f12
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================-============================-============-===============================================================================
ii adduser 3.115 all add and remove users and groups
ii alsa-utils 1.1.3-1 armhf Utilities for configuring and using ALSA
ii apt 1.4.7 armhf commandline package manager
ii apt-listchanges 3.10 all package change history notification tool
ii apt-transport-https 1.4.7 armhf https download transport for APT