Skip to content

Instantly share code, notes, and snippets.

View bdurand's full-sized avatar

Brian Durand bdurand

  • San Francisco, CA
View GitHub Profile
@bdurand
bdurand / .tm_properties
Created July 2, 2022 16:05
TextMate Properties
# Settings
fontName = "Menlo"
fontSize = "12"
exclude = '{$exclude,log/*,tmp/*,public/assets/*,*.log,*.dat}'
excludeDirectories = '{$excludeDirectories,log,tmp,public/assets,node_modules,vendor}'
include = "{$include,.circleci,.gitignore,.dockerignore,.travis.yml,.env,.github,.standard.yml}"
softWrap = false
@bdurand
bdurand / gist:a3f5b3016bccfd64a668cc81d4405db8
Last active January 4, 2022 00:05
puma-dev TLS certificate commands
security add-trusted-cert -k $(security login-keychain | xargs | sed -e 's/^"//' -e 's/"$//') ~/Library/Application\ Support/io.puma.dev/cert.pem
mkdir -p /usr/local/etc/openssl`ls -ld /usr/local/opt/openssl | egrep -o "@[0-9.]+"`/certs
cp ~/Library/Application\ Support/io.puma.dev/cert.pem /usr/local/etc/openssl`ls -ld /usr/local/opt/openssl | egrep -o "@[0-9.]+"`/certs/io.puma.dev.pem
/usr/local/opt/openssl/bin/c_rehash
@bdurand
bdurand / row_lock_test.rb
Created October 18, 2012 17:07
ActiveRecord Row Lock Test
require 'rubygems'
require 'active_record'
require 'logger'
# Run as `ruby row_lock_test.rb [mysql|postgresql]` to see current Rails behavior when two processes
# try to destroy a record at the same time.
#
# Run as `ruby row_lock_test.rb [mysql|postgresql] patch` to see the behavior desired in pull request
# https://github.com/rails/rails/pull/7965
#
@bdurand
bdurand / circleci_insights
Last active April 9, 2021 20:24
CircleCI Insights tool for comparing credits and runtimes.
#!/usr/bin/env ruby
# Script to get information from the CircleCI Insights API for the number of credits used and time
# taken for running workflows across one or more branches.
require "net/http"
require "json"
require 'optparse'
require 'optparse/time'
require 'set'
export EDITOR=/usr/bin/vi
eval "$(rbenv init -)"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{240}%1~%f%b %# '
export BUNDLER_EDITOR=mate
ssh-add -A 2>/dev/null
#!/bin/bash
# Run rubocop with automatic fixes on any new or modified git files
set -o errexit
# set -o xtrace
changed_files=`git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' | cat`
if [ "$changed_files" != "" ]; then
ruby_version=`cat .ruby-version | tr -d '[:space:]'`
#!/bin/bash
# Strip trailing whitespace from modified code files in git.
set -o errexit
# set -o xtrace
git diff --cached --name-only --diff-filter=ACM | egrep -e '\.(rb|js|css|scss|erb|html)$' | xargs sed -i '' -E 's/[[:space:]]+$//'
@bdurand
bdurand / pre_push_guard.sh
Last active January 9, 2020 21:31
Git pre-push hook to prevent you from accidentally pushing to important branches.
#!/bin/bash
# This script can be used as a git pre-push hook to guard against accidentally
# pushing to remote branches that may have special meaning and trigger other
# behavior. If you try to push to one of these branches, you will be prompted
# to confirm that is what you really meant to do.
set -o errexit
# set -o xtrace
@bdurand
bdurand / benchmark_bundle.rb
Created May 10, 2012 16:15
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'bundler'
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
@bdurand
bdurand / merge_branch
Last active October 5, 2018 17:52
Ruby script to manage merging and pushing branches.
#!/usr/bin/env ruby
# This script will handle refreshing your local git repository and merging in
# the latest changes from a remote branch on origin and then syncing the local
# branch back to origin (if applicable).
#
# This can be useful for such things as keeping your Pull Request branches in
# sync with the latest changes to master.
#
# Usage: `merge_branch [options] source [destination]