This is an attempt to list some of those things: On the server Always optimize: Don't do stupid things with the database. Avoid "n + 1" queries. Don...

...Use form models. Optimize on demand: Don't optimize without knowing what's actually slow. Measure first, for example by using a performance monitoring tool like NewRelic, Scout, AppSignal, Skylight...

If your shell seems frozen You probably pressed Ctrl-S which stops the buffer. Try Ctrl-Q to resume. If your shell behaves strangely (no input being displayed, strange character...

...Try typing this, followed by pressing the return key: reset That should clear the screen and reset output settings etc...

...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...

When navigating back to a page that was received from a POST request, undesired side effects may happen. Therefore, modern browsers try to keep users from doing so, i.e. Firefox...

...an error page explaining what's wrong. If the user presses "Try Again", it shows an additional alert asking whether the user is certain. Solution If you need to circumvent...

When searching for text in a MySQL table, you have two choices: The LIKE operator FULLTEXT indexes (which currently only work on MyISAM tables, but will one day work on...

...InnoDB tables. The workaround right now is to extract your search text to a separate MyISAM table, so your main table can remain InnoDB.) I always wondered how those two...

bbs.archlinux.org

xterm by default uses black text on white background. To change that to something like "light gray on black", do a vim ~/.Xresources ...and put this in there: xterm*background...

xterm*foreground: lightgray Afterwards, feed these changes to your current X session: xrdb ~/.Xresources Any subsequent xterm will be colored white on black background. Hint: While you're at...

bundler.io

bundle open BUNDLED_GEM will open the BUNDLED_GEM's source code in your default editor...

jeffkreeftmeijer.com

Back when Steak was first released, Capybara didn’t have any of the nice RSpec helpers it does now. A lot has changed since. Besides the helpers, it got its...

...own RSpec acceptance testing DSL recently, essentially eating Steak’s functionality and turning it into a complete acceptance testing solution (on top of RSpec...

An alternative could be to use the MySQL Docker image which is still updated for 5.6. Ubuntu 16.04 only provides packages for MySQL 5.7 which has a range...

...list of official APT repositories for MySQL 5.6, but those repositories do not yet support Ubuntu 16.04. However, the 15.10 repos will work for 16.04. I would not recommend to...

makandracards.com

...have a README that gives the reader a quick overview of the project. Its size will vary as projects differ in complexity, but there should always be some introductory prose...

...for a developer to read when starting on it. Purpose That's already the main purpose of a project README: Give a new developer a quick overview of the project...

...response includes caching headers like Expires or Cache-Control, their validity depends on the server's Date header if present. Otherwise, the browser uses its local time. This can lead...

...for authentication. The cookie for this feature might include an Expires attribute, specifying its validity: Set-Cookie: remember_me=abc123; Expires=Fri, 15 Dec 2023 12:00:00 GMT

We recommend configuring Selenium's unhandled prompt behavior to { default: 'ignore' }. When running tests in a real browser, we use Selenium. Each browser is controlled by a specific...

...driver, e.g. Selenium::WebDriver::Chrome for Chrome. There is one quirk to all drivers (at least those following the W3C webdriver spec) that can be impractical: When any user prompt...

...an error in the User#name method) you will end up with a confusing stacktrace that looks like you have an error in your render call. If this happens to...

...you, temporarily remove the annotation to see the correct error. Niklas opened an issue in rails, a fix is merged and will arrive in Rails >7.2.2.2 and...

When you do something like this in your code: def var_value @var ||= some_expensive_calculation end Be aware that it will run some_expensive_calculation every time you call...

This illustrates the problem: def some_expensive_calculation puts "i am off shopping bits!" @some_expensive_calculations_result end When you set @some_expensive_calculations_result to nil...

When your Solr seems to be started properly (a process is running with the correct data directory) but never responds properly and replies (via the API or web interface) with...

... check if Solr's log directory is actually writable for the user running it...

Dealing with exceptions in a Rails application is (surprisingly) complex. There are multiple configurations and methods that influence how exceptions are actually handled. This card explains some of the interactions...

...is raised in your app you want the following things to be true: Your server should not crash (your Ruby process should continue to run) Your user should receive an...

makandra dev

...chat messages, and it will load them into its context for analysis. Note For scanned pages that may be sideways or upside down, auto-rotate them first. Autocrop assumes upright...

...px so text remains readable. To convert PDF pages to scaled down images: pdftoppm -png -scale-to 1500 input.pdf output_prefix Convert images to thumbnails: vipsthumbnail input.png --size 1500x1500 -o...

makandra dev

...example, the configuration for SASS files looks like this: { test: /\.(scss|sass)$/i, use: [ { loader: 'style-loader', options: {...

{ loader: 'css-loader', options: {...

{ loader: 'postcss-loader', options: {...

{ loader: 'sass-loader', options...

...loaders (which are usually npm modules) are run on it in reverse order. First, the sass-loader converts SASS to regular CSS. Then, the postcss-loader uses PostCSS to postprocess...

...be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a sign-up form. It runs inside your application and does not depend on an external...

...set config.not_rfc_mx_lookup_flow = true. Validation methods explained Regex validation (1) is pretty straight-forward and basically "free" since you're not making and network connections. SMTP validation...

...looking for a functionality in RubyMine but don't know or remember its keyboard shortcut or which menu it is located in?\ Hit Ctrl+Shift+A. This will bring up...

...the result from the list to run it. The list of results will also show you any assigned keyboard shortcuts...

...method for controllers. The most common way is to pass an ActiveRecord instance or scope, and fresh_when will set fitting E-Tag and Last-Modified headers for you. For...

...scopes, an extra query is sent to the database. fresh_when @users If you do not want that magic to happen, e.g. because your scope is expensive to resolve, you...

...line goes from baseline up to the capital top. That's because text usually starts with a capital letter, plus descenders are far less frequent than ascenders.

...center an icon (or any "blockish" inline element, really) with the capital letters of surrounding text. This works well with our modern approach to SVG icons, or e.g. for custom...

You can use gem list to list all gems available from a remote gem server: gem list -r --clear-sources -s 'https://user:password@gemserver.tld/' This is useful to debug cases...

...where Bundler complains of a gem existing in more than one gem source...

Since Rails 5, domain models inherit from ApplicationRecord by default. This is the place to put code that should be available in all your application's models.