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

Database connections are not thread-safe. That's why ActiveRecord uses a separate database connection for each thread. For instance, the following code uses 3 database connections: 3.times do

...a new connection end end These three connections will remain connected to the database server after the threads terminate. This only affects threads that use ActiveRecord. You can rely on...

...method to automatically compute an ETag from the given record, array of records or scope of records: class UsersController < ApplicationController def show @user = User.find(params[:id]) fresh_when @user

...by passing an array of ETaggable objects to fresh_when. class UsersController < ApplicationController def show @user = User.find(params[:id]) # The show template also renders the user's posts. fresh_when...

...table, two things happen: Rails tries to load all involved records in a huge single query spanning multiple database tables. The preloaded association list is filtered by the where condition...

...you only wanted to use the where condition to filter the containing model. The second case's behavior is mostly unexpected, because pre-loaded associations usually don't care about...

...Plotting graphs in Ruby with Gruff, which comes handy for many uses cases, you sometimes might need configuration for more advanced plots, e.g. for academic concerns. Then using Gnuplot, the...

...first academic open source plotting software, might be a good option. There are several wrappers for Ruby available and I mainly looked at one of the two most frequently used...

...command-line tool for REPL (Read Eval Print Loop). Type gem help info to see a list of available switches. Note that the Ruby API offers a bit more insight...

...Gem Ruby API (at runtime) First, get the Gem::Specification of the gem you are looking for. That object holds all the information from the gem's gemspec file, and...

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

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.

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

...an extra rendering step just for your JavaScript. An example would be: function logBoxHeight() { box.classList.add('super-big'); console.log(box.offsetHeight); // Forces the browser to re-render *now* } Verdict: Make sure you...

...always first read, then write style-relevant values. How to debug: Chrome shows warning icons in the event list in the Timeline for scripts that cause layout trashing. Performance issue...

If you want to find the commits that touched a specific text in a file, use git log -S 'text in the code' -- path/to/file If you use tig you may...

...run a similar command to get a navigatable list of affected files: tig -S'text in the code' Example Here is an example, where the move of the convert_number...

...is a gem for working with daytimes. That's a tuple of (hour, minute second) without a day, month or year. Another additional gem? Thus SQL has a time datatype...

...for storing time of day in the format hh:mm:ss, neither Ruby nor Rails themselves offer an elegant way to deal with day times. Time and DateTime both handle...

Applications often show or hide elements based on viewport dimensions, or may have components that behave differently (like mobile vs desktop navigation menus). Since you want your integration tests to...

...behave consistently, you want to set a specific size for your tests' browser windows. Using WebDriver options / Chrome device metrics For Google Chrome, the preferred way is setting "device metrics...

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

makandra dev
wiki.debian.org

This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can't open file or directory", ...) after configuration changes, e.g. when...

...in licensing, we cannot provide Elasticsearch versions >= 8.0. Version 7.17.x will reach EOL status with the release of Elasticsearch version 9. We have decided to use OpenSearch as a...

...replacement, since it is a fork of Elasticsearch version 7.10.2, still running under the previous licensing model and wire-compatible. A more detailed reasoning can be found on their website...

digitalocean.com

...to be done separatly for each node version on your system, though. Install yarn 1 system-wide via apt The yarn package depends on the nodejs debian package, but with...

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/yarn.gpg >/dev/null echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update...

...for file uploads. CarrierWave has an integrated processing mechanism for different file versions with support for ImageMagick through CarrierWave::MiniMagick (which requires the mini_magick gem). In case your processing...

...runs into an error, CarrierWave will just swallow it and rethrow an error with a very generic message like Processing failed. Maybe it is not an image? which does not...

...notice that the records you create are not deleted and will bleed into your specs the next time you run them. You probably have DatabaseCleaner configured to take care of...

...not bloating your test database with old records: RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:deletion) end config.before(:each) do DatabaseCleaner.strategy = :transaction end config.before(:each, transaction: false) do DatabaseCleaner.strategy...

...been released just a few days ago, allowing us to use Webpack 4. I successfully upgraded an existing real-world Webpack 3 application. Below are notes on everything that I...

Note that we prefer not using the Rails asset pipeline at all and serving all assets through Webpack for the sake of consistency. Preparations Remove version locks in Gemfile...

makandra dev
github.com

The shell variable PS1 holds your bash prompt. You might want to change it to serve your needs best. Here is how to: General non-printing escape sequences in your...

=> ✔ mycomputer ~/projects/platforms master > _ # Arne's epic timestamped prompt with return status indicator and status-colored (green if fresh, or red if unstaged, or yellow if staged) git branch:

...with two matchers that test for equality. The first is toBe: expect(first).toBe(second) toBe passes when first === second. Unfortunately this is useless for non-primitive values because JavaScript...

...is a horrible language. However, Jasmine comes with another matcher toEqual: expect(first).toEqual(second) This matcher behaves as a human would expect for types like the following: Arrays

...status code 400) |_http-title: 400 The plain HTTP request was sent to HTTPS port | ssl-cert: Subject: commonName=www.makandracards.com/countryName=DE | Not valid before: 2015-10-14T12...

...Not valid after: 2016-10-14T12:42:03+00:00 |_ssl-date: 2016-08-05T11:33:52+00:00; +9d23h48m18s from local time. | tls-nextprotoneg: | h2

chrisboakes.com

Debouncing a method call delays its execution until after a specified time has passed. If it's called again before that time has passed, its execution is delayed again.

...would be run more often than it needs to. One example for that are scroll event handlers in JavaScript: You want to react to a user scrolling, but it's...