List of Chromium Command Line Switches « Peter Beverloo
An extensive list of command line options when booting Chrome.
This is useful for building a Capybara driver with custom Chrome options.
Gatekeeping: Guide for developer
If your project manager wants to do gatekeeping on a project, as a developer you need to follow the following guidelines (e.g. by using something like this issue checklist template).
In order to reduce the number of rejects we get from clients, we want to review all code written before it goes to the staging server.
Note: This process is tailored to our specific needs and tools at makandra. While it will certainly not apply to all (especially larger tea...
Yarn: if integrity check won't let you start rails console
I ran into a situation in which I received the yarn integrity check warning when starting the rails console even though everything was up to date and correct versions in use.
TLDR: run spring stop
I tried starting the rails console without switching to the correct node version first and received the yarn integrity warning.
warning Integrity check: System parameters don't match
error Integrity check failed ...
Ruby: required keyword arguments in the pre-2.1 era
Starting with Ruby 2.0 you can define methods with keyword arguments.
In 2.1+ required keyword arguments can be defined by using a colon without default value:
def match(value, ignore:)
# ...
end
To accomplish something similar in ruby 1.8, use:
def match(value, options = {})
ignore = options.fetch(:ignore)
# ...
end
How to avoid raising RestClient exceptions for 4xx or 5xx results
When using RestClient to make an HTTP request, it will raise an exception when receiving a non-successful response.
HTTP status codes like 422 or 403 might be totally expected when talking to APIs, so plastering your code with rescue RestClient::Exception
or similar can feel annoying.
It may not be intuitive, but the readme says you can also pass a block to methods like RestClient.get
or RestClient::Request.execute
. In that case, RestClient will not raise ...
Die Grenzen von SEO: was Suchmaschinenoptimierung nicht ist
Der verlinkte Artikel grenzt präzise ab, welche Aufgaben zur Suchmaschinenoptimierung (SEO) gehören und welche nicht.
Suchmaschinenoptimierung ist eine Querschnittsfunktion: die Arbeit vieler unterschiedlicher Abteilungen hat Einfluss auf den SEO-Erfolg der Firma. In diesem Beitrag versuchen wir deswegen, den Kern von SEO zu definieren.
Capybara: Easiest way to get the parent of an element
If you already selected an element and want to get its parent, you can call find(:xpath, '..')
on it.
To get the parents parent, call find(:xpath, '../..')
.
Example
Find a link which contains a twitter icon and check that it links to the correct page:
<a href="http://twitter.com/">
<i class="icon is-twitter"></i>
</a>
link = page.find("a .icon.is-twitter").find(:xpath, '..')
link[:href].should == "http://twitter.com/"
There is a good overview on xpath syntax on [w3schools](https://www.w3schools.com...
Don't use migrations to seed default data
Don't insert table rows in a Rails database migration. This will break tests that expect that database to be empty and cause you all sorts of pain.
If you need a place for default application data, use db/seed.rb or put a script into lib/scripts
. It won't run automatically, so add a chore story to Pivotal Tracker as a reminder.
GitHub Actions: Manually running a workflow
To start a workflow manually it must have a trigger called workflow_dispatch
:
---
name: Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
branches:
- master
In the Actions tab of your repo you can now select a workflow and press "Run Workflow".
GitHub Actions: Retrying a failing step
If you have a flaky command you can use the nick-invision/retry to re-try a failing command, optionally with a timeout:
---
...
jobs:
test:
...
steps:
- name: Run tests
uses: nick-invision/retry@v2
with:
timeout_seconds: 30
max_attempts: 3
command: bundle exec rake spec
Custom error pages in Rails
Basic error pages
To add a few basic styles to the default error pages in Rails, just edit the default templates in public
, e.g. public/404.html
.
A limitation to these default templates is that they're just static files. You cannot use Haml, Rails helpers or your application layout here. If you need Rails to render your error pages, you need the approach below.
Advanced error pages
- Register your own app as the applicatio...
Find an ActiveRecord by any column (useful for Cucumber steps)
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)
There's also a bang variant that raises ActiveRecord::NotFound
if no record matches the given value:
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 most useful in Cucumber step def...
How to checkout submodules in Gitlab CI
Accessing other repositories in Gitlab CI is not straight forward, since the access rights of the current pipeline might not be sufficient enough.
One approach is to use project access tokens and clone the repositories via HTTPS.
-
Create a project access token for all submodules you want to have access to with the setting
read_repository
- Add the secrets as environment variable to the main project you want to have access to submodules:
- Protected
false
...
- Protected
Git: Show commits that have touched specific text in a file
If you want to find the commits that touched a specific text in a file, use
git log -S 'text in the code' -- path/to/file
If you use tig you may run a similar command to get a navigatable list of affected files:
tig -S'text in the code'
Example
Here is an example, where the move of the convert_number_column_value(value)
method in active record is traced (simplified output):
git log -n 1 --pretty=oneline -S 'convert_number_column_value(value)' -- activerecord/lib/active_record/base.rb
ceb33f84933639d3b6...
Undefined method log for Selenium::WebDriver::Remote::W3C::Bridge
In case your integration tests crash with a message like below, try to upgrade Capybara to a newer version (3.35.3 was good enough). You might encounter this issue when you enabled the w3c option in Selenium.
undefined method `log' for #<Selenium::WebDriver::Remote::W3C::Bridge:0x000055995647ded0>
Your affected code might look similar to this call below and will work after the upgrade again.
Upgrading Capybara with deprecated Integer selectors
Capybara added a deprecation warning in version 3.35.3 (version from 2019) that shows up if your selector is not of type String or Symbol.
Example:
click_link(10) # bad
click_link("10") # good
You might encounter this error e.g. in a pagination step or similar where you want to click on numbers. To figure out where this deprecation warning comes from try to run the tests with a step output.
bundle exec parallel_cucumber --test-options "--format=pretty" feature
The deprecation message looks like following:
Locator In...
Geordi 6.0.0 released
6.0.0 2021-06-02
Compatible changes
-
geordi commit
will continue even if one of the given projects is inaccessible. It will only fail if no stories could be found at all.
Breaking changes
- Removed VNC test browser support for integration tests – Headless Chrome has
matured and is almost a drop-in replacement. Also, key binding issues have
increased with VNC and recent Linux.- Please use a headless Chrome setup https://makandracards.com/makandra/492109-capybara-running-tests-with-headless-chrome.
- You might also ...
PSA: Chrome and Firefox do not always clear session cookies on exit
Cookies without an expiration timestamp are called "session cookies". [1] They should only be kept until the end of the browsing session.
However, when Chrome or Firefox are configured to reopen tabs from last time upon start, they will keep session cookies when closing the browser. This even applies to tabs that were closed before shutting down the browser.
This is by design in Chrome and [Firefox](https://bugzilla.mozilla.org/buglist.cgi?bug_id=337551,345830,358042,362212,36...
Chromedriver: Disabling the w3c option might break your integration tests with Chrome 91
We recently noticed issues with Chrome 75+ when having the w3c
option enabled within the Selenium webdriver. It looks like recent Selenium versions don't have any issues with the w3c interface anymore. And starting with Chrome 91 this fix might cause unexpected issues, so you should try to enabled this option again or just remove the following line from you configuration:
options.add_option('w3c', false)
Background: Setting the w3c
option t...
Heads up: counting may be slow in PostgreSQL
The linked article points out that COUNT
queries might be unexpectetly slow in psql.
If you just need to know "are there any records" use any?
. This uses SELECT 1 AS one FROM ... LIMIT 1
under the hood.
If you just need to know "are there no records" use empty?
or none?
. This uses SELECT 1 AS one FROM ... LIMIT 1
under the hood.
In short: Replace foo.count > 0
with foo.any?
or foo.count == 0
with foo.none?
RubyMine / IntelliJ: How to increase UI and fonts for presentations
When giving a presentation where you do some coding, the font size you usually use is probably a bit too small and makes code hard to read for users on smaller screens or low-bandwidth connections when the image quality is lower.
Here are two solutions.
Presentation Mode
RubyMine offers a "Presentation Mode" which you can use. Simply navigate to View → Appearance → Enter Presentation Mode to enable it.
This will increase your code editor's font size as well as your UI and works nicely when sharing a single file.
However, some control...
Marko Denic's list of TIL for HTML
Table of content for the linked article:
1. The `loading=lazy` attribute
2. Email, call, and SMS links
3. Ordered lists `start` attribute
4. The `meter` element
5. HTML Native Search
6. Fieldset Element
7. Window.opener
8. Base Element
9. Favicon cache busting
10. The `spellcheck` attribute
11. Native HTML sliders
12. HTML Accordion
13. `mark` tag
14. `download` attribute
15. Performance tip
16. Video thumbnail
17. input type="search"
Capistrano: Speeding up asset compile during deploy
Remember How to skip Sprockets asset compile during Capistrano deployment and Automatically skipping asset compilation when assets have not changed? Turns out there is an even better way to speed up Capistrano deployments with asset compilation – and it's even simpler.
Adding the asset cache directory to symlinked directories
Popular asset managers for Rails are Sprockets and Webpacker. Both keep a cache of already compiled files that we're going to leverage for deployments now.
- Sprockets cache...
Webpack: Automatically generating an icon font from .svg files
Over the years we have tried several solution to have vector icons in our applications. There are many ways to achieve this, from SVGs inlined into the HTML, SVGs inlined in CSS, JavaScript-based solutions, to icon fonts.
Out of all these options, the tried and true icon font seems to have the most advantages, since
- icon fonts are supported everywhere
- they perform well and require no JavaScript at all
- their icons align nicely with text
- their icons automatically inherit color and size of the surrounding text
The big issue used to b...