makandra dev
wiki.debian.org

This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can't open file or directory", ...) after configuration changes, e.g. when...

digitalocean.com

...to be done separatly for each node version on your system, though. Install yarn 1 system-wide via apt The yarn package depends on the nodejs debian package, but with...

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/yarn.gpg >/dev/null echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update...

...the new way to do it, and it's great, especially in combination with Sprockets (or Propshaft on Rails 7). You might be missing some convenience features, though.

...cover one specific issue: Once you have started your development Rails server and esbuild with the --watch option (if you used jsbundling-rails to set up, you probably use bin/dev...

...not be observable by non-jQuery code. This is currently a WONTFIX for jQuery (see closed issues #2476, #3347). Native events always work for everyone Note that if you trigger...

...listeners using jQuery's trigger(). Note that you might use third-party libraries like select2 that use trigger(). If your entire app is written in jQuery and you don't...

...method to automatically compute an ETag from the given record, array of records or scope of records: class UsersController < ApplicationController def show @user = User.find(params[:id]) fresh_when @user

...by passing an array of ETaggable objects to fresh_when. class UsersController < ApplicationController def show @user = User.find(params[:id]) # The show template also renders the user's posts. fresh_when...

...Plotting graphs in Ruby with Gruff, which comes handy for many uses cases, you sometimes might need configuration for more advanced plots, e.g. for academic concerns. Then using Gnuplot, the...

...first academic open source plotting software, might be a good option. There are several wrappers for Ruby available and I mainly looked at one of the two most frequently used...

A severe bug was found in ImageMagick by Bryan Gonzalez from Ocelot Team. It allows to embed the content of an arbitrary remote file when ImageMagick parses PNG files.

...on updated Packages for Ubuntu (https://ubuntu.com/security/CVE-2022-44268). Due to that we patched our systems as follows: Ubuntu 22.04: Get package source on a Ubuntu 22.04 system: apt-get source...

Exercise 1: XML On the start page of your Movie DB, show the title of a random movie that is coming soon to theaters. There's an XML feed for...

...no longer a "Year" field when creating a movie. It is automatically fetched and stored before the movie is created. When editing a movie there is a "Year" field that...

...table, two things happen: Rails tries to load all involved records in a huge single query spanning multiple database tables. The preloaded association list is filtered by the where condition...

...you only wanted to use the where condition to filter the containing model. The second case's behavior is mostly unexpected, because pre-loaded associations usually don't care about...

Short reference on how to quickly debug the vanilla Rails job adapters. Queue Adapters by Environment Environment Adapter Jobs Run In Worker Needed? development :async Rails server process No

Not executed (stored) No production :solid_queue Separate worker Yes (bin/jobs) Development (:async) Jobs run in background threads (Concurrent Ruby ThreadPoolExecutor) within the process that called the job.

...gem like accept_language. Customizing Rails error messages for models and attributes Rails I18n scope for humanized attribute names HTML: Making browsers wrap long words Use the same translations for...

...I18n fallback locales Rails: Including HTML in your i18n locales Even for a single language, locales are useful Even if your application only supports a single language, it makes sense...

makandra Curriculum

If you've stumbled over display: grid while reading the Flexbox material of the previous card - we've got you covered! Let's dive into this topic with a quote...

...dimensional layouts and Grid is made for two-dimensional layouts. You will learn more subtle differences in the linked material below, but you can remember this as a rule of...

Action Mailer Basics and Previews Chapter "Task H1: Sending Confirmation Emails" from Agile Web Development with Rails (in our library) Ensure that the receiving e-mail is valid

...the Truemail gem to validate e-mail addresses Ensure that development and staging are not sending out e-mails by accident Rails: How to write custom email interceptors

Rails wraps your parameters into an interface called StrongParameters. In most cases, your form submits your data in a nested structure which goes hand in hand with the strong parameters...

...However, there are cases where this does not fit your use case, or has side effects. If you do it differently, be extra careful not to introduce security issues.

With Ubuntu 24.04 it's not longer possible to setup FDE with BTRFS The new installer won't offer you any options for manually created dm-crypt volumes

.../dev/mapper/ubuntu--vg-ubuntu--lv /mnt Move default subvolume to @ cd /mnt btrfs subvolume snapshot . @ rmdir @/ext2_saved btrfs subvolume set-default @ ls | grep -Ev "@|ext2_saved" | xargs rm -rf Create additional subvolumes btrfs subvolume...

...command-line tool for REPL (Read Eval Print Loop). Type gem help info to see a list of available switches. Note that the Ruby API offers a bit more insight...

...Gem Ruby API (at runtime) First, get the Gem::Specification of the gem you are looking for. That object holds all the information from the gem's gemspec file, and...

...is a gem for working with daytimes. That's a tuple of (hour, minute second) without a day, month or year. Another additional gem? Thus SQL has a time datatype...

...for storing time of day in the format hh:mm:ss, neither Ruby nor Rails themselves offer an elegant way to deal with day times. Time and DateTime both handle...

...Adding Records via XHR and JS Example For the following examples we use a simple data model where a user has zero or more tasks. class ExampleMigration < ActiveRecord::Migration...

...user.tasks.build } end def update load_user @user.attributes = user_params if @user.save flash[:notice] = 'User saved successfully.' redirect_to(edit_variant_1_user_path(@user)) else flash[:notice] = 'User could not...

A JavaScript error in an E2E test with Selenium will not cause your test to fail. This may cause you to miss errors in your frontend code. Using the BrowserConsole...

!!driver_logs_proc end def driver_logs_proc browser = page.driver.browser if browser.respond_to?(:logs) # selenium-webdriver >= 4 proc { browser.logs } elsif browser.respond_to?(:manage) && browser.manage.respond_to?(:logs) # selenium-webdriver...

...chapters from The Pragmatic Programmer, anniversary edition (in our library): Chapter 1, Topic 3: Software Entropy Chapter 2, Topic 9: The Evils of Duplication Chapter 2, Topic 10: Orthogonality

...Chapter 5: Formatting Chapter 8: Boundaries Chapter 10: Classes Chapter 12: Emergence Chapter 17: Smells and Heuristics Also read: How to write modular code Keep It DRY, Shy, and Tell...

Running rails server will start a local server that you can access via http://localhost:3000. When you are working on multiple web apps, they will likely set cookies with...

...generic names on localhost. This is annoying, since you will sign out your current user whenever you switch to another app. A better way is to use our own daho.im...

github.com

You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted...

When deploying, it posts to a Slack channel like this: How to integrate Integrating Slackistrano with Capistrano 3 is fairly simple. If you are not a Slack admin

...a MacBook that uses an M1 or M2 Chip. Documentation on the Internet is sparse and not even the Geniuses at the Genius Bar are 100% sure. We found out...

...your MacBook, using more than one external display is only possible with workarounds. Docking stations Whenever you're considering using more than 1 external display, it makes sense to consider...

...Object into Integer (TypeError) Integer(2) # 2 Integer("11", 2) # 3 This is very similar but not identical to to_i: "2".to_i # 2 "foo".to_i # 0

...an instance of Object (NoMethodError) 2.to_i # 2 "11".to_i(2) # 3 Integer() supports a exception: false variant, which is very handy to cast user input without any exception...