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...
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...
...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...
The most common use case for Ruby's #collect is to call a method on each list element and collect...
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...
...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...
...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 repeat a subpattern with a *, + or {...} operator, you may choose between greedy, lazy and possessive modes. Switching modes may affect the result and performance of your regular expressions...
...In the worst case, an ill-suited mode may make your regular expression so slow that it can DoS your application (Examples are the ActiveRecord's PostgreSQL CVE...
Rails has configurable time zones, while Ruby is always in the server's time zone Thus, using Ruby's time API will give you wrong results for...
...zones, because their existence is a fact. You can, however, tell Rails the only single time zone you'll need is the server's. config.time_zone = "Berlin" # Local time zone...
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...
...be answered with an empty response if the underlying content hasn't changed. This saves CPU time and reduces the bandwidth cost for a request/response exchange to about 1 KB...
...can be considered secure. Random masking of CSRF tokens was introduced to mitigate BREACH, a side-channel attack against HTTPS that was published in 2013. BREACH is pretty hard to...
Migrating data from a legacy into a new system can be a surprisingly large undertaking. We have done this a few times. While there are significant differences from project to...
...project, we do have a list of general suggestions. Before you start, talk to someone who has done it before, and read the following hints: Understand the old system
on the bash (issued as postgres user) Start/Stop/Restart PostgreSQL pg_ctl -D $configdir start|stop|restart Start/Stop/Restart the corresponding PostgreSQL using the given configuration directory. The configuration directory should contain...
...the postgresql.conf file. The following example would start the PostgreSQL of our governor instances: pg_ctl -D /var/lib/postgresql/config start PostgreSQL fast shutdown pg_ctl -D $configdir stop -m fast
To open a terminal quickly navigate to System → Preferences → Keyboard Shortcuts. There, click the "Run a terminal" row (It should be in the "Desktop" section) and press the keyboard shortcut...
...for Ubuntu's default terminal is gnome-terminal. Be aware that many programs use shortcuts of their own and you would not want to clash with those (like Ctrl+T...
...be a quick fix for an existing app. It also ensures that future uploaders get safe-ish defaults when the developer forgets to define an allowlist for concrete uploaders (see...
...you can also go with this more relaxed CSP: Content-Security-Policy: default-src 'self'; script-src 'none'; object-src 'none' While this does not fix users uploading executables etc...