masilotti.com

Slow test suites are a major pain point in projects, often due to RSpec and FactoryBot. Although minitest and fixtures are sometimes viewed as outdated, they can greatly improve test...

We adopted a project using minitest and fixtures, and while it required some initial refactoring and establishing good practices, the faster test suite was well worth it! Stick with...

makandra dev

...or position: fixed display: inline-block display: table-cell overflow: (not "visible") and more, see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context Example: A fluid main area with a right sidebar

...you don't want either column to clear content of the other. Float the sidebar to the right and you're set: its content now renders in the sidebar's...

github.com

Phusion Passenger changed the way how it gets restarted several times. Through the project's history, these all were valid: touch tmp/restart.txt sudo passenger-config restart-app /path/to/app passenger-config...

gem 'capistrano-passenger', require: false Add to your Capfile: require 'capistrano/passenger' Declare which server role should be restarted (optional). Usually passenger tries to restart all servers with the app...

...exception, Rails will look at the exception's class and choose an appropriate HTTP status code and error page for the response. For instance, an ActiveRecord::RecordNotFound will cause Rails...

...render a red "The page you were looking for doesn't exist" with a status code of "404" (not found). The mapping from exception classes to error types is a...

Why secure-only cookies used to be necessary Cookies have an optional secure flag. It tells the browser to not send the cookie for a non-https request.

...users from http:// to https://. The reason was that most users will only enter a scheme-less domain like makandra.de into their location bar, which will default to http://makandra.de...

Understanding your type of cronjob Some cronjobs must only run on a single server. E.g. when you run nightly batch operations on the database, it should probably run on a...

...single server. Running it on multiple servers would likely result in deadlocks or corrupt data. Some cronjobs must always run on all servers. E.g. starting a sidekiq process on reboot...

The following two hints are taken from Github's Ruby style guide: If your regular expression mentions a lot of forward slashes, you can use the alternative delimiters %r(...), %r...

...complex, you can use the /x modifier to ignore whitespace and comments: regexp = %r{ start # some text \s # white space char (group) # first group (?:alt1|alt2) # some alternation end

...can reset the min-width. Say you have a simple grid layout: .container .first-item .second-item .third-item .container display: grid grid-template-columns: 100px 1fr 100px Your expectation...

...correct as the grid layout will try to do that: +---------+----------------------------+---------+ | | - 10 characters long | | +---------+----------------------------+---------+ However, if .second-item's content is too large to fit into the reserved space, it will...

CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these defaults and adjust for your project wherever necessary.

...also find suggestions on what to change below. Understanding the default configuration Here is the current default config for version 2: config.permissions = 0644 config.directory_permissions = 0755 config.storage_engines = { :file => "CarrierWave...

...issues, depending on the exact version, and depending on your app. However, it is still possible to give some generic advice on how you want to tackle the update in...

...really confident about upgrading Rails, have a look at Rails LTS. How many update steps? Besides the Rails upgrade itself, you might also want to upgrade your other gems and...

...exception of the currently running kernel, the kernel version that was installed on the system before that and, of course, the latest updated version of the kernel. However, it will...

...This could lead to unexpected removal of packages. So please check the output of sudo apt-get autoremove closely. One-shot, manual method sudo apt-get autoremove Automatically remove unused...

In a nutshell: Use git rebase --onto target-branch source-commit target-branch means "branch you want to be based on" source-commit means "commit before your first feature commit...

...Let's say my-feature-branch is based on master and we want it to be based on production. Consider this history: %%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%% gitGraph

...Doing that enables e.g. man in the middle attacks. If you accept only a single expired and known certificate, you are much less in trouble. Setup All the solutions described...

...below use a verify_callback for the request's OpenSSL::X509::Store where you can specify a lambda to adjust its verification response. Your callback must return either true or...

When you need to find out in which kind of spec you are during run-time, it's definitely possible. It's a lot easier in RSpec 2+.

...consider this global before block where you'd want to run some code for specific specs only: config.before do # stuff that_fancy_method # more stuff end RSpec 2+

keepachangelog.com

...maintain. There are some good practices for writing a changelog that adds value, please stick to these. Add a notice to the README's contribute section about the changelog

...this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased - Added `Foo#foo` method. ## 1.0.0 - 2017-06-20 ### Breaking changes - Renamed `Foo...

...uses a "real" time zone or :local, and if config.active_record.time_zone_aware_attributes is set to false or not. With time zones configured, always use .current for Time, Date, and...

...which hold time zone information and Time.now only in those that run with the server's time. If you don't, bad things can and will happen. More information can...

makandra dev

There are two ways a logout in SAML can happen: Service Provider (SP) initiated and Identity Provider (IDP) initiated logout. I'll explain how to implement both flows with devise...

...on logout and devise does not do that we get a Unsafe redirect to "https://some-idp.example.com/realms/dev/protocol/saml?SAMLRequest=fZJBb9QwEIX%2FSm45zcZx4j...", pass allow_other_host: true to redirect anyway. upon trying to logout.

w3c.github.io

Here is how to use Chromedriver without libraries like selenium-webdriver. This can be useful for debugging. The following example visits a web page and reads the a headline's...

...things you can do with it, but performing more advanced tasks without a tool like selenium-webdriver can be quite difficult. However, for simple debugging or remote-controlling, curl might...

PostgreSQL can cosplay as a full-text search engine. It doesn't have the features or fidelity of ElasticSearch or Algolia, but it's good enough if you just need...

...to search and rank large volumes of text. This card will teach you how to index, search and rank your Rails models in a PostgreSQL full-text index. We will...

...a minifier that is good enough for most cases. If you're looking to squeeze out as many bytes as possible, you can consider compressing with Terser instead.

...will increase your build times significantly, but produce the smallest output: Terser (3 pass) Terser (1 pass) esbuild application.js 163.6 kB 163.7 kB 181.6 kB application.js (gzipped)

...and autoload paths. They do NOT create a module for namespacing. This is intuitive, since there normally is no module Model, or module Controller. If you want to add a...

├── models ├── uploaders # No config needed ├── util # No config needed └── workers # No config needed Sometimes it's handy to group files within a directory, but not reflect that grouping within...

adobe.com

Flash movies (.swf files) can talk with Javascript code embedded in the same HTML page. There are two ways to do this: The preferred way is to use the ExternalInterface...

...ActionScript by calling SetVariable(name, value) on the Flash movie's DOM element. This is super-legacy, but still encountered in the field. Note that communication between a Flash movie...

makandra dev

When your application is open for public sign up and sends out transactional e-mails to a large number of users, e-mail deliverability becomes an issue. E-mail providers...

...work hard to eliminate spam and have put in place relatively tight checks what kinds of emails they will accept, and from whom. To that end we use tools like...

...with an english name. This makes you code easier to read and is also suggested by Rubocop's Style/GlobalVars cop. Example before: if 'foo' =~ /foo/ puts $~[1] # => foo end

...following content: require 'English' List of global aliases $ERROR_INFO => $! $ERROR_POSITION => $@ $FS => $; $FIELD_SEPARATOR => $; $OFS => $, $OUTPUT_FIELD_SEPARATOR => $, $RS => $/ $INPUT_RECORD_SEPARATOR => $/ $ORS => $\ $OUTPUT_RECORD_SEPARATOR => $\ $INPUT_LINE_NUMBER...