Skip to content

Instantly share code, notes, and snippets.

View maxwell's full-sized avatar
🦁
chillin

Maxwell Salzberg maxwell

🦁
chillin
View GitHub Profile
@joshsusser
joshsusser / silence_assets.rb
Created April 17, 2012 22:34
put in config/initializers to silence asset logging in Rails development mode
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
call_without_quiet_assets(env)
ensure
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jamiew
jamiew / logger_customizations.rb
Created January 4, 2012 03:21
Rails logger customizations I use in production apps
# config/initializers/logger_customizations.rb
# Production-only monkeypatches to make our logs awesome
# Monkeypatch 1
# Don't log common poller-style requests, they are just noise
class CustomLogger < Rails::Rack::Logger
def initialize(app, opts = {})
@app = app
@opts = opts
@opts[:silenced] ||= []
@bonkydog
bonkydog / mailer.rb
Created August 24, 2011 06:23
Messagebus ActionMailer adapter
# in your environment file (for instance, production.rb)
MyAwesomeApp::Application.configure do
# ...lots of configuration...
config.action_mailer.delivery_method = Messagebus::Mailer.new(ENV['MESSAGEBUS_API_KEY'])
end
# lib/messagebus/mailer.rb
@a-chernykh
a-chernykh / avatar_uploader.rb
Created August 9, 2011 14:28
CarrierWave extension-aware remote file downloading
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def extension_white_list
model.skip_avatar_extension_check ? nil : %w(jpg jpeg gif png bmp)
end
end
@maxwell
maxwell / webfinger.rb
Created June 5, 2011 00:15
using faraday magic for webfinger parsing. modified code from sporkmonger webfinger repo
#tons take from sporkmonger's webfinger github
require File.join(Rails.root, 'lib/webfinger/hcard')
require File.join(Rails.root, 'lib/webfinger/webfinger_profile')
require 'addressable/uri'
require 'addressable/template'
require 'xrd'
class Webfinger
def self.lookup(email)
setup_faraday
module Devise
module Orm
module MongoMapper
module Hook
def devise_modules_hook!
extend Schema
include Compatibility
yield
return unless Devise.apply_schema
devise_modules.each { |m| send(m) if respond_to?(m, true) }