Skip to content

Instantly share code, notes, and snippets.

View jhollinger's full-sized avatar

Jordan Hollinger jhollinger

View GitHub Profile
@jhollinger
jhollinger / .tmux.conf
Last active January 30, 2024 03:07
My Dotfiles
# vim style tmux config
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 0
# Easy config reload
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
@jhollinger
jhollinger / thin
Created November 4, 2012 14:51 — forked from sorah/thin
/etc/init.d/thin - thin init script with bundle exec
#!/bin/bash
DAEMON=/usr/local/bin/thin
BUNDLE=/usr/local/bin/bundle
CONFIG_PATH=/etc/thin
SCRIPT_NAME=/etc/init.d/thin
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
invoke()
@jhollinger
jhollinger / README.md
Last active July 6, 2023 09:54
rbackup - time-stamped, hard-linked backups powered by rsync

rbackup

rbackup is a lightweight, rsync-powered backup utility that creates time-stamped backups.

Features

It can save backups to your local filesystem (probably an attached USB device) or to a remote host.

Backups are saved in time-stamped directories. Backups are cheap on storage, because hard-links are used for files that haven't changed between backups.

@jhollinger
jhollinger / nyancat
Last active March 26, 2023 15:44
Nyancat
#!/usr/bin/env bash
red='\e[31m'
green='\e[32m'
yellow='\e[33m'
blue='\e[34m'
bold='\033[1m'
normal='\e[0m'
lines=(
@jhollinger
jhollinger / keep-recent.sh
Created March 24, 2023 19:16
Keep most recent files
# Delete all but the most recent N files in the given dir (and its subdirs)
function keep_most_recent {
dir="$1"
n=$2
offset=$((n+1))
find "$dir" -type f -printf "%T+ %p\n" |
sort -r |
awk '{ print $2 }' |
tail -n +$offset |
xargs --no-run-if-empty rm -f
@jhollinger
jhollinger / csp-strict-dynamic.js
Last active March 8, 2023 22:56
Rewrites index.html to with CSP strict-dynamic enabled
/**
* Usage: node csp-strict-dynamic.js dist/index.html [path/to/nginx.conf]
*
* Replaces all external script tags in index.html with dynamic loaders, calculates their SHA 256 hashes, and adds those
* hashes as allowed script sources + strict dynamic. Also works for inline scripts.
*
* Your index.html and/or given nginx/apache config file should contain your CSP policy with a script-src section like below:
*
* script-src 'strict-dynamic' {{csp-strict-dynamic-sources}};
*/
@jhollinger
jhollinger / extract-google-photos
Created February 5, 2023 21:06
Extract photos/video from a Google Takeout tarball
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]] || [[ ! -f "$1" ]] || [[ ! -d "$2" ]]; then
echo "usage: extract-google-photos [tarfile] [dest-dir]"
exit 1
fi
if ! command -v exiftool > /dev/null || ! command -v gawk > /dev/null; then
@jhollinger
jhollinger / chrome-auto.sh
Last active July 2, 2021 20:07
Remote Headless Chrome
#
# Easiest. If this doesn't work right, try manual.sh
#
docker run --rm -it -p=0.0.0.0:9222:9222 alpeware/chrome-headless-trunk
# Then open local Chrome go to localhost:9222, then to chrome://inspect. From there you can open new tabs and inspect them.
@jhollinger
jhollinger / Gemfile
Created April 9, 2019 00:23
DatabaseTasks Green Example
source 'https://rubygems.org'
gem 'activerecord', '~> 5.2', require: 'active_record'
gem 'sqlite3'
gem 'rake'
@jhollinger
jhollinger / rspec_database_cleaner.rb
Created December 21, 2012 05:58
Optimal RSpec Database Cleaner config
Capybara.javascript_driver = :webkit # Selenium works, but not as well
RSpec.configure do |config|
config.use_transactional_fixtures = false
# Use transactions by default
config.before :each do
DatabaseCleaner.strategy = :transaction
end