...and — more and more — code that an agent wrote for you. Reviewing is a skill of its own. This lesson teaches you what to look for, how to write useful...

...code review is for: a code base that gets better over time, knowledge that spreads, bugs caught before users find them. You can review a change in order of importance...

TypeScript basically uses structural typing, which is conceptually quite similar to duck typing, but with static compile-time type checking. We'll explore what this means in practice.

...a superset of JavaScript, meaning TypeScript compiles down to native JavaScript syntax and checks type consistency only at compile time. Idea of Structural Typing TypeScript only wants to know whether...

...but does not have to be. It's actually very easy when done right. Summary (tl;dr) Here's the short version: Define a table_name_prefix method in the...

...not define any table_name_prefix in ActiveRecord classes inside of it. If this sounds familiar, we have a card about using it already. This card explains why you want...

Code that works is not enough; it must stay easy to change. This lesson introduces the principles of maintainable code: avoiding duplication, small responsibilities, clear names and loose coupling.

...in teacher mode. Learning goals You can explain why working code isn't enough: software entropy, and the cost of change over an application's lifetime. You can recognize duplication...

Let's say you need to revert a migration that happened a while back. You'd create a new migration that removes what was added back then in the up...

...do that. Especially when the up/down paths already contained some logic (that executed update statements on the created column, for example), copying does not feel right. Someone already added the...

...following places and uses the first implementation it finds: Methods from the object's singleton class (an unnamed class that only exists for that object) Methods from prepended modules (Ruby...

...from the object's class Methods from included modules Methods from the class hierarchy (superclass and its ancestors) Example Let's say we have the following class hierarchy: class Superclass...

makandra dev
getmdl.io

CSS (+ some Javascript) framework, implementing Google's material design for static web pages. Can be used for plain websites without requiring a full blown Javascript framework, unlike the (also excellent...

...elements, or Angular material. Prelimiary impression: I would recommend against using it at this stage, for a couple of reasons: It is much less complete than you might expect from...

kernel.org

Git allows you to do a binary search across commits to hunt down the commit that introduced a bug. Given you are currently on your branch's HEAD that is...

...not working as expected, an example workflow could be: git bisect start # Start bisecting git bisect bad # Tag the revision you are currently on (HEAD) as bad. You could also...

...binary, do not install Ubuntu's node package. Instead, you need to create a symlink that points to the binary one of the nodejs package: sudo ln -s /usr/bin/nodejs /usr/bin/node...

...You probably already installed NodeJS. In case you did not: sudo apt-get install nodejs If you already installed the node Ubuntu package, bower will just do nothing (i.e. not...

Note: This applies to plain Ruby scripts, Rails does not have this issue. When you work with Ruby strings, those strings will get some default encoding, depending on how they...

...are created. Most strings get the encoding Encoding.default_internal or UTF-8, if no encoding is set. This is the default and just fine. However, some strings will instead get...

Most of MovieDB is server-rendered and enhanced with Unpoly, and that's our default. Sometimes one region of a page needs more interactivity than that model gives you comfortably...

...Then we build an island: a React component mounted into a server-rendered page. This card teaches the React basics you need for that — components, state, effects, talking to Rails...

The most common use case for Ruby's #collect is to call a method on each list element and collect...

github.com

The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall to it: its way of applying the orphan_strategy which...

...might want to disallow destruction if there are any child nodes present. The restrict strategy does the trick but raises an exception when destroy is called: has_ancestry :orphan_strategy...

...to be defined ahead of your before block and can be different for individual sections. It works just like that: describe User do describe '#locked?' do before :each do subject.should...

...receive(:current_plan).and_return plan end context 'when expiring today' do let(:plan) { stub(:expiry => Date.today) } it 'should be false' do subject.should_not be_locked end end context 'when...

...up. Run /trainee-setup. It will pick a folder for your code, create a folder for stand-alone exercises and prepare your global agent configuration. The MovieDB app comes later, in...

...you're stuck is fine and visible in the transcript. Doing it secretly in a side-session defeats the purpose of your own training. Explain it or don't ship...

Use Socket.gethostname. So for a machine whose hostname is "happycat", it will look like this: >> Socket.gethostname => "happycat" That should work right away for your Rails application. For plain Ruby, you...

...first need to do: require 'socket' If you don't want to use Socket for some reason, you can still just use the hostname command, at least on non-Windows...

When you regularly make use of Cucumber's "show me the page" step (or let pages pop up as errors occur), the capybara-20120326132013.html files will clutter up your Rails root...

To tell Capybara where it should save those files instead, put this into features/support/env.rb: Capybara.save_and_open_page_path = 'tmp/capybara...

The will_paginate gem will show a default of 30 records per page. If you want to test pagination in a Cucumber feature, you don't want to create...

...records just for that. Instead, you probably want to modify the number of items shown, by saying something like this: Given we paginate after 2 users Using the following step...

Forms in PDF documents follow the AcroForm definition. Prawn has no native support for it, but you can build form fields through plain PDF objects. The card is only about...

...fields, since I have only used those. Text fields Here is how to add a single-line text field, e.g. in a Prawn::View class. Note that ref! and state...

To find a hash key by it's value, i.e. reverse lookup, one can use Hash#key. It's available...

Sometimes you want git to ignore certain files that appear on your machine. You can do this in 3 ways: Per project, in the project's .gitignore file

Downsides of per-project .gitignore entries While it might be tempting to set it per project (other devs might benefit from it), you need to do it each...

...to an open redirect vulnerability. Your application's generated route methods with a _url suffix are also affected because they use url_for unter the hood. The problem

...use links with your application's hostname, cause a redirect to evil.tld and present a sign-in form which looks like yours. Users will enter their login credentials and submit...

...has a very different disk usage on it's nodes you can use these steps to rebalance the shards. Attention Before we begin it's important to understand how Elasticsearch/OpenSearch...

...defines balance: The balance of the cluster depends only on the number of shards on each node and the indices to which those shards belong. It considers neither the sizes...

...consider processing your images with libvips instead of ImageMagick. Reasons for libvips There are several upsides to using libvips over ImageMagick: libvips is considerably faster and uses less memory.

...has a large attack surface that has repeatedly caused security incidents in the past (compare ImageMagick CVEs with libvips CVEs). Ubuntu is sometimes slow to fix the numerous ImageMagick vulnerabilities...