ubuntu

The hidden cost of the Ruby 2.7 dot-colon method reference usage 1

The hidden cost of the Ruby 2.7 dot-colon method reference usage

Note: This case is valid also for the “old” #method method usage. The reason why I mention that in the “dot-colon” context, is the fact that due to the syntax sugar addition, this style of coding will surely be used more intensely. Note: This feature has been reverted. See details here: bugs.ruby-lang.org/issues/16275. Note: Benchmarks and …

The hidden cost of the Ruby 2.7 dot-colon method reference usage Read More »

NameError: undefined method ‘parse’ for class ‘NilClass’ when doing Time.zone.parse

If you get following error when trying to parse time: Time.zone.parse(‘2019-01-01 11:11:11′) Traceback (most recent call last): 16: from /bundler/friendly_errors.rb:124:in `with_friendly_errors’ 15: from /bundle:30:in `block in ‘ 14: from /bundler/cli.rb:18:in `start’ 13: from /bundler/vendor/thor/lib/thor/base.rb:466:in `start’ 12: from /bundler/cli.rb:27:in `dispatch’ 11: from /bundler/vendor/thor/lib/thor.rb:387:in `dispatch’ 10: from /bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command’ 9: from /bundler/vendor/thor/lib/thor/command.rb:27:in `run’ 8: from /bundler/cli.rb:465:in `exec’ …

NameError: undefined method ‘parse’ for class ‘NilClass’ when doing Time.zone.parse Read More »

Karafka framework 1.3.0 Release Notes (Ruby + Kafka)

Note: These release notes cover only the major changes. To learn about various bug fixes and changes, please refer to the change logs or check out the list of commits in the main Karafka repository on GitHub. TL;DR If you would prefer to see the changes in the code, here’s the upgrade PR from the …

Karafka framework 1.3.0 Release Notes (Ruby + Kafka) Read More »

Synology DSM 6.2 Photo Station 6 – Failed to Load Data Fix

I’m a quite happy Synology user. For the past years I’ve been using it mostly to backup my things, so I didn’t pay much of an attention to the fact, that the Photo Station software would get slower and slower up to the point when I would end up with “Failed to load data” message …

Synology DSM 6.2 Photo Station 6 – Failed to Load Data Fix Read More »

How to take over a Ruby gem and what to do with it / RubyKaigi 2019 presentation

Using Ruby gems is safe, right? We’re a nice community of friendly beings that act towards the same goal: making Ruby better. But is that true? Can we just blindly use libraries, without making sure, that they are what they are supposed to be? Learn how you can take over a gem, what you can …

How to take over a Ruby gem and what to do with it / RubyKaigi 2019 presentation Read More »

Ruby on Rails HTTP Basic authentication with JSON failure message

A short snippet on how to make Ruby on Rails authenticate_or_request_with_http_basic respond with a JSON valid message upon failure. class ApplicationController < ActionController::API include( ActionController::HttpAuthentication::Basic::ControllerMethods ) before_action :http_authenticate! def http_authenticate! authenticate_or_request_with_http_basic do |key, secret| return if Resource.find_by( key: key, secret: secret ) end render( json: 'Invalid credentials'.to_json, status: 401 ) end end Cover photo by …

Ruby on Rails HTTP Basic authentication with JSON failure message Read More »

Exploring a critical Net::Protocol issue in Ruby 2.6.0p0 and how it can lead to a security problem

TL;DR This bug has been fixed in 2.6.1. Please upgrade and all should be good. If you do any HTTP communication (HTTP requests, Elasticsearch, etc) do not upgrade to 2.6.0p0 or apply the patch below as soon as possible. Ruby is eating up characters when pushed over HTTP Ruby 2.6.0 has been released not long …

Exploring a critical Net::Protocol issue in Ruby 2.6.0p0 and how it can lead to a security problem Read More »

Extracting the device token from Xiaomi Air Purifier 2S EU for Domoticz usage 4

Extracting the device token from Xiaomi Air Purifier 2S EU for Domoticz usage

Xiaomi Air Purifier is one of the best on the market in the price/value category. Like many other Xiaomi devices, it can be controlled using a great home automation system called Domoticz. The only problem that I had is that for the 2S version, there is no way to obtain the device token needed for …

Extracting the device token from Xiaomi Air Purifier 2S EU for Domoticz usage Read More »

Simplifying internal validations using Dry-Validation

When building APIs for other developers, it’s often important to draw the line between other programmers input data and the internal world of your library. This process is called data validation and you’re probably familiar with this name. What you may not know, is the fact that it can be achieved in many ways. One …

Simplifying internal validations using Dry-Validation Read More »