Skip to content

Instantly share code, notes, and snippets.

View jeremywadsack's full-sized avatar

Jeremy Wadsack jeremywadsack

View GitHub Profile
jeremywadsack /
Last active August 29, 2015 14:05
Change git remote after renaming origin organization at GitHub
# A one-line script to change the origin organization name.
# After renaming our organization at GitHub, I had 25 repos I needed to update locally.
# This script finds the current "origin", removes it and replaces it with a new one
# with the organization changed.
# Just change OLD_ORG and NEW_ORG below to the old and new organization names and run
# this in each repository.
f=`git remote -v | grep '^origin' | cut -c 8- | cut -d' ' -f 1 | uniq`; git remote remove origin; git remote add origin ${f/OLD_ORG/NEW_ORG}
jeremywadsack / rails_3.2.19
Created November 25, 2014 23:01
Postgres logs from rspec run under rails 3.2.19 and 4.1.8
[unknown]LOG: connection received: host=::1 port=58397
my-app-test LOG: connection authorized: user=jeremywadsack database=my-app-test
my-app-test LOG: statement: set client_encoding to 'UTF8'
my-app-test LOG: statement: set client_encoding to 'utf8'
my-app-test LOG: statement: SET client_min_messages TO 'WARNING'
my-app-test LOG: statement: SHOW client_min_messages
my-app-test LOG: statement: SET client_min_messages TO 'panic'
my-app-test LOG: statement: SET standard_conforming_strings = on
my-app-test LOG: statement: SET client_min_messages TO 'warning'
my-app-test LOG: statement: SET time zone 'UTC'
jeremywadsack /
Created July 14, 2015 23:28
Covert UTC time to local time on browser
# A jQuery plugin to convert UTC times to local times on the browser.
# You can apply this to any element on the page like this:
# $('#message').covertToLocalDate();
# This looks for one or more date-time strings in the original element
# and replaces them. The existing dates must be in the format
# 2015-07-14 16:30:00 UTC
# It replaces them with an <abbr> element (which is usually styled with
jeremywadsack / assets.rake
Last active May 5, 2016 18:43
Rails 4.2, Capistrano 3.4 local asset precompilation using rsync
# lib/capistrano/tasks/assets.rake
namespace :deploy do
desc "Precompile assets locally and then rsync to web servers"
task :compile_assets => [:set_rails_env] do
run_locally do
with rails_env: :production do
execute "bundle exec rake assets:precompile"
jeremywadsack /
Created November 16, 2016 18:49
Get postgres memory usage and send it to graphite
#!/usr/bin/env bash
# Uses du to track the amount of disk space that postgres is using to hold queries that don't fit in memory.
# Uses smem to track USS, PSS, and RSS for the postrgres user for various views of how much memory it is using.
# Add this to crontab to run every minute.
# * * * * * /path/to/
# Configure for your graphite host
jeremywadsack / all-memory-deployment.yaml
Last active December 5, 2016 16:39
Kubernetes configuration files for kubernetes/kubernetes#37995 issue
apiVersion: extensions/v1beta1
kind: Deployment
name: all-memory-deployment
replicas: 1
app: bash
jeremywadsack / load_balancer
Created March 28, 2017 21:54
Create a Google Cloud HTTPS Load Balancer (with Cloud CDN) that fronts a Kubernetes service hosted in a GKE cluster exposed on a NodePort.
#!/usr/bin/env bash
# TODO: Fill in these details for the cluster and project:
# The GKE cluster
# Assume the app is named the same as the working directory
APP=$(basename $(pwd))
# The GKE tag that identifies the cluster nodes
# Expects to have `tls.crt` and `tls.key` in this folder
jeremywadsack /
Last active June 8, 2017 17:56
K8s resource requests by node
# Kuberentes doesn't provide information about resource resquest in the `get` command, even in JSON mode
# This is the best I've got for getting a report of the total resource request allocation per node
kubectl describe nodes | egrep -A 4 '^Name:|^Allocated resources' | egrep '^Name:|Requests|%)'
jeremywadsack / gem_cleaner.rb
Created August 28, 2017 19:59
Remove unused rvm gemsets
# Safely cleans up your rvm Gemsets with the following:
# - Deletes gemsets associated with older rubies than the latest (if more than one)
# - Runs `bundle clean` to remove unused gems in latest gemsets
# - Removes rubies (and related gemsets) that are no longer used by a gemset
gemsets = Dir["#{ENV['HOME']}/.rvm/gems/*"].select do |folder|
gemsets = do |folder|
jeremywadsack / bigquery-schema-load.rb
Created January 4, 2018 00:40
Schema#load implementation suggestion
class Schema
def load source
add_fields_to_schema(schema, source_fields)
def add_fields_to_schema schema, fields