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
require "rake" | |
shared_context "rake" do | |
let(:rake) { Rake::Application.new } | |
let(:task_name) { self.class.top_level_description } | |
let(:task_path) { "lib/tasks/#{task_name.split(":").first}" } | |
subject { rake[task_name] } | |
def loaded_files_excluding_current_rake_file | |
$".reject {|file| file == Rails.root.join("#{task_path}.rake").to_s } |
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
# webm | |
ffmpeg -y -i snp-inst3.mp4 \ | |
-filter:v scale=640:360,setsar=1/1 -pix_fmt yuv420p \ | |
-vpre libvpx-720p -b:v 500k -r:v 25/1 -force_fps \ | |
-c:a libvorbis -b:a 80k -pass 1 out_inst.webm | |
# mp4 | |
ffmpeg -y -i snp-inst3.mp4 \ | |
-filter:v scale=640:360,setsar=1/1 -pix_fmt yuv420p \ | |
-c:v libx264 -preset:v slow -profile:v baseline \ |
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
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, |
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
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 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 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 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 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 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 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); | |
} |
OlderNewer