Skip to content

Instantly share code, notes, and snippets.

@joshuap
joshuap / openpgp.md
Created December 2, 2022 19:24
keyoxide proof

openpgp4fpr:4E5DC0D7B51CF6AB3664FCD83C185ED56E760F73

@joshuap
joshuap / app.js
Created December 10, 2020 18:24
Koa middleware for Honeybadger
// https://github.com/honeybadger-io/honeybadger-node
// https://github.com/koajs/koa/blob/master/docs/guide.md
// https://github.com/koajs/koa/blob/master/docs/error-handling.md
const Honeybadger = require('honeybadger')
const Koa = require('koa')
const app = new Koa()
// Should probably be the first middleware you use
app.use(async (ctx, next) => {
<!-- Do Not Track -->
<script type="text/javascript">
// Global
window.trackingEnabled = function() {
var dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
return !(dnt === "1" || dnt === "yes");
}();
</script>
<!-- Google Tag Manager, Segment, etc. -->
@joshuap
joshuap / rails_lamby_notes.md
Last active February 21, 2022 09:00
Deploy a new Rails app to AWS Lambda using Lamby
@joshuap
joshuap / jumpstart_heya.md
Last active December 9, 2021 15:50
Configuring Jumpstart to send a welcome sequence w/ Heya
package main
import "errors"
import "fmt"
import "github.com/honeybadger-io/honeybadger-go"
func notifyHoneybadger(err error) {
if err == nil {
return
}
@joshuap
joshuap / tag.js
Created August 5, 2019 21:21
Netlify function to tag subscribers in ConvertKit
// Netlify function to tag subscribers in ConvertKit
// https://www.netlify.com/products/functions/
// POST to /.netlify/functions/tag?id={subscriberId} with JSON array of tag ids: `[{tagId}, {tagId}, ...]`
const request = require("request-promise");
const apiKey = process.env.CONVERTKIT_API_KEY;
const apiSecret = process.env.CONVERTKIT_API_SECRET;
exports.handler = function(event, context, callback) {
@joshuap
joshuap / gist:5c0b3c6cb0bfb150cef3caf98cf9c6f6
Created April 4, 2019 22:08
Report correct controller name and action to Honeybadger w/ custom Rails exceptions app
Honeybadger.configure do |config|
config.before_notify do |notice|
# break out of our hook if component is not our errors controller
break if notice.component != 'errors'
# correct the component and action info based on the url
params = Rails.application.routes.recognize_path(notice.url)
# => {:controller=>"page", :action=>"index"}
notice.controller = params[:controller]
notice.action = params[:action]
@joshuap
joshuap / application_job.rb
Created March 19, 2019 16:15
Report ActiveJob exceptions to Honeybadger (default backend/unsupported backends)
# app/jobs/application_job.rb
class ApplicationJob < ActiveJob::Base
include HoneybadgerActiveJob
end
@joshuap
joshuap / redis.rb
Created November 30, 2018 01:31
Disable dangerous Redis commands in Ruby
# config/initializers/redis.rb
require 'redis'
# Disables the `flushdb` and `flushall` commands.
class Redis
module DangerousCommands
def flushdb
raise 'This is EXTREMELY DANGEROUS! If you really want to EMPTY THE ENTIRE DATABASE, do it from `redis-cli`.'
# You could call `super` here if you want to allow access in some circumstances.
end