Skip to content

Instantly share code, notes, and snippets.

@pgib
pgib / Dockerfile
Last active April 6, 2023 01:23
Run Jekyll in Docker
FROM ruby:3.2-bullseye AS build
WORKDIR /jekyll
RUN bundle config set --global path /vendor
RUN bundle config set --global without development
COPY Gemfile Gemfile.lock /jekyll
RUN bundle install
#!/bin/bash
# based on https://github.com/Skedulo/aws-instance-connect-proxy
set -eu
if [ $# -lt 2 ] ; then
echo "Usage: $0 [--profile profile] [--region region] [--key key] [--filter filterkey] [--value filtervalue] user host [port]"
exit
fi
rmb()
{
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
@pgib
pgib / README.md
Created May 21, 2020 20:23
Clean up the bloated Backblaze bzfileids.dat

Place in /Library/Backblaze.bzpkg/bzdata/bzbackup, and run with:

ruby purge_nonexistent.rb

It will process bzfileids.dat placing any file that exists in bzfileids.dat-found and any missing file in bzfileids.dat-missing. You can then back up your original file and replace it with bzfileids.dat-found.

My original file was almost 1.4GB. It had grown so large that the backup would cause all my fans spin and it never seemed to complete. Backblaze support suggested I delete my entire backup with them and start over. After running this script, my new bzfileids.dat file is 301MB. Still huge, but about 1/5th the size. The backup seemed to go much more smoothly.

@pgib
pgib / pre-commit
Last active August 11, 2022 23:52
CircleCI precommit hook
#!/usr/bin/env bash
# Slightly modified from: https://circleci.com/blog/circleci-hacks-validate-circleci-config-on-every-commit-with-a-git-hook/
# The following line is needed by the CircleCI Local Build Tool (due to Docker interactivity)
exec < /dev/tty
# Only validate if we've changed the .circleci/config.yml file
if git diff --cached --name-only | grep --quiet ".circleci/config.yml"; then
# Make sure we have the circleci utility installed
# https://circleci.com/docs/local-cli
@pgib
pgib / apod.sh
Created May 23, 2012 22:38 — forked from schallis/apod.sh
Automatically download NASA Astronomy Pictures of the Day
# Download the latest pic of the day from NASA and delete or archive any
# previous ones in a specified directory. Optionally create a copy of the most
# current picture to allow OSX to pick up pictures as wallpapers
#
# Steve Challis 2011
# http://schallis.com/2011/mar/20/nasa-astronomy-picture-of-the-day-background/
# Get a fresch picture from NASA
todays_pic=`ruby -rubygems latest_nasa_photo.rb`
@pgib
pgib / bbedit_colours.sh
Created May 6, 2011 19:51
My BBEdit Color Scheme
defaults write com.barebones.bbedit Color:Background -string "rgb(0,0,0)"
defaults write com.barebones.bbedit Color:CTagsIdentifier -string "rgb(57825,39937,11422)"
defaults write com.barebones.bbedit Color:ColorAttributesSeparately -string 1
defaults write com.barebones.bbedit Color:Comment -string "rgb(21845,21845,21845)"
defaults write com.barebones.bbedit Color:Comment:Ruby -string "rgb(34992,34992,34992)"
defaults write com.barebones.bbedit Color:Foreground -string "rgb(65535,65535,65535)"
defaults write com.barebones.bbedit Color:Foreground:CSS -string "rgb(56342,56342,56342)"
defaults write com.barebones.bbedit Color:GuideContrast -string 7
defaults write com.barebones.bbedit Color:HTMLAnchor -string "rgb(43690,0,0)"
defaults write com.barebones.bbedit Color:HTMLAttributeName -string "rgb(57528,45076,5799)"
@pgib
pgib / nginx.sh
Created November 9, 2019 18:40
nginx startup script for Amazon Linux 2
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: nginx initscript
# Description: nginx
### END INIT INF
@pgib
pgib / Gemfile
Created December 14, 2018 21:14
Sign an S3 URL
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'aws-sdk'
@pgib
pgib / .tmux.conf
Last active December 2, 2017 09:54
Nice tmux copy and paste using OS X clipboard
# =======================================================================
# vim-style copy and paste
setw -g mode-keys vi
bind ] paste-buffer
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -t vi-copy Space rectangle-toggle
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter