$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...
...universe multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu yakkety-security...
10 http://de.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 Packages 10 http://security.ubuntu.com/ubuntu yakkety-security/main amd64 Packages 2:7.4.1829-1ubuntu2 10 10 http://de.archive.ubuntu.com/ubuntu yakkety/main...
We're always striving towards keeping our website's JavaScript as small as possible. If you're using webpack(er), you can use the webpack-bundle-analyzer plugin to get...
...a good overview, which of your JavaScript modules take up how much space, and where you can optimize. To use it, add it via npm or yarn yarn add webpack...
...default order" of rows in database tables. For instance, when you paginate a result set: When using LIMIT, it is important to use an ORDER BY clause that constrains the...
...result rows into a unique order. Otherwise you will get an unpredictable subset of the query's rows. You might be asking for the tenth through twentieth rows, but tenth...
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...
...had worked fine just a few weeks ago and there had been no changes since. Long story short: The browserslist database was simply outdated and the project's browserslist config...
...specifies "last 2 years" -- which no longer resolved to any known browsers, because the package version was older than 2 years. So, the fix is to just upgrade that package...
...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...
...on a very good network connection. To test how your application behaves on a slow network (e.g. mobile), you can simulate limited bandwidth. Chrome Open the dev tools (Ctrl+Shift...
...I or F12) and switch to the "Network" tab In the row below the dev tool tabs, there's a throttling dropdown which reads "Online" by default. Inside the dropdown...
When you need to add a event listener to hundreds of elements, this might slow down the browser. An alternative is to register an event listener at the root of...
...for events to bubble up and check whether the triggering element (event.target) matches the selector before you run your callback. This technique is called event delegation. Performance considerations
...or every even-numbered item. However, :nth-child can do more. In modern CSS specifications (Level 4), there’s an additional feature that lets you use :nth-child in combination...
...with a list of css selectors. This way, you can target the nth-child within a subset of siblings matching a selector. For example: .container .foo %span.my-selector .bar
Bundler so far ignored the version specified under BUNDLED_WITH in the Gemfile.lock. This had two annoying consequences: If the bundler version on your system was lower than in the...
...and had to manually install the correct version. If the bundler version on your system was higher than in the Gemfile.lock, bundler silently updated the version in the Gemfile.lock to...
...good UI design, you should always be able to come up with a default. Since the user interface makes up 70% of a typical web application, this is closely related...
...and a "user" are both human beings, it's rarely practical to have them share a model or inheritance hierarchy. Try to model everything as CRUD (regardless of whether a...
Splitting up commits makes the process of reviewing often easier, since you can create several merge requests or review every commit one by one. So when you find out that...
...refactoring along the current changes, you can use one of the following processes to split up the changes into several commits in a logical order: #1 Splitting up the last...
wkhtmltopdf is deprecated and shouldn't be used anymore. Please consider switching to another tool We can install wkhtmltopdf on your appserver if you need to generate PDF files...
wkhtmltopdf/wkhtmltopdf wkhtmltopdf/packaging Please note: We do not compile the package ourselves on the server. Instead, we install the most recent available version of the prebuilt package. Example:
You need to update a lof gems. Make sure you don't have any version constraints in your Gemfile or your bundle update won't do anything!
...cucumber_priority: bundle update cucumber_priority Upgrade spreewald: bundle update spreewald Upgrade cucumber_factory: bundle update cucumber_factory Upgrade parallel_tests: bundle update parallel_tests Even on the latest version...
Whenever you have to deal with randomness in a jasmine test there are some spy strategies to help you out! Let's say we have a method Random.shuffle(array) to...
...shuffle an array randomly and a class that uses shuffle within the constructor. returnValue & returnValues it('shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1])
...write complex migrations in Rails Discuss with your mentor Instead of migrations, could we simply log into the production server's SQL console and alter tables there whenever we need...
...Actor#total_movies: This field should cache the total number of movies an actor stars in Actor#first_movie_id: This field should cache the first movie to which the...
...hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts The Rails default is using rake tasks for your application tasks. These live in lib/tasks...
...case you want to avoid rake for your tasks and just use plain ruby scripts, consider lib/scripts/* as folder. Keeping tasks slim For readability and testing it's easier to...
YJIT is Ruby's default just-in-time compiler. It is considered production-ready since Ruby 3.2 (source). To activate YJIT you need two steps: Your ruby binary needs to...
...be compiled with YJIT support. You need to enable YJIT. Getting a Ruby with YJIT support We usually install Ruby with tools like rbenv or asdf. This compiles the ruby...
In long diffs, it can become impossible to spot small changes in larger blocks of moved code. This may be either a method that was moved from the top to...
...the bottom of a file, or a long test file that was split in many. Fortunately, Git offers a special highlighting mode that directs the reader's attention to relevant...
...of different file types including: Ruby (business logic) HTML fragments (layouts and views) CSS/Sass/SCSS (styles) JavaScript (client-side behavior) Static media (images, fonts, videos) Except for the Ruby part, all...
...your application assets cachable in Rails The assets pipeline history The section "network" of "JavaScript Start-up Optimization" Sprockets: Everything You Should Know About the Rails Asset Pipeline
...and how to normalize them. In the example below, the Movie#title attribute is stripped from leading and trailing whitespace automatically: class Movie < ApplicationRecord normalizes :title, with: -> { _1.strip } end
...a class. Which could look like this: class Movie < ApplicationRecord normalizes :title, with: Normalizers::StripNormalizer end The with keyword accepts any callable object that takes the attribute’s value as...
...refactor later. Always add tests on whatever we work on. When you work on something, improve that part of the code. Make sure setup for a new developer is as...
...frictionless as possible (ideally it's bin/setup). Make sure deployment is as frictionless as possible. Setup failure notifications. Set aside some time every month to deal with the most frequent...
Goals After finishing this lesson you should be able to read and write simple Ruby programs. Gain an understanding of the following concepts: Working with basic datatypes: String, Integer...
Classes and inheritance The difference between class methods and instance methods (def self.method vs. def method) Modules and include Code blocks ("procs", "lambdas") Input and output Simple regular...