...can use find and replace with capture groups (.*?) and backreferences $1 (if you have several groups: $[Capture-Group ID]). Named captures (? .*) are also supported. Examples Replace double quotes with single...

If you want to replace double quotes with single quotes, replacing every " with a ' is prone to errors. Regular expressions can help you out here. Open find and replace...

If Sunspot does not work and fails with a backtrace similar to this: /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:227:in `adapt_response' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:164:in `execute' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:158:in `send_and_receive'

then the schema.xml that is shipped with Sunspot is not loaded into Solr correctly. Often the latter can be found in /etc/solr/conf/schema.xml. So copy Sunspot's schema.xml there...

The httpclient gem comes with a custom SSL cert store.

...customizable, application-level cert store is great when you need to deal with broken or self-signed certificates, you usually want to use the cert store from the underlying Linux...

Sometimes huge refactorings or refactoring of core concepts of your application are necessary for being able to meet new requirements or to keep your application maintainable on the long run...

...different parts. Try to make tests green for each part of your refactoring as soon as possible and only move to the next big part if your tests are fixed...

We usually ship applications that self-host webfonts to comply with GDPR. Many popular web fonts are available as NPM packages provided by Fontsource. We recommend using those instead of...

...downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a font that...

...applications can be used by multiple users at the same time. A typical application server like Passenger has multiple worker processes for a single app. In a distributed deployment setup...

...like we use at makandra you will even have multiple application servers, each with their own worker pool. This means that your code needs to deal with concurrent data access...

...translation data {...

...} can not be used with :count => 1. key 'one' is missing. They seem to appear out of the blue and the error message is more confusing than helpful...

...all models on the activerecord.attributes level (or activemodel.attributes) instead of having the same translation string in each model's attribute block: # I18n file like en.yml en: activerecord: attributes: updated_at...

DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It creates AJAX requests to persist the file within your form...

...and wraps them in a little API. This card will show you how to use it in order to create in-place file uploads with progress and a remove button...

AuthExternal pwauth Require group admin You need to first install libapache2-mod-auth-sys-group. You don't get any error message if you haven't installed it but...

...it doesn't work. sudo apt-get install libapache2-mod-auth-sys-group

...full trace reveals that ActionPack's action_controller/integration.rb is breaking while doing this: cookies = @headers['Set-Cookie'] cookies = cookies.to_s.split("\n") unless cookies.is_a?(Array) cookies.each do |cookie| name, value = cookie.match...

...happened for me. That is how my cookie looked when debugging: (rdb:1) puts headers['Set-Cookie'] remember_token=abcdef123456; path=/; expires=Mon, 31-Dec-2029 23:03:29 GMT...

There are cases when you need to select DOM elements without jQuery, such as: when jQuery is not available when your code is is extremely performance-sensitive

...an entire HTML document (which is hard to represent as a jQuery collection). To select descendants of a vanilla DOM element (i.e. not a jQuery collection), one option is to...

...t find a complete and working documentation on how to do this. But this steps succeeded (at least once). Install build dependencies $ sudo apt-get install pbuilder devscripts dpatch grep...

...sources to apt sources list (if you don't have it yet) deb-src http://security.ubuntu.com/ubuntu xenial-security main universe multiverse restricted Start the process: $ mkdir exim

stackoverflow.com

This card will show you how to use git rebase --onto without confusion. Use case You've got two feature branches (one and two), where two depends on one. Now...

...branched two from it (i.e. after code review the commits of branch one are squashed). Thus the commit history of branch one has changed. Branch two's history however didn...

SELECT pg_size_pretty(pg_database_size('some-database')); Example SELECT pg_size_pretty(pg_database_size('cards_p')); ---------------- 13 GB (1 row) SELECT pg_database_size('cards_p');

------------------ 13524832927 (1 row) Related PostgreSQL: Show size of all databases PostgreSQL: How to show table sizes

Sometimes it might be helpful to have a version history for a gem, e.g. when you want to see if there is a newer Rails 2 version of your currently...

At first you should search your gem at RubyGems. Example: will_paginate version history. The "Tags" tab at GitHub might be helpful as well...

Use this MySQL command to show further info about a table: SHOW CREATE TABLE tags; This will output a table schema like this: CREATE TABLE `tags` ( `id` int(11) NOT...

SVG files often contain redundant information, like editor metadata or hidden elements. When esbuild handles your static assets, you can easily optimize SVG files using svgo as a plugin. Here...

...is how to do it. Adding svgo as an esbuild plugin Add the svgo package to your project's package.json Adjust your esbuild.config.js like so: const esbuild = require('esbuild')

When you need the DOM node of a tag (e.g. to read extra attributes, or to modify the DOM near it), you can usually reference it via document.currentScript. However, document.currentScript is unsupported in ancient browsers, like Internet Explorer 11 or wkhtmltopdf's Webkit engine. If you are not running async scripts, you can easily polyfill it: document.scripts[document.scripts.length - 1] It works because document.scripts grows with each tag that was evaluated. That is also the reason why this solution will not work reliably for async code. Demo: https://codepen.io/foobear/pen/poRLxQm

A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs, or only when the entire test suite is run.

...JavaScript periodically requests updates from a server to keep a in sync with the latest server-site data. Sometimes the test ended right after a polling request was sent, but...

...project, as a developer you need to follow the following guidelines (e.g. by using something like this issue checklist template). In order to reduce the number of rejects we get...

...from clients, we want to review all code written before it goes to the staging server. Note This process is tailored to our specific needs and tools at makandra. While...

...of pain like me, you can get to Xfce's native window manager by saying: xfwm4 --replace

You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...

...be that the Content-Disposition header is not set. That's why the following spreewald step might raise an error: Then I should get a download with filename "..." expected: /filename...

makandra dev

...Ruby. def and define_method differ in which one they use. def Ruby keyword, starts a method definition Opens a new, isolated scope. Variables defined outside are not accessible inside...

...and vice versa. Defines an instance method on the receiver (specified before the method name, e.g. def object.foo); implicit receiver is the default definee The default definee is not self...

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