Skip to content

Instantly share code, notes, and snippets.

@joshuap
joshuap / gist:11292337
Last active August 29, 2015 14:00
Google script to analyze SaaS cancellation emails and deliver a word cloud to the account owner. Install into https://script.google.com
// Requires the Word Cloud Lib extension to be installed prior to running:
// https://sites.google.com/site/scriptsexamples/custom-methods/other-libraries/word-cloud-library
function deliverCancellationThemes() {
var threads = GmailApp.search('subject:User Cancelled', 0, 100);
var messagesforCancellationThreads = GmailApp.getMessagesForThreads(threads);
var input = '';
for(i in messagesforCancellationThreads) {
for(j in messagesforCancellationThreads[i]) {
var body = messagesforCancellationThreads[i][j].getPlainBody();
Logger.log(body);
@joshuap
joshuap / .gitconfig
Created May 2, 2014 23:44
Josh's .gitconfig
[core]
excludesfile = ~/.gitignore
editor = mate -w
whitespace = trailing-space,space-before-tab
[apply]
whitespace = fix
[color]
ui = true ;doesnt work for some reason ...
@joshuap
joshuap / Gemfile
Last active August 29, 2015 14:05
CarrierWave
# File uploads
gem 'carrierwave'
# Image processing
gem 'mini_magick'
# S3 file storage
gem 'fog'
@joshuap
joshuap / block_allocations.rb
Created March 6, 2015 20:00
Object allocations when calling block parameter vs. yielding implicitly.
require 'allocation_stats'
GROUP_BY = [:sourcefile, :sourceline, :class]
def block_without_param
yield
end
def block_with_param(&block)
block.call
@joshuap
joshuap / assigned.json
Last active August 29, 2015 14:16
Example outage payloads for Honeybadger WebHooks
{"event":"assigned","message":"[Crywolf/production] RuntimeError assigned to Benjamin Curtis by Joshua Wood","actor":{"id":3,"email":"josh@hintmedia.com","name":"Joshua Wood"},"fault":{"project_id":1717,"klass":"RuntimeError","component":"pages","action":"caused_exception","environment":"production","resolved":true,"ignored":false,"created_at":"2015-07-21T20:06:20.046Z","comments_count":4,"message":"This is the third cause raised at 2015-07-21 13:06:19 -0700","notices_count":1,"last_notice_at":"2015-07-21T20:06:20.000Z","tags":[],"id":14108233,"assignee":"ben@bencurtis.com"},"assignee":{"id":1,"email":"ben@bencurtis.com","name":"Benjamin Curtis"}}
@joshuap
joshuap / environment.rb
Created April 29, 2011 19:37
Net:HTTP enabled URI Validator for Rails 3
...
require 'uri_validator'
@joshuap
joshuap / mp3_update
Created February 21, 2012 19:08
Systematically retrieve audio files from popular mp3 blogs
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
class Mp3Crawler
def initialize(url)
@data = Nokogiri::XML(open(url))
end
def links
@joshuap
joshuap / custom_events.js.erb
Created August 24, 2012 00:50
Rails 3.2 route-based custom JQuery events
$(function(){
var controllers = <%=
actions = {}
Rails.application.routes.routes.each do |route|
if route.defaults.include?(:controller)
actions[route.defaults[:controller]] ||= []
actions[route.defaults[:controller]] << route.defaults[:action] if route.defaults.include?(:action)
end
end
actions.to_json %>;
@joshuap
joshuap / honeybadger.rb
Created October 7, 2012 01:46
Standard Honeybadger initializer
Honeybadger.configure do |config|
config.api_key = 'asdf'
end
@joshuap
joshuap / honeybadger.rb
Created December 28, 2012 18:28
Using Honeybadger with Sidekiq
# config/initializers/honeybadger.rb
Honeybadger.configure do |config|
...
config.async do |notice|
WorkingBadger.perform_async(notice.to_json)
end
end