makandra Curriculum

...does a feature look and feel). Frequent deploy gets changes to users faster. We sleep better, because we know stuff still works. Make sure no one removes a feature by...

...to write both with "should" and "expect" You should know how to enable the old #should-syntax in RSpec 3 Understand what "Test the behavior, not the implementation" means.

Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done in a migration because it takes a long time.

...s say you do something like this: Project.all.each(&:recalculate_statistics!) Even though you may have been successful with this on your development machine or the staging server, keep in mind...

...old to match the format created by pg_dump. The version of the PostgreSQL server doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL...

...amd64] after deb so that it reads deb [arch=amd64] https://... or deb [arch=amd64 signed-by=.... Workaround Step 2: Connect with host option The latest PostgresQL client will only...

...create a Gemfile for installing all required gems. Gemfile # Gemfile gem 'docker-api' gem 'serverspec' Then we install them bundle install Preparation Create the directory where the Tests are going...

...to live. Add the folder to .dockerignore since we wo not want the test to be included within our final container image. mkdir spec echo spec >> .dockerignore spec/spec_helper.rb

makandra Curriculum

...progress for the Rails 7 version Documentation for rspec-core Using metadata attributes to write spec-type specific before blocks Shared examples and contexts in RSpec Testing shared traits or...

Sharing test setup can lead to DRY, but tightly coupled test code. Read Prefer self-contained examples for an argument for isolating tests instead, even if it means some...

Normally, Rails handles encryption and signing of cookies, and you don't have to deal with the matter. Should you need to decrypt a session cookie manually: here is how...

...Obviously, you can only decrypt a session cookie from within the corresponding Rails application. Only the Rails application that encrypted a cookie has the secrets to decrypt it.

makandra Curriculum

Understand how nested attributes appear in the params. See how the Rails form helpers encode the names of nested inputs. Understand how the record and all of its nested...

...attributes are saved in a transaction. That means the entire structure is saved or not. Resources Rails Guide: Nested forms Nested Forms in Rails Popular mistakes when using nested forms...

makandra dev
iamvdo.me

Line-height and vertical-align are simple CSS properties. So simple that most of us are convinced to fully understand how they work and how to use them. But it...

...less-known feature of CSS: inline formatting context. For example, line-height can be set as a length or a unitless value 1, but the default is normal. OK, but...

...this.boundStopLock = this.stopLock.bind(this) // Stream rendering document.addEventListener("turbo:before-stream-render", this.boundLockTurboStreamRendering) // Form submission document.addEventListener("turbo:submit-start", this.boundStartLock) document.addEventListener("turbo:submit-end", this.boundStopLock) // Network activity document.addEventListener("turbo:before-fetch-request...

...render", this.boundStopLock) } disconnect() { // Stream rendering document.removeEventListener("turbo:before-stream-render", this.boundLockTurboStreamRendering) // Form submission document.removeEventListener("turbo:submit-start", this.boundStartLock) document.removeEventListener("turbo:submit-end", this.boundStopLock) // Network activity document.removeEventListener("turbo:before-fetch-request...

Option 0: Download from the official page (preferred) Open https://googlechromelabs.github.io/chrome-for-testing/ In Section "Stable" > chromedriver / linux64 > Download ZIP from URL Take the chromedriver binary from the ZIP file and...

...your path like this: echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile Option 2: Use apt source Warning Wo no longer recommend this option. After a chrome update, the chromedriver package sometimes...

expect(page).to have_field('Username') { |field| field[:class].blank? } Limitations Using execute_script, evaluate_script or evaluate_async_script within a filter block will crash with a timeout...

...Selenium::WebDriver::Error::ScriptTimeoutError Exception: script timeout This is due to Capybara using a zero timeout while calling the filter block. A workaround is to temporarily set a different timeout...

You can execute systemctl --user --failed to check for failed systemd user units. But let's face it: It's inconvenient and you'll probably miss failures. Better use desktop...

...pipewire.socket ConditionUser=!root [Service] LockPersonality=yes MemoryDenyWriteExecute=yes NoNewPrivileges=yes RestrictNamespaces=yes SystemCallArchitectures=native SystemCallFilter=@system-service Type=simple ExecStart=/usr/bin/pipewire Restart=on-failure Slice=session.slice [Install] Also=pipewire.socket

...moving a file, your imports also need to change. To get around this, esbuild support a mechanism first introduced in TypeScript called "path aliases". It works like this:

...if you do use TypeScript): { "compilerOptions": { "baseUrl": "./app/assets", "paths": { "@/*": ["js/*"], "@images/*": ["images/*"], "@css/*": ["css/*"], "@spec/*": ["../../spec/js/*"] } }, "include": [] } (The include: [] only makes sense if you do not use Typescript. If you...

web.archive.org

This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as one pretty commit. Squashing commits with git rebase

...here will destroy commit history and can go wrong. For this reason, do the squashing on a separate branch: git checkout -b squashed_feature This way, if you screw up...

The attached patch lets you find a record by a string or number in any column: User.find_by_anything('carla') User.find_by_anything('email@domain.de') User.find_by_anything(10023)

User.find_by_anything!('carla') Boolean and binary columns are excluded from the search because that would be crazy. I recommend copying the attachment to features/support/find_by_anything.rb, since it is...

}) Example case I had an Unpoly compiler for a tab navigation, which sets an -active class per default to the first tab link and removes it from all...

...other tab links. If another tab link is clicked, the -active class switches to the clicked link. In a Jasmine spec I wanted to test this behaviour. Unpoly's up.hello...

...binary file. This method might be telling the truth most of the time. But sometimes it doesn't, and that's what causes pain. The method is defined as follows...

...not guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true # File.binary?('somefile.txt') # => false #--

makandra dev

...text right next to the code: notes for other developers, and for your future self. You can imagine comments as post-its (or sometimes multi-sheet letters ...) on real-world...

...objects like cupboards, light switches etc. As always, with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code...

developer.mozilla.org

...animate HTML elements using the Web Animation API's method .animate(keyframes, options) (which seems to be Baseline for all browsers since 2022). const fadeIn = [{ opacity: 0 }, { opacity: 1 }] // this...

// the animation object can be used for things like querying timings or state or `pause`, `cancel` the animation animation.pause() animation.play() await animation.finished // do other stuff Even though play...

To return non-HTML responses (like XLS spreadsheets), we usually use the respond_to do |format| format.xls do # send spreadsheet end end This is often, but not always the same...

...one format checks for authorization and the other doesn't. params[:format] is only set when a user explicitly puts a .xls at the end of the URL. The format.xls...

options.add_option(:web_socket_url, true) options.add_option(:page_load_strategy, 'none') # required for selenium-webdriver 4.27+ end Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) In combination with...

...ignore' } (which we recommend setting) any unload alerts will now stay open until handled. Note Selenium-Ruby doesn't allow setting the unhandled prompt behavior to a hash yet. See...

Looking at the source code of the validates_numericality_of validator, it becomes clear that it converts the attribute in question to either an integer or float: if configuration[:only...

...any of your users as this is only broken in the most extreme case shown above...

makandra dev

If you want to play music or sounds from a browser, your choice is to use either Flash or the new tag in HTML5. Each method has issues, but depending...

Can play MP3s or Wave files. Cannot play OGG Vorbis audio. Cannot reliably seek to a given position when playing VBR-encoded MP3s. HTML5 audio Is the future, but...

TL;DR: Rails ships two methods to convert strings to constants, constantize and safe_constantize. Neither is safe for untrusted user input. Before you call either method you must validate...

...the input string against an allowlist. The only difference between the two methods is that unresolvable constants raise an error with constantize, but return nil with safe_constantize. If you...