Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile
@pboling
pboling / plpgsql.rake
Last active October 12, 2015 18:56 — forked from rietta/plpgsql.rake
Are you using PostgreSQL and don't want to make your app run as PostgreSQL super user, then add this custom rake task to your `lib/tasks` folder and be happy.
#
# PostgreSQL writes two optional commands to the database schema
# file, called db/structure.sql, that can only be run as a root
# database user. These are not needed actually, so comment them
# out automatically
#
# CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
# COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
#
namespace :db do

I upgraded to El Capitan, with Homebrew & Ruby, and this is how I did it flawlessly.

... and Xcode and Java, etc.

Prepare

If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.

Hardware

@pboling
pboling / PhantomJS Install.md
Last active July 23, 2019 17:54
How to install old PhantomJS 1.8.2 on Mac OS X
@pboling
pboling / prepare-commit-msg
Last active September 19, 2015 08:28
commit message git hook: Adds story type and story ID to the end of each commit
#!/usr/bin/env ruby
# vim: set syntax=ruby
# branches should be named like:
# <story_type>/<story_id>-explosion-in-the-fudge-factory-spec-suite-fix
# where story type is one of "hotfix", "bug", "feature", "candy"
#
branch = `git branch 2> /dev/null | grep -e ^* | awk '{print $2}'`
regex = /^(?<story_type>(hotfix)|(bug)|(feature)|(candy))\/(?<story_id>\d{8,})-.+\Z/
match_data = branch.match(regex)
@pboling
pboling / slim_vs_haml.md
Last active February 11, 2024 16:33
Slim vs Haml

Analysis of Slim vs. Haml Project Health

  • Static data as of April 13, 2015, some updates as of October 1, 2015
# Metric Haml Slim Winner
1 Issues Open Issues Open Issues Slim
2 Stars Stars Open Issues Slim
3 Quality Code Climate technical debt Code Climate maintainability -- Haml
4 Test Coverage ![Code Climate coverage](https://i
@pboling
pboling / boolean.rb
Created April 3, 2015 00:01
TrueClass & FalseClass => Boolean Comparable hack
module Boolean
include Comparable
# true > false
def <=>(other)
raise ArgumentError, "Do not know how to compare #{other.class} with TrueClass and FalseClass" unless [TrueClass, FalseClass].include?(other.class)
other ? (self ? 0 : -1) : (self ? 1 : 0)
end
end
# Download all repos for an organization
ORG_NAME=trumaker
curl -s https://api.github.com/orgs/$ORG_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
# Download all repos for a user
USER_NAME=pboling
curl -s https://api.github.com/users/$USER_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@pboling
pboling / nested_filters.rb
Last active August 29, 2015 14:16
Concern::NestedFilters
module Concern
module NestedFilters
extend ActiveSupport::Concern
CACHE_EXPIRATION = 1.days
NULL_SORT = "LAST"
NestedFilter = Struct.new(:filter_klass, :filter_param_key, :filter_name, :filter_options)
NestedFilterOption = Struct.new(:id, :name)
included do
@pboling
pboling / api_logger.rb
Last active August 29, 2015 14:13 — forked from dblock/api_logger.rb
require 'ext/grape_middleware_logger'
module TrumakerAPI
module Middleware
class ApiLogger < Grape::Middleware::Logger
def after
logger.info "[api] Requested#{request_log}" if !request_log.blank?
if Rails.env.development?
response_body = JSON.parse(response.body.first)
@pboling
pboling / phone_finder.rb
Last active August 29, 2015 14:11
Find Phone Numbers in Dirty Database
# SQL_PHONE_NORMALIZER Example:
# Lead.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'leads', column_name: 'phone', phone: '(555) 760-2012'))
# User.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'users', column_name: 'phone', phone: '555-223-4027'))
#
# AREL_PHONE_NORMALIZER Example:
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: Lead.where(email: 'peter.boling@example.org'), table: 'leads', column_name: 'phone', phone: '(555) 760-2012')
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: User.where(email: 'peter.boling@example.org'), table: 'users', column_name: 'phone', phone: '555-223-4027')
#
# See: https://coderbits.com/posts/pCl7og
module PhoneFinder