Ubuntu 18.04 uses systemd to manage services. There are basically two commands for listing all services and manipulating the state of a certain service: service and systemctl: service manages System...
...which system V init scripts are available and running / not running, you can use service --status-all: >service --status-all [ + ] acpid [ - ] alsa-utils [ - ] anacron [ + ] apache-htcacheclean [ - ] apache2 [ + ] apparmor [ + ] apport
The change_column method for rails migrations support casting with a custom SQL statement. This allows us to change a column type and keep the former content as the new...
...number, 'int USING CAST(rating AS int)' end end Warning This migration's rollback strategy will fail, if any existing entry can't be casted. This is likely to happen...
When your public-facing application has a longer downtime for server maintenance or long migrations, it's nice to setup a maintenance page to inform your users. When delivering the...
...maintenance page, be very careful to send the correct HTTP status code. Sending the wrong status code might get you kicked out of Google, or undo years of SEO work...
...yml files. You may override those application-wide error messages using model or attribute scope like this: en: activerecord: errors: messages: invalid: is invalid # used for any invalid attribute in...
There is a practical short list for valid/invalid example email addresses - Thanks to Florian L.! The definition for valid emails (RFC 5322) can be unhandy for some reasons, though.
...provides a built-in email regex URI::MailTo::EMAIL_REGEXP. That's the best solution to work with. /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0...
To work with other type of nodes (like text, comment or CDATA sections) you need to: Retrieve child nodes contents() (which behaves like children() except that it returns...
...element and returns an array of all child nodes that are text nodes: function selectTextNodes($container) { return $container.contents().filter(function() { return this.nodeType === 3; }); } Also check out this list of existing...
If you migrate a Rails application from Sprockets to Webpack(er), you can either transpile your CoffeeScript files to JavaScript or integrate a CoffeeScript compiler to your new process. This...
...to the global namespace, define them on window directly: -class @User +class window.User Replace Sprocket's require statement with Webpacker's import statement to load dependencies. -#= require ./person +import './person...
...PATH << File.expand_path('../../lib', __FILE__) require 'my_cli' MyCli.run! However, if you create a symlink to this file, this will no longer work. __FILE__ will resolve to the path of...
...the symlink, not to its target. One solution is to use File.realpath(__FILE__). In Ruby 2+ you can also use this: $LOAD_PATH << File.expand_path('../lib', __dir__) __dir__ is simply...
By activating strict_loading you force developers to address n+1 queries by preloading all associations used in the index view. Using an association that is not preloaded will raise...
...an ActiveRecord::StrictLoadingViolationError. I think it's a good default to activate strict_loading in your controllers' #index actions. This way, when a change introduces an n+1 query, your...
Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of three things can happen: The browser shows a "Save as...
...dialog. Since it is a modal dialog, we can no longer communicate with the browser through Selenium. The browser automatically downloads the file without prompting the user. For the test...
When using tmux, selecting and copying multiple lines of text can be a hassle, especially when using splits (highlighting lines will cross pane borders, copying contents from the other pane...
...too) and when the user wishes to copy (thus, select) lines that have already scrolled out of the viewport in the current pane. One idea would be to enable mouse...
The functions below pack your current work (diffs, full repos, or specific commits) into XML/Diff files, which are then load into your clipboard as File Uploads. My...
nvm exec 22 npx repomix@latest \ --ignore "$dyn_ignores" \ --output "$out_dir/$base_name.xml" \ --split-output "2mb" \ --quiet local files=() if compgen -G "$out_dir/$base_name*.xml" > /dev/null...
...is a checklist I use to work on issues. For this purpose I extracted several cards related to the makandra process and ported them into a check list and refined...
...main/master branch Branch off the master with geordi branch or manually Name your branch like sort-users-by-name-73624, i.e. start with the issue id, then a shortened description...
This card is just about creating simple PostgreSQL dumps. This is no instruction for a backup strategy nor a guide for SQL dump performance optimization. Read before starting
...assume that all commands will be executed as local postgres user on a database server master. Please mind that you should stop the replication on a slave PostgreSQL server before...
RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to work together. This is nicer to the eyes and much...
...more powerful than sharing code through some video chat. How to Getting started is really simple: Click the "add person" icon in the top-right editor corner (or hit Ctrl...
...Request, visit /__better_errors on your app's root path (e.g. http://localhost:3000/__better_errors). It shows the error page for the last exception that occurred, even when it has been triggered...
...Optionen können optional enthalten sein? Für was dient der User-Agent Header? Was tut der Set-Cookie Header? Was sind Cookies? Was hat es mit HTTP keepalive auf sich?
...Beyond with Socket.io WebSockets Explained Cross-Origin Resource Sharing (CORS) Content Security Policy (CSP) HTTP Strict-Transport-Security (HSTS) HTTP authentication Nginx Nginx Admin Guide Nginx docs -> Es ist empfehlenswert...
...much faster than the configured up.form.config.observeDelay. Therefore, it may happen that you already entered something into the next field before unpoly updates that field with a server response, discarding your...
The steps I wait for active ajax requests to complete (if configured) and capybara-lockstep can catch some of these cases, but not all. Both of these only wait...
...does a feature look and feel). Frequent deploy gets changes to users faster. We sleep better, because we know stuff still works. Make sure no one removes a feature by...
...to write both with "should" and "expect" You should know how to enable the old #should-syntax in RSpec 3 Understand what "Test the behavior, not the implementation" means.
...on a Rails record is converted to UTC using to_s(:db) to be stored, and converted back into the correct time zone when the record is loaded from the...
...This is now UTC Problem That will blow up in your face when you send times to attributes that expect dates, just because those times will also be converted using...
...ZIP archive, you basically have two options: Write a ZIP file to disk and send it as a download to the user. Generate a ZIP archive on the fly while...
...streaming it in chunks to the user. This card is about option 2, and it is actually fairly easy to set up. We are using this to generate ZIP archives...
...index do |person, index| person.award_trophy(index + 1) end Ruby's map with index Similarly, you may need an index when using other methods, like map, flat_map, detect (when...
...you need the index for detection), or similar. Here is an example for map: people.map.with_index do |person, index| person.at_rank(index + 1)
...old to match the format created by pg_dump. The version of the PostgreSQL server doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL...
...amd64] after deb so that it reads deb [arch=amd64] https://... or deb [arch=amd64 signed-by=.... Workaround Step 2: Connect with host option The latest PostgresQL client will only...
...create a Gemfile for installing all required gems. Gemfile # Gemfile gem 'docker-api' gem 'serverspec' Then we install them bundle install Preparation Create the directory where the Tests are going...
...to live. Add the folder to .dockerignore since we wo not want the test to be included within our final container image. mkdir spec echo spec >> .dockerignore spec/spec_helper.rb