Using rack-mini-profiler (with Unpoly)

Posted 2 days ago by Niklas Hä..

Debugging performance issues in your Rails app can be a tough challenge. To get more detailed insights consider using the...

Ruby: How to connect to a host with expired SSL certificate

Posted 10 days ago by Arne Hartherz.

If you need to make an HTTPS connection to a host which uses an expired certificate, do not disable certificate...

List of handy Ruby scripts to transcode different file types (often by using GPT)

Posted About 1 month ago by Michael Leimstädtner.

It's 2024 and we have tools like ffmpeg, imagemagick and GPT readily available. With them, it's easy to...

Ruby on Rails: Finding a memory leak

Posted About 1 month ago by Dominik Schöler.
dev.37signals.com

The author describes his little journey in hunting down a memory leak. Maybe his approach and tooling may one day...

Use <input type="number"> for numeric form fields

Posted 2 months ago by Arne Hartherz.

Any form fields where users enter numbers should be an . Numeric inputs have several benefits over : On mobile or tablet...

Bash: How to count and sort requests by IP from the access logs

Posted 3 months ago by Emanuel.

87.140.79.42 - - [23/Jan/2024:09:00:46 +0100] "GET /monitoring/pings/ HTTP/1.1" 200 814 "-" "Ruby" 87.140.79.42 - - [23/Jan/2024:09:00:46 +0100] "GET...

Rails: Testing the number of database queries

Posted 3 months ago by Dominik Schöler.
github.com

There are a few tools to combat the dreaded n+1 queries. The bullet gem notifies you of missing eager...

When loading Yaml contents in Ruby, use the :freeze argument to deep-freeze everything

Posted 3 months ago by Arne Hartherz.

Ruby methods which load from a Yaml file, like YAML.safe_load or YAML.safe_load_file, support passing freeze: true to...

Maintaining custom application tasks in Rails

Posted 3 months ago by Emanuel.

Here are some hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts

OpenAI TTS: How to generate audio samples with more than 4096 characters

Posted 4 months ago by Michael Leimstädtner.

OpenAI is currently limiting the Audio generating API endpoint to text bodies with a maximum of 4096 characters.

Transfer records to restore database entries (with Marshal)

Posted 5 months ago by Daniel Straßner.

If you ever need to restore exact records from one database to another, Marshal might come in handy. Marshal.dump is...

Ruby: Using `sprintf` to replace a string at fixed named references

Posted 5 months ago by Felix Eschey.
docs.ruby-lang.org

The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000

Using Rationals to avoid rounding errors in calculations

Posted 5 months ago by Martin Schaflitzl.
ruby-doc.org

Ruby has the class Rational which allows you to store exact fractions. Any calculation on these variables will now use...

Zeitwerk: How to collapse folders in Rails

Posted 5 months ago by Niklas Hä..

All direct child directories of app are automatically added to the eager- and autoload paths. They do NOT create a...

Solving "TypeError (nil can't be coerced into Integer)" in the Rails console / IRB

Posted 5 months ago by Dominik Schöler.

On the Rails console, assigning an object to a variable can lead to this strange error (without stacktrace): irb > recipient...

Ruby: `extend` extends the singleton class's inheritance chain

Posted 5 months ago by Felix Eschey.

In the discussion of the difference between include and extend in Ruby, there is a misconception that extend would add...

Using Ruby's Method objects for inspecting methods

Posted 6 months ago by Felix Eschey.
ruby-doc.org

Do you remember finding where a method is defined? I recently learned from a senior colleague that Method objects are...

Use rbenv-each to run a command for every installed Ruby version

Posted 6 months ago by Michael Leimstädtner.
github.com

The linked rbenv plugin rbenv-each is very helpful to keep QoL gems up to date that are not part...

Don't use log level :debug in your production environments

Posted 7 months ago by Jakob Scholz.

You don't want sensitive user data in your logs. Background Rails per default filters sensitive data like...

Advanced plotting in Ruby with Gnuplot

Posted 7 months ago by Felix Eschey.

Besides Plotting graphs in Ruby with Gruff, which comes handy for many uses cases, you sometimes might need configuration for...

Lightning Talk: Coverage based Test Case Prioritization in Ruby on Rails

Posted 7 months ago by Felix Eschey.
github.com

For my computer science bachelor's thesis I programmed and evaluated a CLI Test Case Prioritization (TCP) tool for makandra...

CarrierWave: Processing images with libvips

Posted 9 months ago by Henning Koch.

When you write your next CarrierWave uploader, consider processing your images with libvips instead of ImageMagick. Reasons for libvips

Ruby: alias_method conflicting with prepend

Posted 9 months ago by Dominik Schöler.
newrelic.com

alias_method makes a copy of a method. This works fine until the same method is overridden using prepend. If...

Best practice: How to manage versions in a Gemfile

Posted 9 months ago by Emanuel.

It most cases it's not necessary to add a version constraint next to your gems in the Gemfile. Since...