Skip to content

Instantly share code, notes, and snippets.

View leifcr's full-sized avatar

Leif Ringstad leifcr

View GitHub Profile
config.middleware.insert_before ActionDispatch::ParamsParser, ::Rack::Robustness do |g|
g.no_catch_all
# you might need to replace this with JSON::ParserError, depending on your Rails configuration
# or you can catch both...
g.on(MultiJson::ParseError) { |ex| 400 }
g.content_type 'text/plain'
g.body{ |ex| ex.message }
g.ensure(true) do |ex|
env['rack.errors'].write(ex.message)
logger.warn(ex.message)
@jnunemaker
jnunemaker / mongo_mapper_new_relic.rb
Created January 8, 2010 09:04
MongoMapper NewRelic Integration
# Have to use ActiveRecord so that New Relic shows it on all graphs.
# The push scope false stuff makes it so that you can track usage by model and overall.
if defined?(NewRelic)
module MongoMapperNewRelic
def self.included(model)
mm_class_methods = [
:find,
:find!,
:paginate,
:first,
# Just drop this little diddy in your app to get some (not perfect) information on query times and such
# This will eventually become an official plugin but for those who can't wait, enjoy.
if defined?(NewRelic)
module MMNewRelicTracing
def self.included(model)
model.metaclass.class_eval do
add_method_tracer :find, 'Database/#{self.name}/find'
add_method_tracer :find!, 'Database/#{self.name}/find!'
add_method_tracer :paginate, 'Database/#{self.name}/paginate'
add_method_tracer :first, 'Database/#{self.name}/first'
@leifcr
leifcr / leifcr.zsh-theme
Created March 14, 2013 08:48
Oh-my-zsh theme based on "muse". Added green user@machine
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
@catsby
catsby / puma.rb
Created October 17, 2013 14:28
Example config/puma.rb file
preload_app!
min_threads = Integer(ENV['MIN_THREADS'] || 0)
max_threads = Integer(ENV['MAX_THREADS'] || 5)
threads min_threads, max_threads
workers Integer(ENV['WORKER_COUNT'] || 3 )
on_worker_boot do
ActiveSupport.on_load(:active_record) do
@virusman
virusman / example.js
Created September 25, 2012 10:31
Twitter Bootstrap Tabs + History.js - made as jQuery plugin
$(document).ready(function() {
//init tab history with default tab 'table'
$(window).tabHistory('table');
});
@markrendle
markrendle / Git Bash.vbs
Created November 25, 2010 17:31
Modified Git Bash to use Console2
Set AppObj = CreateObject("Shell.Application")
If WScript.Arguments.Length=1 Then
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"" -d """ & WScript.Arguments(0) & """"
Else
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"""
End If
@taras
taras / gist:3acbed53702ce4e0d106
Created July 4, 2014 02:02
Where to start after you read Ember Guides?
You'll need proper development environment, learn about Ember CLI - https://www.youtube.com/watch?v=hygxGDjhGp8.
You might want to know about more about what's happening under the hood, watch Robert Jackson talk about Ember Magic - https://www.youtube.com/watch?v=OjqcI8KWesk.
Learn more about complex architecture in Ember https://www.youtube.com/watch?v=Kcij9lH2OyM
Learn more about Ember Data - https://www.youtube.com/watch?v=HL2bMjndviE.
You can get lost in the View layer, learn about Events and Actions from Luke Melia - https://www.youtube.com/watch?v=w6__hEUjqaw
@aaronzirbes
aaronzirbes / gist:3239033
Created August 2, 2012 17:43
brew doctor and libmacfuse/libosxfuse
If you see...
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libmacfuse_i32.2.dylib /usr/local/lib/libmacfuse_i64.2.dylib /usr/local/lib/libosxfuse_i32.2.dylib /usr/local/lib/libosxfuse_i64.2.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
@rzezeski
rzezeski / gist:3250870
Created August 3, 2012 19:53
detect bad merge index files
#!/usr/bin/env escript
%% -*- erlang -*-
-include_lib("kernel/include/file.hrl").
-compile(export_all).
-define(LOG(S), io:format(S)).
-define(LOG(S,A), io:format(S,A)).
main(Dirs) ->
CodePath = case os:getenv("RIAK_LIB") of