Skip to content

Instantly share code, notes, and snippets.

The only gist I have.
@kazimzaidi
kazimzaidi / airbrake_filters.rb
Created May 9, 2016 04:39
Monkey patch airbrake to include response from Facebook API calls, when Facebook throws a 400 or 500 (RestClient::BadRequest)
# When FB throws a 400 (e.g. while calling Graph API), the real error is inside the response body.
# This initializer intends to report that to Airbrake in a way that this response doesn't get lost.
# params would include __rest_client key that contains JSON-parsed response body of the error
# Also, error message would include the actual error message from FB, instead of just a boring "400: Bad Request"
module Airbrake
class Notifier
def send_notice_with_extra_logging(*args)
exception = args[0]
params = args[1]
@kazimzaidi
kazimzaidi / pre-commit
Created August 28, 2018 02:23
git pre-commit hook to run rubocop on changed files
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED