This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import bugsnag | |
class BugsnagHandler(logging.Handler): | |
def emit(self, record): | |
if record.levelno == logging.ERROR or record.levelno == logging.WARNING: | |
bugsnag.notify(Exception(record.message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleMongoidSlug | |
extend ActiveSupport::Concern | |
included do | |
cattr_accessor :slug_scope, :slug_field | |
end | |
module ClassMethods | |
def slug(*field) | |
options = field.extract_options! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bugsnag::Notification.class_eval do | |
class << self | |
def deliver_exception_payload_with_thread(*args) | |
Thread.new do | |
Bugsnag::Notification.deliver_exception_payload_without_thread(*args) | |
end | |
end | |
alias_method :deliver_exception_payload_without_thread, :deliver_exception_payload | |
alias_method :deliver_exception_payload, :deliver_exception_payload_with_thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="slider-value"></div> | |
<input type="text" data-slider="true" data-slider-values="0,100,500,800"> | |
<script> | |
var sliderValues = { | |
0: "None", | |
100: "Small", | |
500: "Medium", | |
800: "Large" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Delayed | |
module Plugins | |
class Bugsnag < Plugin | |
module Notify | |
def error(job, error) | |
::Bugsnag.auto_notify(error) | |
super | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Simple pub/sub using redis and server-sent events (EventSource) | |
// | |
// Usage: | |
// | |
// // Attach the middleware | |
// redisSse = require("redis-sse"); | |
// app.use(redisSse({redis: yourRedisClient})); | |
// | |
// // Set up a subscription to a channel in your route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo pip install -Iv http://gdata-python-client.googlecode.com/files/gdata-2.0.14.tar.gz googlecl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the AWS instance ID for the current instance, no API credentials required | |
curl http://169.254.169.254/2009-04-04/meta-data/instance-id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Batman.LayoutController extends Batman.Controller | |
render: (options = {}) -> | |
layout = options.layout ? @layout ? Batman.helpers.underscore(@get('routingKey')) | |
if layout | |
# Prefetch the action's view in parallel | |
source = options.source || Batman.helpers.underscore(@get('routingKey') + '/' + @get('action')) | |
Batman.View.store.prefetch source | |
# Fetch the layout's view and apply context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically generates the plain-text version of emails from the html | |
# template using premailer. | |
class SmartMailer < ActionMailer::Base | |
def mail(headers={}) | |
# Configure the premailer options | |
premailer_options = { | |
with_html_string: true, | |
line_length: 9999, | |
} |