“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust.
I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay who are based in Denmark...”
Old blog posts I never published, except I have now #12
Say we wanted to schedule a job but wanted to limit duplicate jobs running within a specific time period. We could set a time for a job to run and ignore duplicate requests in our queue. It appears Ruby’s Time object makes this simple for us. We can round up (or floor) to the nearest, time interval. Nice.
rl@macbookair personal % asdf plugin update ruby
Location of ruby plugin: /Users/rl/.asdf/plugins/ruby
Updating ruby to master
From https://github.com/asdf-vm/asdf-ruby
1ce84e2..8f28d3a master -> master
1ce84e2..8f28d3a master -> origin/master
Already on 'master'
Your branch is up to date with 'origin/master'.
rl@macbookair personal % asdf install ruby 4.0.0-preview2
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-4.0.0-preview2.tar.gz...
-> curl -q -fL -o ruby-4.0.0-preview2.tar.gz https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.0-preview2.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.3M 100 22.3M 0 0 17.5M 0 0:00:01 0:00:01 --:--:-- 17.5M
==> Installing ruby-4.0.0-preview2...
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/4.0.0-preview2" --with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+ --enable-yjit
It’s not uncommon for Rails specs to kill our database in development. It appears that if a browser spec doesn’t close cleanly you can end up with processes just hanging and so the next spec run will just wait forever.
Here’s the process list. It’s sleeping on the job.
Old blog posts I never published, except I have now #9
I, [2015-01-22T07:15:59.225481 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225700 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225951 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561068 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (1307.7ms)
I, [2015-01-22T07:16:00.561527 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561772 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561993 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.562210 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:16:00.562425 #30041] INFO -- : Rendered api/characters/_character.json.jbuilder (0.1ms)
After realising that Bot traffic originating from China takes up significantly more hits to a store than normal traffic, we’re taken steps to try and block traffic to get analytics back in good order. Here are the CloudFlare rules we’ve gone with.
Block CN + Other Regions
Blocks all traffic that Cloudflare sees as coming from China according to GeoIP.
(ip.geoip.country in {"CN" "RU" "KP" "SY"})
Block China Unicom ASNs
AS 4134 is the “ChinaNet Backbone” (China Telecom).
ip.src.asnum in {4134}
Block China Unicom ASNs
These are several ASNs owned by China Unicom. For example, AS 4837 is a well-known Unicom backbone.
Cybercrime Information Center. AS 133118 and other ASNs (136958, 134543, 135061) are also associated with Unicom.
ip.src.asnum in {4837, 133118, 134543, 135061, 136958}
Block China Mobile / CMCC ASNs
AS 9808 is commonly associated with China Mobile.
ip.src.asnum in {9808}
Challenge Suspicious / Low-Reputation Requests
Uses Cloudflare’s threat scoring + bot detection to challenge likely bot traffic. Good for reducing automated “dead” sessions.