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 'byebug' | |
module MethodMetadata | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def method_advice(data = {}) | |
lineno = caller_locations(1, 1).first.lineno |
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
RSpec.configure do |config| | |
def count_rows_from_all_tables | |
Hash[ | |
ActiveRecord::Base.connection.tables.map do |tbl| | |
[tbl, ActiveRecord::Base.connection.execute("select count(*) from #{tbl}").values.last.first.to_i] | |
end | |
] | |
end | |
config.around :example do |example| |
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
rebase-reminder: | |
docker: | |
# specify the version you desire here | |
- image: circleci/ruby:2.4.1-node-browsers | |
environment: | |
RAILS_ENV: test | |
PGHOST: 127.0.0.1 | |
PGUSER: root | |
PUBLIC_HOST: https://example.org |
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 'pp' | |
def profile | |
old_strs = ObjectSpace.count_objects[:T_STRING] | |
old_objs = GC.stat[:total_allocated_objects] | |
yield.tap do | |
new_strs = ObjectSpace.count_objects[:T_STRING] | |
new_objs = GC.stat[:total_allocated_objects] |
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
# Add ruby tracepoint | |
EXCLUDED_CLASSES = %w(Sidekiq::Worker Delayed::Worker Unicorn::Worker Sidekiq::Worker Parallel::DeadWorker | |
Parallel::Worker Concurrent::RubyThreadPoolExecutor::Worker Twilio::REST::TaskRouter::Worker) | |
$__TRACE_WORKERS = [] | |
trace = TracePoint.new(:class) do |tp| | |
class_name = tp.self.name | |
next if class_name.nil? |
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
fun findFibSeries(n: Int) { | |
val series = mutableListOf(0, 1) | |
(0..n).map { n -> | |
series.add(series.takeLast(2) | |
.reduce {sum, it -> sum + it}) | |
} | |
series.forEach { println(it) } | |
} |
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 *calcFib () { | |
let n = 0 | |
let fib = function(v) { | |
return v <= 1 ? v : fib(v - 1) + fib(v - 2) | |
} | |
while (true) yield fib(n++) | |
} |
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
#!/usr/bin/env bash | |
ssh -v -nNT -R 9999:localhost:3000 ubuntu@staging.source4style.com |
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
.shadow1 { | |
box-shadow: 0 0 20px 1px rgba(114,114,189,0.1); | |
} |
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
window.UIControls.CountryField = React.createClass | |
mixins: [CountriesMixin] | |
getInitialState: -> {code: @props.data} | |
changeCountry: (evt) -> | |
code = evt.currentTarget.value | |
@setState(code: code) | |
@props.onChange(code) if @props.onChange? |