Skip to content

Instantly share code, notes, and snippets.

View pda's full-sized avatar
💾
Formatting…

Paul Annesley pda

💾
Formatting…
View GitHub Profile
@pda
pda / poorman
Last active February 16, 2024 00:00
poorman: a Procfile runner for tmux, in terrible bash
#!/bin/bash
set -e -o pipefail -u
# Launches each Procfile service as a tmux pane in a background window.
# The window is created if it doesn't already exist.
# Panes are created on demand, and existing panes are restarted if stopped.
WINDOW_NAME="poorman"
if [[ ${1:-} == "stop" ]]; then
@pda
pda / lircd.conf
Created January 4, 2014 05:35
LIRC config for my Apple Remote (aluminum) on Raspberry Pi / RaspBMC via one of these IR receivers: http://www.ebay.com/itm/121156693642?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sat Dec 7 19:14:59 2013
#
# contributed by
#
# brand: lirc-pda.conf
# model no. of remote control:
@pda
pda / hash_search.rb
Created September 15, 2022 11:32
Ruby recursive Hash search
haystack = {
action: "greeting",
scope: "world",
things: [
{ x: "city" },
{ x: "country" },
{ x: "world" },
]
}
@pda
pda / goreman-tmux
Created December 14, 2021 09:34
Idempotently launches each Procfile service as a tmux pane in a background window. Cursed dense bash hacks 🐉
#!/bin/bash
set -e -o pipefail -u
# Launches each Procfile service as a tmux pane in a background window.
# The window is created if it doesn't already exist.
# Panes are created on demand, and existing panes are restarted if stopped.
WINDOW_NAME="goreman"
tmux new-window -adS -n $WINDOW_NAME
@pda
pda / garbage_collection.rb
Created August 3, 2011 05:34
Faster RSpec with manual garbage collection
##
# spec/support/garbage_collection.rb
#
# Inspired by:
# http://www.rubyinside.com/careful-cutting-to-get-faster-rspec-runs-with-rails-5207.html
#
# At time of writing:
# reduces duration from ~16.7sec to ~15.7sec (6% improvement)
# increases peak memory usage from 150mb to 200mb (33% increase)
@pda
pda / docker-mysql-initialize.sh
Created March 21, 2014 22:09
Docker script to initialize MySQL database; auth from remote hosts.
#!/bin/bash
# Initialize MySQL database.
# ADD this file into the container via Dockerfile.
# Assuming you specify a VOLUME ["/var/lib/mysql"] or `-v /var/lib/mysql` on the `docker run` command…
# Once built, do e.g. `docker run your_image /path/to/docker-mysql-initialize.sh`
# Again, make sure MySQL is persisting data outside the container for this to have any effect.
set -e
set -x
@pda
pda / git-push-as
Last active November 30, 2020 08:26
git-push-as: pull request without creating branches.
#!/bin/bash -e
# Push local changes on the current branch as a new branch, then
# reset the local branch back to its remote tracking branch.
#
# This enables a fast workflow:
# 10 `git commit` one or more changes to main.
# 20 `git push-as -p new-feature`
# 30 goto 10
@pda
pda / inline_file.rb
Last active September 14, 2020 04:01
A basic !InlineFile YAML tag/function resolver for inlining Lambda into CloudFormation; assumes two-space indentation
PATTERN = %r{
^
(?<indent>\s*)
(?<key>\S+):
\s*
!InlineFile
\s*
(?<file>.*)
$
}x
@pda
pda / www.rb
Created August 9, 2012 02:23
www: Serve the current directory via HTTP.
#!/usr/bin/env ruby
# Serve the current directory via HTTP.
# Like Python's SimpleHTTPServer, but with no-cache headers.
# Default port 8000, specify alternate port as first parameter:
# www 3000
# sudo www 80 # (probably a bad idea)
# Inspired by http://chrismdp.github.com/2011/12/cache-busting-ruby-http-server/
@pda
pda / Gemfile
Created January 23, 2017 03:52
Sidekiq::Web v4.2 (no longer on Sinatra) with GitHub OAuth
source "https://rubygems.org"
# ruby web server; run Sidekiq::Web with e.g. `puma --port=80`
# https://github.com/puma/puma
gem "puma"
# provides Sidekiq::Web monitoring UI
# https://github.com/mperham/sidekiq/wiki/Monitoring
gem "sidekiq", "~> 4.2"