Skip to content

Instantly share code, notes, and snippets.

View lardcanoe's full-sized avatar
🏃‍♂️
Figuring out life.

Steve Frank lardcanoe

🏃‍♂️
Figuring out life.
View GitHub Profile
@lardcanoe
lardcanoe / rollbar_transform.rb
Created September 1, 2016 02:37
A transform function for Rollbar to remove text that creates new items
def transform_payload(opts)
ex_msg = opts[:payload]['data'][:body][:trace][:exception][:message] rescue nil
if ex_msg =~ /#<(.*)(:0x[a-f0-9]{8})>$/
# Convert
# "undefined method `blow_up!' for #<Customer:0x7b417d08>"
# to
# "undefined method `blow_up!' for #<Customer>"
# to prevent rollbar storms when each message has a different hash
opts[:payload]['data'][:body][:trace][:exception][:message].gsub! $2, ''
end
@lardcanoe
lardcanoe / health_pulse_api.py
Created April 21, 2015 22:40
Access Health Check Pulse through API
#!/usr/bin/env python
import urlparse
import urllib2
import json
import os
import pprint
API_ENDPOINT = "https://chapi.cloudhealthtech.com/pulse/"
API_KEY = os.getenv('API_KEY')
@lardcanoe
lardcanoe / example.rb
Last active August 29, 2015 14:17
Trying to get multiple threads working with March Hare
require 'march_hare'
connection = MarchHare.connect(:host => 'localhost', :thread_pool_size => 8)
channel = connection.create_channel
channel.prefetch = 10
exchange = channel.exchange('test', :type => :direct)
queue = channel.queue('hello.world')
queue.bind(exchange, :routing_key => 'xyz')
@lardcanoe
lardcanoe / Gemfile
Created September 30, 2014 16:50
Require tasks from all gems in a group from a Gemfile
group :engines do
gem 'my_engine'
gem 'another_engine'
end
@lardcanoe
lardcanoe / schema_dumper.rb
Created May 28, 2014 21:10
ActiveRecord module to get BIGINT Primary Keys in schema.rb when using schema_plus
# This gives us the ability to get BIGINT PK's in schema.rb
# It also plays nice with the schema_plus gem
module MyCompany
module ActiveRecord
module SchemaDumper
def self.included(base) #:nodoc:
base.class_eval do
private
alias_method_chain :table, :bigint_support
@lardcanoe
lardcanoe / Thread 1
Created January 16, 2014 00:52
Some sample thread dumps for jruby issue
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:225)
at sun.nio.ch.IOUtil.read(IOUtil.java:198)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:375)
- locked <0x0000000689667010> (a java.lang.Object)
at org.jruby.ext.openssl.SSLSocket.readAndUnwrap(SSLSocket.java:516)
at org.jruby.ext.openssl.SSLSocket.read(SSLSocket.java:504)
at org.jruby.ext.openssl.SSLSocket.do_sysread(SSLSocket.java:616)
@lardcanoe
lardcanoe / gist:7252550
Created October 31, 2013 16:20
Convert action field to enum
mysql> create table test_enum (action varchar(255));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into test_enum set action="create";
Query OK, 1 row affected (0.04 sec)
mysql> insert into test_enum set action="delete";
Query OK, 1 row affected (0.00 sec)
mysql> insert into test_enum set action="update";
@lardcanoe
lardcanoe / gist:5174394
Created March 16, 2013 01:01
An updated example for using meteor-keybindings by @matteodem Note the use of Meteor.startup so that Meteor.Keybindings has had a chance to be defined.
Meteor.startup(function() {
Meteor.Keybindings.addOne('a', function() {
console.log('You pressed a');
});
});
@lardcanoe
lardcanoe / reset repo
Last active December 14, 2015 00:48
Reset forked repo to match original (upstream) for a pull request http://scribu.net/blog/resetting-your-github-fork.html
git clone https://github.com/lardcanoe/repo.git
cd repo
git remote add upstream https://github.com/repo/repo.git
git pull --rebase upstream
git pull --rebase upstream devel
git checkout -b repo_branch origin
git add new_file
git commit
git push origin repo_branch
@lardcanoe
lardcanoe / ec2_vol
Created February 18, 2013 21:28
Add tags to ec2_vol created by @lwade
if device_name and instance:
try:
volume.add_tag("Name", "%s - %s" % (inst.id, device_name))