Skip to content

Instantly share code, notes, and snippets.

@starrhorne
starrhorne / main.rs
Created July 6, 2017 22:03
The `use errors::*` in mymodule causes an unused import warning
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
mod errors {
error_chain!{}
}
use errors::*;
#!/usr/bin/python
import sys
from fontTools import ttLib
FONT_SPECIFIER_NAME_ID = 4
FONT_SPECIFIER_FAMILY_ID = 1
def shortName( font ):
"""Get the short name from the font's names table"""
name = ""
family = ""
@starrhorne
starrhorne / a.rb
Created September 8, 2013 18:04
Sample
a=1
@starrhorne
starrhorne / test.bash
Created June 21, 2013 15:46
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 :)
rake honeybadger:test HONEYBADGER_API_KEY=12345
@starrhorne
starrhorne / honeybadger.rb
Created June 21, 2013 15:32
Sample honeybadger initializer for heroku
Honeybadger.configure do |config|
config.api_key = ENV['HONEYBADGER_API_KEY']
end
@starrhorne
starrhorne / gist:5824347
Created June 20, 2013 16:35
How to send an error to HB manually
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 December 13, 2015 23:38
Example Incoming Email Receiver for a Rails Application
# 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 December 13, 2015 23:38
Example of how to use the Incoming! gem.
# 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"
Honeybadger.configure do |config|
# Will send session["sensitive_key"] = "FILTERED" to Honeybadger
config.params_filters << "sensitive_key"
end
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;