Skip to content

Instantly share code, notes, and snippets.

View jhawthorn's full-sized avatar
⌨️

John Hawthorn jhawthorn

⌨️
View GitHub Profile
require 'date'
data = File.read("CHANGELOG.md")
versions = []
data.scan(/## Solidus ([0-9\.]+)\.0 \(([0-9]+)-([0-9]+)-([0-9]+)\)/) do
version = $1
release_date = Date.new($2.to_i, $3.to_i, $4.to_i)
eol = [release_date >> 18, Date.new(2018, 05, 05)].max
class I18nLogger
include I18n::Backend::Base
include I18n::Backend::Flatten
def available_locales
['en']
end
def lookup(locale, key, scope = [], options = {})
p [locale, key, {scope: scope, options: options}]
@jhawthorn
jhawthorn / gist:898305d08ea3b2cdc5bc089bc13f7550
Created February 4, 2018 21:58
Testing out ruby's new MJIT
$ ruby -v
ruby 2.6.0dev (2018-02-05 trunk 62211) [x86_64-linux]
$ time =ruby --disable-gems 15b.rb
313
=ruby --disable-gems 15b.rb 8.99s user 0.00s system 99% cpu 9.011 total
$ time =ruby --disable-gems --jit 15b.rb
313
=ruby --disable-gems --jit 15b.rb 7.37s user 0.04s system 105% cpu 6.991 total
@jhawthorn
jhawthorn / gist:f0097bf098e93187064f7f75af3bda9e
Created February 5, 2018 05:37
Ruby startup time with JIT
$ time ruby --disable-gems -e ''
0.006 total
$ time ruby -e ''
0.036 total
$ time ruby --disable-gems --jit -e ''
0.184 total
$ time =ruby --jit -e ''
$ ruby -v
truffleruby 0.30.2, like ruby 2.3.5 <Java HotSpot(TM) 64-Bit Server VM 1.8.0_151-b12 with Graal> [linux-x86_64]
$ time =ruby -e ''
=ruby -e '' 16.52s user 0.37s system 350% cpu 4.821 total
$ time =ruby --native -e ''
=ruby --native -e '' 0.12s user 0.03s system 98% cpu 0.159 total
$ time =ruby 15a.rb
# A stable ping target
# pretty much anything is more reliable than shaw
target_ip = "1.1.1.1"
# Maximum wait time in seconds.
wait = 1
interval = 10
require 'fileutils'
$ ruby report.rb
Outage from 2018-06-07 02:50:49 -0700 to 2018-06-07 02:58:32 -0700
duration: 8 minutes
pings lost: 77% (34 / 44)
average ping: 22ms
Outage from 2018-06-07 05:07:10 -0700 to 2018-06-07 05:21:04 -0700
duration: 14 minutes
pings lost: 83% (65 / 78)
average ping: 16ms
@jhawthorn
jhawthorn / Gemfile
Last active July 4, 2018 18:12
bundler vs bundler-explain: A real world Gemfile during an upgrade to Rails 5 https://github.com/jhawthorn/bundler-explain
source 'https://rubygems.org'
gem 'rails', '~> 5.0.0'
# Soft-deletion
gem 'paper_trail'
gem 'discard', '~> 1.0'
# auth
gem 'pundit'
@jhawthorn
jhawthorn / dtruss.txt
Last active September 12, 2018 23:58
app/views/users/show{.en,}{.html,.text,.js,.css,.ics,.csv,.vcf,.vtt,.png,.jpeg,.gif,.bmp,.tiff,.svg,.mpeg,.mp3,.ogg,.m4a,.webm,.mp4,.otf,.ttf,.woff,.woff2,.xml,.rss,.atom,.yaml,.multipart_form,.url_encoded_form,.json,.pdf,.zip,.gzip,}{}{.raw,.erb,.html,.builder,.ruby,}
getattrlist("app\0", 0x7FFEEE3598D0, 0x7FFEEE359910) = 0 0
getattrlist("app/views\0", 0x7FFEEE3596F0, 0x7FFEEE359730) = 0 0
getattrlist("app/views/users\0", 0x7FFEEE359510, 0x7FFEEE359550) = 0 0
getattrlist("app/views/users/show.en.html.raw\0", 0x7FFEEE359330, 0x7FFEEE359370) = -1 Err#2
getattrlist("app\0", 0x7FFEEE3598D0, 0x7FFEEE359910) = 0 0
getattrlist("app/views\0", 0x7FFEEE3596F0, 0x7FFEEE359730) = 0 0
getattrlist("app/views/users\0", 0x7FFEEE359510, 0x7FFEEE359550) = 0 0
getattrlist("app/views/users/show.en.html.erb\0", 0x7FFEEE359330, 0x7FFEEE359370) = -1 Err#2
getattrlist("app\0", 0x7FFEEE3598D0, 0x7FFEEE359910) = 0 0
getattrlist("app/views\0", 0x7FFEEE3596F0, 0x7FFEEE359730) = 0 0
@jhawthorn
jhawthorn / dtruss.txt
Created September 13, 2018 00:14
Dir["app/views/users/show*"]
getattrlist("app\0", 0x7FFEEC328C50, 0x7FFEEC328C90) = 0 0
getattrlist("app/views\0", 0x7FFEEC328A70, 0x7FFEEC328AB0) = 0 0
getattrlist("app/views/users\0", 0x7FFEEC328890, 0x7FFEEC3288D0) = 0 0
sigprocmask(0x1, 0x0, 0x7FFEEC3292A0) = 0x0 0
sigaltstack(0x0, 0x7FFEEC329290, 0x0) = 0 0
openat(0xFFFFFFFFFFFFFFFE, "app/views/users\0", 0x1100000, 0x1) = 7 0
fstat64(0x7, 0x7FFEEC329220, 0x0) = 0 0
fcntl_nocancel(0x7, 0x2, 0x1) = 0 0
fstatfs64(0x7, 0x7FFEEC328968, 0x0) = 0 0
getdirentries64(0x7, 0x7FA162008000, 0x1000) = 104 0