3864 cards
Linked contentAuto-destruct in 6 days

Updated: Make Capistrano use SSH Key Forwarding


Agent forwarding should be enabled with caution. Users with the ability to bypass file permission on the remote host (e.g. the root user) can access the local agent through the forwarded connections. Its not possible to extract your key, but it would be possible to use your agent forwarding to connect to other hosts with your agent/identity.

Never enable SSH Agent forwarding globally in your ssh_config

Missing certificates for rubygems and bundler in Ruby 1.8.7

Using Ruby 1.8.7 you will not be able to use the maximum versions Rubygems 1.8.30 and Bundler 1.17.3 with https://rubygems.org/ anymore. This is a result of a server certificate on December 5th, 2020. The resulting errors will look like following:

  • TypeError: can't modify frozen object
  • Could not verify the SSL certificate for https://rubygems.org/*
  • Bundler::Fetcher::CertificateFailureError: Could not verify the SSL certificate for https://index.rubygems.org/versions.
  • `Error fetching data: hostname was not m...

A few recent CSS properties

  • Feature Queries (Edge 12+): Similar to @media queries, @supports blocks can be scoped to browsers that support a given declaration. There is CSS.supports() to do the equivalent in Javascript.

  • backdrop-filter (Edge 17+, but not FF): Applying filters to what is visible through an element.

  • [touch-action](https://d...

Linked content

liquidprompt: A full-featured & carefully designed adaptive prompt for Bash & Zsh

Liquid Prompt gives you a nicely displayed prompt with useful information when you need it. It shows you what you need when you need it. You will notice what changes when it changes, saving time and frustration. You can even use it with your favorite shell – Bash or zsh.

liquidprompt Examples

Configuring Webpacker deployments with Capistrano

When deploying a Rails application that is using Webpacker and Capistrano, there are a few configuration tweaks that optimize the experience.

Using capistrano-rails

capistrano-rails is a Gem that adds Rails specifics to Capistrano, i.e. support for Bundler, assets, and migrations. While it is designed for Asset Pipeline (Sprockets) assets, it can easily be configured for Webpacker. This brings these features to the Webpacker world:

  • Automatic removal of expired assets
  • Manifest backups
# c...

Git: Switching back to the previous branch

With "git checkout -" you can switch back to the branch you previously worked on.

(master) $ git checkout foobar
Switched to branch 'foobar'
(foobar) $ git checkout -
Switched to branch 'master'
(master) $

This also works with other commands like git merge:

(master) $ git checkout foobar
Switched to branch 'foobar'
(foobar) $ git merge -
Merged branch 'master'

Testing ActiveRecord validations with RSpec

Validations should be covered by a model's spec.

This card shows how to test an individual validation. This is preferrable to save an entire record and see whether it is invalid.

Recipe for testing any validation

In general any validation test for an attribute :attribute_being_tested looks like this:

  1. Make a model instance (named record below)
  2. Run validations by saying record.validate
  3. Check if record.errors[:attribute_being_tested] contains the expected validation error
  4. Put the attr...

Geordi: How to rerun failed features

Cucumber will save a file tmp/parallel_cucumber_failures.log will the filenames and line number of the failed scenarios after a full test run.

Normally you can say cucumber -p rerun (rerun is a profile defined by default in config/cucumber.yml) to rerun all failed scenarios. Unfortunately this does not work with geordi yet.

Here is a list of possible workarounds, that depends on you personal taste:

With geordi

geordi cucumber @tmp/parallel_cucumber_failures.log


# Run the `c...
Linked contentRepeats

Using the alt attribute and the figcaption element in HTML

The linked blog post contains some background information about the alt attribute and the figure / figcaption element. It is interesting, that a figure is not only for images but also for captions, code snippets, quotations and more.

Linked contentRepeats

How to Make Your Code Reviewer Fall in Love with You

Why improve your code reviews?
Improving code review technique helps your reviewer, your team, and, most importantly: you.
Learn faster: If 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...

How to remove entries from the bash history

Sometimes you accidentally generate entries in the bash history that you do not want to have there (e.g. commands with credentials).
Here's how to remove single entries.

You can look at the bash history with the history command.
To see e.g. the last 5 entries, use history | tail -n 5:

>history | tail -n 5
 1994  my-secret-command
 1995  cd xyz-mnt/
 1996  ls
 1997  cd appliance/
 1998  cd ..

Each entry has a number. You can use that to delete it: history -d 1994. Note that as you delete entries, the numbers of the following...

Linked contentRepeats

JavaScript basics tutorial: 33 Concepts Every JavaScript Developer Should Know

This repository was created with the intention of helping developers master their concepts in JavaScript. It is not a requirement, but a guide for future studies. It is based on an article written by Stephen Curtis.

Table of Contents

  • Call Stack
  • Primitive Types
  • Value Types and Reference Types
  • Implicit, Explicit, Nominal, Structuring and Duck Typing
  • == vs === vs typeof
  • Function Scope, Block Scope and Lexical Scope
  • Expression vs Statement
  • IIFE, Modules and Namespaces
  • Message Queue and Event Loop
  • setTimeout, setInte...

A quick introduction to CORS


Cross-Site Request Forgery (CSRF) is an attack pattern for websites. A CSRF attack is usually relevant in a browser context, where state is kept for multiple domains (as opposed to independent requests made e.g. with curl). The most common example is authentication via cookies. If a script on https://example.com made requests to https://docs.google.com, the browser would send all cookies for docs.google.com along, effectively given the script access to anythin...

Linked contentRepeats

How to have a target=_blank link open with DevTools open

In the tab where you need it, open Chrome DevTools with F12, open settings with F1, scroll down to the "Global" section and check "Auto-open DevTools for popups".

When you follow a link with target=_blank within that tab, DevTools will be open and you can inspect e.g. request headers.

How to fix: Pasting in IRB 1.2+ is very slow

IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting longer contents is incredibly slow.

You can fix that by disabling said features. [1] Ruby 3.0.0-pre2 / IRB 1.2.6 solved the issue.

Option 1:

Add a command line flag when opening an IRB:

irb --nomultiline

This also works on modern Rails when using rails console like so:

rails console -- --nomultilin...

Variable fonts for web developers

This card is mainly an explanation how variable fonts work in CSS, not necessarily a recommendation to actually use them.

What is a variable font?

Designing and rendering fonts are two highly complex topics. For an arbitrary text to appear properly on your screen, its font must be created multiple times for different "settings" like stroke width (boldness) and style (e.g. italic).

Now as web developers, we usually ship these variants of the same font via multiple @font-faces of the same font-family:


How to not repeat yourself in Cucumber scenarios

It is good programming practice to Don't Repeat Yourself (or DRY). In Ruby on Rails we keep our code DRY by sharing behavior by using inheritance, modules, traits or partials.

When you reuse behavior you want to reuse tests as well. You are probably already reusing examples in unit tests. Unfortunately it is much harder to reuse code when writing integration tests with Cucumber, where you need t...


FactoryBot: Passing attributes to associated records using transient attributes

FactoryBot.define do

  factory :parent do
    transient do
      child_name nil
      child_allowed_to_drive false
    child do
      association(:child, name: child_name, allowed_to_drive: child_allowed_to_drive)

  factory :child do
    name 'Child'
    allowed_to_drive false


# Usage
daughter = FactoryBot.create(:parent, child_name: 'Lisa').child
daughter.name # => 'Lisa'
daughter.allowed_to_drive? # => false

son = FactoryBot.create(:parent, child_name: 'Benedikt', child_allowed_to_drive: tr...
This website uses short-lived cookies to improve usability.
Accept or learn more