Skip to content

Instantly share code, notes, and snippets.

View djbender's full-sized avatar
🕵️‍♂️

Derek Bender djbender

🕵️‍♂️
View GitHub Profile
@djbender
djbender / rename-docker-volume.sh
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
djbender / README.md
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
djbender / docker-run-mount-test.sh
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
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
fi
/usr/bin/env docker-compose "$@"
}
@djbender
djbender / docker-compose.yml
Created April 9, 2019 20:39
bitnami's jenkins config ready for use with dinghy
version: '2'
services:
jenkins:
image: 'bitnami/jenkins:2'
ports:
- '8080:8080'
- '8443:8443'
- '50000:50000'
volumes:
- 'jenkins_data:/bitnami'
@djbender
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)
"attachment_upload:#{attachment.global_id}:status"
end
def self.pending!(attachment)
Rails.cache.write(cache_key(attachment), 'pending', expires_in: 1.day.from_now)
end
@djbender
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
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 = Twitter::REST::Client.new do |t|
t.consumer_key = config.fetch("consumer_key")
t.consumer_secret = config.fetch("consumer_secret")
#!/bin/bash
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@djbender
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 = hs.hotkey.modal.new({}, "F17")
-- Global variable for Delete Mode
dMode = hs.hotkey.modal.new({}, 'F20')
-- Global variable for Select Mode
sMode = hs.hotkey.modal.new({}, 'F19')