Skip to content

Instantly share code, notes, and snippets.

View phil-monroe's full-sized avatar

Phil Monroe phil-monroe

View GitHub Profile
@phil-monroe
phil-monroe / ruby-install.sh
Created February 20, 2013 19:28
Things I did to install Ruby 1.9.3 on OS X Mountain Lion (10.8)
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(rbenv init -)"' >> ~/.zprofile
exec $SHELL -l
brew install readline openssl
@phil-monroe
phil-monroe / rufus.rb
Last active December 12, 2015 02:58
Embedding rufus scheduler within sidekiq. Put this file into your rails `config/initializers` folder.
require 'rufus/scheduler'
require 'redis'
require 'redis-lock'
if $0 == 'sidekiq'
$redis = Redis.new
def run_rake task
$redis.lock_for_update(task, 100, 0) do
puts "scheduling #{task}"
@phil-monroe
phil-monroe / permissions.sql
Created January 30, 2013 00:05
Gist to test postgres permissions so multiple apps can connect and use the same DB in a namespaced way
--- cleanup
drop database test;
drop user piston;
drop user crankshaft;
drop user identified;
--- setup
create database test;
\c test
@phil-monroe
phil-monroe / tools.md
Last active December 11, 2015 07:28
Tools that I find useful and use everyday.

Development Tools

Productivity Tools

Asana

By far the best ToDo list I have ever used.

  • asana.com
  • Asana.app - Fluid app to make the Asana web interface seem like a native OS X App.
@phil-monroe
phil-monroe / haproxy
Created January 11, 2013 01:47
HAProxy init.d script.
#!/usr/bin/env bash
# haproxyd
# Script to start|stop|restart haproxy from /etc/init.d/
# By Phil Monroe.
HAPROXY_PATH=/usr/sbin
HAPROXY_DAEMON=$HAPROXY_PATH/haproxy
HAPROXY_CONFIG=/etc/haproxy/haproxy.cfg
test -x $HAPROXY_DAEMON || exit 0
@phil-monroe
phil-monroe / install.sh
Last active May 10, 2019 15:02
Parallel, Multiple File Remote File Copy. Fills up network bandwidth while copying many files
#!/bin/bash
mkdir -p ~/bin/
curl -s -L https://gist.github.com/raw/4477190/pmrcp.rb > ~/bin/pmrcp
chmod +x ~/bin/pmrcp
@phil-monroe
phil-monroe / rails_2_papertrail.rb
Created December 19, 2012 00:30
Things needed to log rails to papertrail.
class MultiIO
def initialize(*targets)
@targets = targets
end
def write(*args)
puts "writing"
@targets.each { |t| t.write(*args) }
end
@phil-monroe
phil-monroe / clone_vm.rb
Created November 14, 2012 19:51
Clone vm with IP
identity = RbVmomi::VIM.CustomizationLinuxPrep({
hostName: RbVmomi::VIM.CustomizationFixedName(name: "test"),
domain: "test.com"
})
global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings({
dnsServerList: ["172.31.10.37"],
dnsSuffixList: ["identified.com"]
})
@phil-monroe
phil-monroe / db_lag.rb
Created September 29, 2012 00:21
Calculate the lag in WAL transmission for postgres databases
# math based on http://eulerto.blogspot.com/2011/11/understanding-wal-nomenclature.html
dbname = ""
dbuser = ""
host_master = ""
host_slave = ""
previous_recieved_lags = []
previous_replated_lags = []
@phil-monroe
phil-monroe / Rails Models.rb
Created August 14, 2012 23:45
Collect all Model Classes
def models
Module.constants.inject([]) do |models, k|
klass = Kernel.const_get k
models << klass if klass.respond_to? :ancestors and klass.ancestors.include? ActiveRecord::Base
models
end
end