Skip to content

Instantly share code, notes, and snippets.

View djbender's full-sized avatar

Derek Bender djbender

View GitHub Profile
djbender /
Created September 20, 2022 14:33
Rename a docker volume via create/copy/rm
docker volume create --name <new_volume>
docker run --rm -it -v <old_volume>:/from -v <new_volume>:/to alpine ash -c "cd /from ; cp -av . /to"
docker volume rm <old_volume>
djbender /
Last active April 25, 2020 14:16
install pigz on boot2docker tiny core linux environments (i.e. dinghy) for speedup on docker image layer extraction

connect to the boot2docker image via dinghy ssh

djbender /
Last active January 21, 2020 19:20
a minimal repro for mounting individual files like the id_rsa file into a container
#!/usr/bin/env bash
docker run -it -v $HOME/.ssh/id_rsa:/Users/docker/.ssh/id_rsa alpine sh -c "ls -lah /Users/docker/.ssh/"
# which should output something like:
# total 12K
# drwxr-xr-x 2 root root 4.0K Jan 21 19:19 .
# drwxr-xr-x 3 root root 4.0K Jan 21 19:19 ..
# -r-------- 1 10000000 10000000 1.7K Sep 27 2017 /Users/docker/.ssh/id_rsa
djbender / .bash_profile
Created April 10, 2019 19:09
docker-compose wrapper for dinghy's issue with taking down networks.
docker-compose() {
if [ "$1" == "down" ]; then
echo "Running \`docker-compose stop\` first"
/usr/bin/env docker-compose stop
/usr/bin/env docker-compose "$@"
djbender / docker-compose.yml
Created April 9, 2019 20:39
bitnami's jenkins config ready for use with dinghy
version: '2'
image: 'bitnami/jenkins:2'
- '8080:8080'
- '8443:8443'
- '50000:50000'
- 'jenkins_data:/bitnami'
djbender / attachment_upload_status.rb
Created March 14, 2019 17:51
example of wrapping an ActiveRecord class with a module that uses it so as to separate the behavior of AttachmentUploadStatus from the persistence concerns (and table name) of AttachmentUploadFailures since only failures are stored in the db.
# app/models/attachment_upload_status.rb
module AttachmentUploadStatus # no parent needed!
def self.cache_key(attachment)
def self.pending!(attachment)
Rails.cache.write(cache_key(attachment), 'pending', expires_in:
djbender / Gemfile
Created December 12, 2018 17:21 — forked from palkan/Gemfile
RSpec profiling with RubyProf and StackProf
gem 'stackprof', require: false
gem 'ruby-prof', require: false
djbender / thread.rb
Created March 25, 2018 14:58 — forked from alyssais/thread.rb
My really hacky livetweeting script. You pass in the ID of the tweet to continue the thread from.
require "yaml"
require "twitter"
config = YAML.load_file(File.expand_path("~/.trc")).dig("profiles", "qyliss").each_value.first
last_status = ARGV.fetch(0)
twitter = do |t|
t.consumer_key = config.fetch("consumer_key")
t.consumer_secret = config.fetch("consumer_secret")
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
djbender / init.lua
Created December 27, 2016 05:14 — forked from RichardForrester/init.lua
Karabiner Elements and Hammerspoon on MacOS Sierra
-- ln -s ~/repos/config/init.lua ~/.hammerspoon/init.lua
-- Global variable for the Command Mode
cMode ={}, "F17")
-- Global variable for Delete Mode
dMode ={}, 'F20')
-- Global variable for Select Mode
sMode ={}, 'F19')