Skip to content

Instantly share code, notes, and snippets.

View cbartlett's full-sized avatar

Colin Bartlett cbartlett

View GitHub Profile
@cbartlett
cbartlett / gist:2093abd42296ddd51775
Last active December 22, 2023 09:26
Print Ruby Exception Hierarchy
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] ||= {}}
end
git log --author="Colin" --no-merges --pretty=format:"%Cgreen%cs%C(cyan) %h%Creset %s" --after="2021-08-01"
@cbartlett
cbartlett / exception_tree.rb
Created October 7, 2019 20:53
Prints out a list of the all the ruby exceptions in your app
# thanks to http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy/
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] ||= {}}
end
@cbartlett
cbartlett / app.json
Created February 28, 2019 21:02
dumping a database in review apps
{
"name": "some_app_name",
"scripts": {
"postdeploy": "[ \"$RAILS_ENV\" != \"TEST\" ] && pg_dump $PRODUCTION_DATABASE_URL | psql $DATABASE_URL && bundle exec rake db:migrate"
},
"env": {
"PRODUCTION_DATABASE_URL": { "required": true },
"SOME_VAR": { "required": true },
"RELEASE_STAGE": "review",
},
@cbartlett
cbartlett / gist:505152c4b06aa309d74b7c3902be72a4
Created November 26, 2018 18:47
Disable Google Suggested Replies
[aria-label^="Suggested reply"] {
display: none;
}
@cbartlett
cbartlett / remove.sh
Created October 20, 2018 16:38
Remove unused local git branches
git branch --merged master | grep -v ^\* | xargs git branch -d
@cbartlett
cbartlett / upsert.rb
Created September 2, 2018 20:24
ActiveRecord upsert extension
module Upsert
extend ActiveSupport::Concern
class_methods do
def upsert(key, attributes)
begin
create(attributes)
rescue ActiveRecord::RecordNotUnique => e
where(key => attributes[key]).
first.tap do |obj|
@cbartlett
cbartlett / gist:1b9042fcb93aecd187915d59e6b07462
Created August 26, 2018 11:55
Trello card number style tweak
.card-short-id {
display: inline !important;
padding: 0 4px;
margin-right: 4px;
background-color: #E2E4E6 ;
color: #929292 ;
}
@cbartlett
cbartlett / convert_repo.sh
Created July 8, 2018 15:58
Convert Ruby hash syntax
find . -name \*.rb -exec perl -p -i -e 's/([^:]):(\w+)\s*=>/\1\2:/g' {} \;
@cbartlett
cbartlett / pr.md
Created April 29, 2017 22:01 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: