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...

...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...

...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 #--

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...

makandra dev
unpoly.com

...let editor = await import('wysiwyg-editor') editor.init(textarea) }) You can also use this to split up expensive tasks, giving the browser a chance to render and process user input:

...element', async function(element) { doRenderBlockingWork(element) await scheduler.yield() doUserVisibleWork(element) }) Cleaning up async work Like synchronous compilers, async compiler functions can return a destructor function: up.compiler('textarea.wysiwyg', async function(textarea...

makandra dev

...is a checklist I use to work on issues. For this purpose I extracted several cards related to the makandra process and ported them into a check list and refined...

...main/master branch Branch off the master with geordi branch or manually Name your branch like sort-users-by-name-73624, i.e. start with the issue id, then a shortened description...

...any of the gems that GEM depends on. For the example above you would say: bundle update cucumber-rails --conservative If Bundler complains of a single dependency that it cannot...

...resolve this way, simply add it to the command: bundle update cucumber-rails capybara --conservative Options for old versions of bundler The options below might be relevant if you're...

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...

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...

...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...

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.

...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...

apidock.com

...want some output. In Rails > 3.1 you have two methods at hand: announce and say_with_time. In the migration: class AddUserToken < ActiveRecord::Migration class User < ActiveRecod::Base; end

add_column :users, :token, :string announce "now generating tokens" User.find_in_batches do |users| say_with_time "For users ##{users.first.id} to ##{users.last.id}" do users.each do |user| user.update_attribute :token...

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...

When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default social networks will use the window title, the first image...

...the current URL and some random text snippet for this purpose. This is often not what you want. Luckily Facebook, Twitter, etc. lets you control how your content appears in...

...want to be in there. In order to reduce the chance to accidentally commit something you didn't intend, review your changes before committing. My preferred way of doing this...

...N . # Add all paths, but not their contents git add -p Git will now show you all your changes in small chunks and ask you in an interactive mode whether...

sitepoint.com

$number = $length / 1px // => 13 Converting a unit the result of an addition or subtraction between two numbers of different units is expressed in the first member’s unit

...the desired unit: $duration: .21s $duration-in-milliseconds: 0ms + $duration // => 210ms An example is storing a transition duration as CSS custom property to read it from Javascript. By converting the...

postgresql.org

PostgreSQL's Common Table Expressions (CTEs) can be used to extract sub-queries from bulky SQL statements into a temporary table to be referenced instead. This is most useful to...

...avoid ugly joins or sub-selects. CTEs can be used for SELECT, INSERT, UPDATE or DELETE. Example (from the PostgreSQL docs): WITH regional_sales AS ( SELECT region, SUM(amount) AS...

...can use ETags to allow clients to use cached responses, if your application would send the same contents as before. Besides what "actually" defines your response's contents, your application...

...probably also considers "global" conditions, like which user is signed in: class ApplicationController < ActionController::Base etag { current_user&.id } etag { current_user&.updated_at } end Under the hood, Rails generates...

mtlynch.io

...you prepare your changelist properly, it directs your reviewer’s attention to areas that support your growth rather than boring style violations. When you demonstrate an appreciation for constructive criticism...

...your reviewer provides better feedback . Make others better: Your code review techniques set an example for your colleagues. Effective author practices rub off on your teammates, which makes your job...

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...