This file contains hidden or 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
# Some colors | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad | |
alias ls='ls -GFh' | |
# Dev shortcuts | |
alias be="bundle exec" | |
alias dkc='docker-compose' | |
alias dkcr='docker-compose run' | |
alias dkr='docker run' |
This file contains hidden or 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 MyApp | |
class Application < Rails::Application | |
if Rails.env == 'test' | |
require 'diagnostic' | |
config.middleware.use(MyApp::DiagnosticMiddleware) | |
end | |
end | |
end |
This file contains hidden or 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
function Foo() { | |
this.bacon = “Bacon!”; | |
} | |
Foo.prototype.say = function() { | |
console.log(this.bacon); | |
} |
This file contains hidden or 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
function onExit(astChild: ts.Node, child: types.Node) { | |
switch (astChild.kind) { | |
case ts.SyntaxKind.ModuleDeclaration: | |
case ts.SyntaxKind.ClassDeclaration: | |
case ts.SyntaxKind.SourceFile: | |
this.namespaceStack.pop() | |
break | |
// BinaryExpression may contain a prototype function declaration, which | |
// should be given a NAMESPACE role. It's indicated by the state of |
This file contains hidden or 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
var Foo = function() { | |
return 0; | |
} | |
function Foo() { | |
return 1; | |
} | |
Foo.prototype.speak = function () { | |
return 2; |
This file contains hidden or 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
# Sample controller | |
def create | |
ctx = Pipes::Context.new(…..) | |
flow.call(ctx) | |
render json: ctx.project, status: :ok | |
# no need for handling specific exceptions of multiple types | |
resuce Pipes::Error => e | |
render json: {errors: e.message} | |
end |
This file contains hidden or 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
docker rm `docker ps -a | grep Exited | awk '{print $1 }'` | |
docker rmi `docker images -aq` |
This file contains hidden or 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
if ENV["PROFILE"] | |
require "objspace" | |
ObjectSpace.trace_object_allocations_start | |
Sidekiq.logger.info "allocations tracing enabled" | |
module Sidekiq | |
module Middleware | |
module Server | |
class Profiler | |
# Number of jobs to process before reporting |
This file contains hidden or 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
http://blog.skylight.io/hunting-for-leaks-in-ruby/ | |
http://www.be9.io/2015/09/21/memory-leak/ | |
http://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby | |
# Parse a JSON dump from ObjectSpace.dump_all and sort it to show object allocations count (descending) | |
# parse_dump.sh | |
cat $0 | | |
ruby -rjson -ne 'obj = JSON.parse($_).values_at("file","line","type"); puts obj.join(":") if obj.first ' | | |
sort | | |
uniq -c | |
This file contains hidden or 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
def trace_calls_on | |
scope = {} | |
trace = TracePoint.new(:call, :line) do |tp| | |
case tp.event | |
when :call then puts "#{tp.path}:#{tp.lineno} #{tp.defined_class}::#{tp.method_id} " \ | |
"called from #{scope[:path]}:#{scope[:lineno]} #{scope[:class]}::#{scope[:method_id]}" | |
when :line then scope = { | |
event: :line, | |
lineno: tp.lineno, | |
path: tp.path, |