Skip to content

Instantly share code, notes, and snippets.

View cbartlett's full-sized avatar

Colin Bartlett cbartlett

View GitHub Profile
View check.rb
def check_grade(grade)
puts "Checking #{grade}"
case grade
when 90..100
puts "A"
when 80...90
puts "B"
puts "loser"
cbartlett / info.plist
Created October 13, 2015 23:55 — forked from mlynch/info.plist
Disable App Transport Security in iOS 9
View info.plist
This disables app transport security and allows non-HTTPS requests.
Note: it is not recommended to use non-HTTPS requests for sensitive data. A better
approach is to fix the non-secure resources. However, this patch will work in a pinch.
To apply the fix in your Ionic/Cordova app, edit the file located here:
And add this XML right before the end of the file inside of the last </dict> entry:
#! /bin/bash
# directory to save backups in, must be rwx by postgres user
YMD=$(date "+%Y-%m-%d")
mkdir -p $DIR
cd $DIR
# make database backup
View squirt
#!/usr/bin/env ruby
require 'json'
if ARGV.length < 3 then
puts "Usage: squirt <filename> <channel> <comment>"
token = ENV['TOKEN'] || ""
cbartlett / average_deploy.rb
Created April 16, 2015 15:42
How often do you deploy to Heroku?
View average_deploy.rb
#!/usr/bin/env ruby
# Copyright 2015 Colin Bartlett, Inc.
# MIT Licensed:
# Usage: ./average_deploy.rb your-heroku-app-name
require 'time'
dates = `heroku releases -n 50 -a #{ARGV[0]} | grep Deploy`
View gist:51f487f475418be834c3
Error detected while processing User Auto commands for "ProjectionistDetect":
E716: Key not present in Dictionary: rake_command('static'))}}) | endif
E116: Invalid arguments for function split(rails#app().rake_command('static'))}}) | endif
E116: Invalid arguments for function projectionist#append
UpdateLastColumn failed to find bufnr 9 in w:BufKillList
UpdateLastColumn failed to find bufnr 9 in w:BufKillList
cbartlett / gist:7d2f027650ed0e74cbd3
Created November 11, 2014 16:36
removes orphaned records
View gist:7d2f027650ed0e74cbd3
model_base = Rails.root.join('app/models')
Dir[model_base.join('**/*.rb').to_s].each do |filename|
# get namespaces based on dir name
namespaces = (File.dirname(filename)[model_base.to_s.size+1..-1] || '').split('/').map{|d| d.camelize}.join('::')
# skip concerns folder
next if namespaces == "Concerns"
View gist:1e5f540acec9ab2cb21a
require 'spec_helper'
describe Event do
let(:event) { FactoryGirl.create(:event) }
let(:summer_long_event) { FactoryGirl.create(:summer_long) }
describe '.summer_long' do
subject { described_class.summer_long }
it { should include(summer_long_event) }
it { should_not include(event) }
View gist:ad09c2d63224fd2759c5
if [ -z "$REMOTES" ]; then
REMOTES=$(git remote);
REMOTES=$(echo "$REMOTES" | xargs -n1 echo)
cbartlett / gist:2093abd42296ddd51775
Last active November 14, 2023 02:43
Print Ruby Exception Hierarchy
View gist:2093abd42296ddd51775
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
next if cls.superclass == SystemCallError # avoid dumping Errno's
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}