Skip to content

Instantly share code, notes, and snippets.

@starrhorne
starrhorne / main.rs
Created Jul 6, 2017
The `use errors::*` in mymodule causes an unused import warning
View main.rs
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
mod errors {
error_chain!{}
}
use errors::*;
View gist:149bce4ae24548442334
" begin script to prevent pase over from replacing the default register
" contents
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
@starrhorne
starrhorne / test.bash
Created Jun 21, 2013
This is how you generate a test exception from your local computer, when you're using the heroku addon. Be sure to replace the api key below with your real API key, as found on the project settings page :)
View test.bash
rake honeybadger:test HONEYBADGER_API_KEY=12345
@starrhorne
starrhorne / honeybadger.rb
Created Jun 21, 2013
Sample honeybadger initializer for heroku
View honeybadger.rb
Honeybadger.configure do |config|
config.api_key = ENV['HONEYBADGER_API_KEY']
end
@starrhorne
starrhorne / gist:5824347
Created Jun 20, 2013
How to send an error to HB manually
View gist:5824347
begin
raise "some error"
rescue => e
# Use one of the two methods below. Not both :)
# Use this to ALWAYS send the error to honeybadger regardless of error class
Hoenybadger.notify(e)
# This will only send the error if it doesn't match any of the exclusion rules
@starrhorne
starrhorne / emails_controller.rb
Last active Dec 13, 2015
Example Incoming Email Receiver for a Rails Application
View emails_controller.rb
# app/controllers/emails_controller.rb
class EmailsController < ActionController::Base
def create
if EmailToSmsReceiver.receive(request)
render :json => { :status => 'ok' }
else
render :json => { :status => 'rejected' }, :status => 403
end
end
end
@starrhorne
starrhorne / sample_email_receiver.rb
Last active Dec 13, 2015
Example of how to use the Incoming! gem.
View sample_email_receiver.rb
# First, you define an email receiver class
class EmailReceiver < Incoming::Strategies::CloudMailin
def receive(mail)
puts %(Got message from #{mail.to.first} with subject "#{mail.subject}")
end
end
# Then you feed it a Rack::Request object. And you're done.
req = Rack::Request.new(env)
result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com with subject "hello world"
View gist:4520447
Honeybadger.configure do |config|
# Will send session["sensitive_key"] = "FILTERED" to Honeybadger
config.params_filters << "sensitive_key"
end
View gist:2520717
Delivered-To: starr@chromahq.com
Received: by 10.52.174.78 with SMTP id bq14csp20270vdc;
Sat, 28 Apr 2012 10:31:46 -0700 (PDT)
Received: by 10.216.135.225 with SMTP id u75mr8769804wei.97.1335634305296;
Sat, 28 Apr 2012 10:31:45 -0700 (PDT)
Return-Path: <mandujano.david@yahoo.com>
Received: from nm7-vm0.bullet.mail.ird.yahoo.com (nm7-vm0.bullet.mail.ird.yahoo.com. [77.238.189.222])
by mx.google.com with SMTP id ei5si7755970wid.4.2012.04.28.10.31.44;
Sat, 28 Apr 2012 10:31:45 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of mandujano.david@yahoo.com designates 77.238.189.222 as permitted sender) client-ip=77.238.189.222;