Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️

Derek Bender djbender

🕵️‍♂️
View GitHub Profile
@djbender
djbender / README.md
Last active Apr 25, 2020
install pigz on boot2docker tiny core linux environments (i.e. dinghy) for speedup on docker image layer extraction
View README.md

connect to the boot2docker image via dinghy ssh

@djbender
djbender / docker-run-mount-test.sh
Last active Jan 21, 2020
a minimal repro for mounting individual files like the id_rsa file into a container
View docker-run-mount-test.sh
#!/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 Apr 10, 2019
docker-compose wrapper for dinghy's issue with taking down networks.
View .bash_profile
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 Apr 9, 2019
bitnami's jenkins config ready for use with dinghy
View docker-compose.yml
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 Mar 14, 2019
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.
View attachment_upload_status.rb
# 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 Dec 12, 2018 — forked from palkan/Gemfile
RSpec profiling with RubyProf and StackProf
View Gemfile
gem 'stackprof', require: false
gem 'ruby-prof', require: false
@djbender
djbender / thread.rb
Created Mar 25, 2018 — forked from alyssais/thread.rb
My really hacky livetweeting script. You pass in the ID of the tweet to continue the thread from.
View thread.rb
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")
View ocr-shot.sh
#!/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 Dec 27, 2016 — forked from RichardForrester/init.lua
Karabiner Elements and Hammerspoon on MacOS Sierra
View init.lua
-- 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')
View README
I assume that the bot user is already in some channel.
In my case I had the bot invited to #bot-test in a slack I have admin privileges for.
$ SLACK_API_KEY=xoxb-XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXX ruby test-slack.rb
You can’t perform that action at this time.