...status code 400) |_http-title: 400 The plain HTTP request was sent to HTTPS port | ssl-cert: Subject: commonName=www.makandracards.com/countryName=DE | Not valid before: 2015-10-14T12...
...Not valid after: 2016-10-14T12:42:03+00:00 |_ssl-date: 2016-08-05T11:33:52+00:00; +9d23h48m18s from local time. | tls-nextprotoneg: | h2
Applications send e-mail for notifications, confirmations and more. This lesson covers Action Mailer, keeping development and staging from sending real mail, and getting mail delivered to the inbox.
...mailer, including attachments, and preview mails during development. You can explain why development and staging must never send real mail, and how to make sure of it, e.g. with an...
My RubyMine (and it seems like many other Java GUI applications) crashes the Compiz window decorator almost every time on exit. This also seems to happen for the Unity decorator...
...Update: The commited fix from below seems to have made it into the stable Ubuntu repository. Easy mode You can restore window decorations by executing this command: gtk-window-decorator...
...on this lesson in advisor mode. Learning goals You can explain what problem Unpoly solves: SPA-like navigation and interactions on a server-rendered app, with very little JavaScript.
...Rails ships with Hotwire (Turbo and Stimulus) for the same job: updating fragments of a server-rendered page without full reloads. Turbo Drive and Turbo Frames correspond roughly to Unpoly...
When you need test images, instead of using services like lorempixel or placehold.it you may generate test images yourself. Here we build a simple SVG image and wrap it into...
...a data: URI. All browsers support SVG, and you can easily adjust it yourself. Simply set it as an image's src attribute. JavaScript Simple solution in modern JavaScript, e.g...
...number of different versions for Ruby, Rails and many gems. To be able to switch between projects easily, we must control every dependency our applications has. Important
...gem is and where installed gems live, and you can read a gem's source locally (e.g. with bundle open) or on GitHub. You can explain why we need a...
...case Ruby does not detected the expected encoding of a file automatically you can specify the known encoding manually. Example with File.open file = File.open('some.bin', encoding: Encoding::ASCII_8BIT)
text.encoding => # Example with File.read text = File.read('some.bin', encoding: Encoding::ASCII_8BIT) text.encoding => # More details about the encoding of strings in Ruby can be found here...
Defining one callback several times in the same class behaves different in ActiveRecord and ResourceController. While in ActiveRecord the callbacks are enqueued, they overwrite each other in ResourceController. ActiveRecord - a...
...common practice class Post < ActiveRecord::Base does 'post/behavior' before_validation :do_something end module Post::BehaviorTrait as_trait do before_validation :do_something_else end end do_something_else and...
I recently stumbled upon the Rails feature composed_of. One of our applications dealt with a lot of addresses and they were implemented as 7 separate columns in the DB...
...and Rails models. This seemed like a perfect use case to try out this feature. TLDR The feature is still a VERY leaky abstraction. I ran into a lot of...
...rails_performance (https://github.com/igorkasyanchuk/rails_performance) provides a lot of valuable information with very little setup cost. It only needs Redis which we use in the majority of our applications anyway...
Only problematic requests (> 500 ms) Longer history than "Recent requests" The "500 Errors" screen self-explanatory and hopefully always empty The "Custom Events" screen Let's you easily add...
...which records a user sees, which transitions they may trigger — to the state. You test state-dependent behavior at the right level: end-to-end for the business process, unit...
...as it's getting reviewed. This could be a typical state flow for a movie: stateDiagram-v2 [*] --> draft draft --> pending pending --> declined: Reason declined --> pending pending --> published Changes to the...
...is hard coded. A popular example is extension_allowlist, which returns an array of strings and let's you only upload files that have a filename with an extension that...
...matches an entry in that array. Another useful validation can be size_range, which gives you a little bit of control over how your storage gets polluted.
...operators typeof and instanceof which work very differently. JavaScript has some primitive types, like string literals, that are not objects (as opposed to Ruby, where every value is an object...
...Some values are sometimes a primitive value (e.g. "foo") and sometimes an object (new String("foo")) and each form requires different checks There are three different types for null (null...
Webmocks hash_including is similar to RSpec::Mocks::ArgumentMatchers#hash_including. Be aware that hash_including (webmock v3.0.1) doesn't parse integer values to String. Without hash including you would...
uri = URI('http://example.com/?foo=1&bar=2') stub_request(:get, 'example.com').with(query: {foo: 1, bar: 2}) Net::HTTP.get(uri) # ===> Success If you only want to check if foo is present...
Here is a bash script that I use to auto-configure displays on Ubuntu 24.04 with Xorg. Background Ubuntu always sets the primary display to the 1st (i.e. internal) display...
...bottom-aligned (the default would be aligned at their top edges). As an oddly specific bonus (you may not need this), I adjust my internal display's resolution when connected...
...previously announced it would not charge royalties for such video through December 31, 2015 (see http://www.mpegla.com/Lists/MPEG%20LA%20News%20List/Attachments/226/n-10-02-02.pdf), and today’s announcement makes clear that royalties will continue not to...
...be charged for such video beyond that time. Products and services other than Internet Broadcast AVC Video continue to be royalty-bearing...
...are attacked constantly. This lesson covers the most common attacks like XSS, CSRF and SQL injection, how Rails protects you, and where you still need to be careful. Important
Learning goals You can explain the CIA triad — confidentiality, integrity, availability — and sort any threat into it. You can explain how the most common attacks on web applications...
Shoulda Matchers don't provide canditional validations (validations with if: option). Here is how to write tests for the condition: Class: class Employee < ActiveRecored::Base validates :office, presence: true, if...
describe Employee do describe '#office' do context 'is a manager' do before { allow(subject).to receive(:manager?).and_return(true) } it { is_expected.to validate_presence_of(:office) } end context 'is...
...the same child table, declare a has_many association per condition with its own scope and dependent: :restrict_with_error, then declare the plain dependent: :destroy association last.
...The example below uses two scoped associations to keep things readable, but the same approach works with one, three, or any number of independent restrictions. class Account < ApplicationRecord
RAG is often equated with vector databases, embeddings, and semantic search. But RAG ("Retrieval-Augmented Generation") really is just 'put relevant data in the prompt' — the retrieval mechanism is up...
...to you. If your app already has any working search functionality, you can build a useful RAG pipeline with it. Semantic search can still be included later on, if really...
Rails supports time zones, but there are several pitfalls. Most importantly because Time.now and Time.current are completely different things and code from gems might use one or the other.
Your life will be easier if your application does not need to support time zones. Disable them like this: config.time_zone = 'Berlin' # Your local time zone config.active_record.default_timezone...
If you're on Ubuntu: sudo apt-get install ruby-dev On other platforms: Look for a package containing ruby header files. On Red Hat that's "ruby-devel" likely...
The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the working tree from either the index or another commit. This...
...The command can also be used to restore the content in the index with --staged, or restore both the working tree and the index with --staged --worktree. By default, if...
To force a check on your next reboot (here for your root partition), simply: touch /forcefsck To manually do this, here is how to do it for the first partition...
...on sda, when you are using ext4: fsck.ext4 -fn /dev/sda1 -f forces the check, even if everything seems okay. -n is a "read only" check, where nothing is changed and...