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
<a href="#">Test</a> |
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
# seconds = duration in seconds as integer i.e. time.to_i | |
[ | |
seconds / (60*60*24), # days | |
seconds % (60*60*24) / (60*60), # hours | |
seconds % (60*60) / 60, # minutes | |
seconds % 60 # seconds | |
].zip(%w(d h m s)).map { |u| u.join unless u.first.zero? }.compact.tap { |a| a << '<1s' if a.none? }.join | |
# Uses Object#tap rather than Rails Object enhancements like Object#presence |
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
// W2V script intended for http://www.globalforestwatch.org/map/3/15.00/27.00/ALL/grayscale/loss,forestgain?begin=2001-01-01&end=2013-01-01&threshold=30 | |
w2v.info("Injecting polyfill"); | |
// Inject W2V polyfill so that this script will run in normal browsers without errors | |
(function(d, s, id){ | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)){ return; } | |
js = d.createElement(s); js.id = id; | |
js.onload = function(){ |
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['MEMORY_PROFILING'] | |
require 'benchmark' | |
def require(file) | |
puts `pmap #{Process.pid} | grep 'total'` | |
puts Benchmark.measure('') { super }.format("%t require #{file}") | |
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
module SimpleForm | |
module Inputs | |
class StaticInput < SimpleForm::Inputs::StringInput | |
def input | |
template.content_tag(:p, object.send(attribute_name), class: 'form-control-static') | |
end | |
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
require 'benchmark/ips' | |
require 'bigdecimal' | |
Benchmark.ips do |x| | |
x.report('Rational from String') { '214.04'.to_r - '74.79'.to_r + '74.79'.to_r > '214.04'.to_r } | |
x.report('Rational from Float') { 214.04.to_r - 74.79.to_r + 74.79.to_r > 214.04.to_r } | |
x.report('BigDecimal from String') { BigDecimal.new('214.04') - BigDecimal.new('74.79') + BigDecimal.new('74.79') > BigDecimal.new('214.04') } |
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
# RUBY | |
1564181439.071863 [0 99.99.99.99:43608] "multi" | |
1564181439.131934 [0 99.99.99.99:43608] "sadd" "queues" "from_sk_ruby" | |
1564181439.131955 [0 99.99.99.99:43608] "lpush" "queue:from_sk_ruby" "{\"queue\":\"from_sk_ruby\",\"class\":\"Sample::MyWorker\",\"args\":[{\"test\":\"payload\",\"activity_id\":15838549}],\"retry\":true,\"jid\":\"ab8ed2a13e41756c5a4dde89\",\"created_at\":1564181430.3014073,\"enqueued_at\":1564181439.043673}" | |
1564181439.132031 [0 99.99.99.99:43608] "exec" | |
1564181439.180776 [0 99.99.99.99:43608] "multi" | |
1564181439.223040 [0 99.99.99.99:43608] "sadd" "queues" "from_sk_ruby" | |
1564181439.223064 [0 99.99.99.99:43608] "lpush" "queue:from_sk_ruby" "{\"queue\":\"from_sk_ruby\",\"class\":\"Sample::MyWorker\",\"args\":[{\"test\":\"payload\",\"activity_id\":15838549}],\"retry\":true,\"jid\":\"ab8ed2a13e41756c5a4dde89\",\"created_at\":1564181430.3014073,\"enqueued_at\":1564181439.1471574}" |
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
# ORIGINAL | |
Time to queue remotely: 00:00:00.236023892 | |
Time to queue remotely: 00:00:00.123225651 | |
Time to queue remotely: 00:00:00.136234454 | |
Time to queue remotely: 00:00:00.140092191 | |
Time to queue remotely: 00:00:00.120226790 | |
Time to queue remotely: 00:00:00.120232020 | |
Time to queue remotely: 00:00:00.123584921 | |
Time to queue remotely: 00:00:00.148454025 |
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
# Hack to avoid segfault during compilation of statically-linked binary on Alpine | |
{% if flag?(:static) %} | |
require "llvm/lib_llvm" | |
require "llvm/enums" | |
{% 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
FROM crystallang/crystal:0.33.0-alpine-build as builder | |
WORKDIR /app | |
COPY . /app | |
RUN shards build --static --release --no-debug | |
FROM scratch | |
WORKDIR /app | |
COPY --from=builder /app/bin /bin | |
ENTRYPOINT ["/bin/<YOUR_BINARY_NAME"] |