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

...throw in some locking mechanism, but then are usually done with it. Unfortunately, transactions semantics in databases are actually very complicated, and chances are, your making some incorrect assumptions.

...engine actually has four different modes for transactions: READ UNCOMMITTED READ COMMITTED REPEATABLE READ SERIALIZABLE READ UNCOMMITED gives you the least isolation between transactions (i.e. one transaction can see most...

Jasmine has long standing support for writing asynchronous specs. In days gone by we used the done callback to achieve this, but these days it is possible to write much...

...more readable specs. Async specs As a first example, say we want to check that some form disables the submit button while working. // bad (how we used to do it...

A JavaScript error in an E2E test with Selenium will not cause your test to fail. This may cause you to miss errors in your frontend code. Using the BrowserConsole...

!!driver_logs_proc end def driver_logs_proc browser = page.driver.browser if browser.respond_to?(:logs) # selenium-webdriver >= 4 proc { browser.logs } elsif browser.respond_to?(:manage) && browser.manage.respond_to?(:logs) # selenium-webdriver...

Exercise 1: XML On the start page of your Movie DB, show the title of a random movie that is coming soon to theaters. There's an XML feed for...

...no longer a "Year" field when creating a movie. It is automatically fetched and stored before the movie is created. When editing a movie there is a "Year" field that...

github.com

...in C, with much better performance (20-200x) than the version in the standard library, while being almost completely compatible...

github.com

Reads Active Record's validations and makes them available to live client side javascript

tech.puredanger.com

...that pops up as it’s a thing of beauty in a piece of software that usually is seen as highly unimportant, yet is the first thing you encounter when...

...taking commercial software for a spin...

roughtype.com

...fans of progress, of technology's inexorable march forward, will change their tune as soon as progress destroys something they care deeply about...

37signals.com

...Adobe a few days before the launch of their flagship product, what hope do smaller players hold...

makandra Curriculum

If you've stumbled over display: grid while reading the Flexbox material of the previous card - we've got you covered! Let's dive into this topic with a quote...

...dimensional layouts and Grid is made for two-dimensional layouts. You will learn more subtle differences in the linked material below, but you can remember this as a rule of...

github.com

You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted...

When deploying, it posts to a Slack channel like this: How to integrate Integrating Slackistrano with Capistrano 3 is fairly simple. If you are not a Slack admin

Terser is a really good minifier ("compressor") for JavaScript code. I'm often surprised by the thoughtfulness of its compressed output. Let's take this function: function fn() {

...this to the following code: console.log(a||b?"foo":c()) Note how: The if statement has been replaced by a tertiary expression. This is often less readable, but it doesn...

...Object into Integer (TypeError) Integer(2) # 2 Integer("11", 2) # 3 This is very similar but not identical to to_i: "2".to_i # 2 "foo".to_i # 0

...an instance of Object (NoMethodError) 2.to_i # 2 "11".to_i(2) # 3 Integer() supports a exception: false variant, which is very handy to cast user input without any exception...

makandra dev

...do not use request.xhr? to decide that. Use respond_to. I've too often seen code like this: def show # ... if request.xhr? render json: @user.as_json else # renders default HTML...

...just plain wrong. Web browsers often fetch JSON via XHR, but they (should) also send the correct Accept HTTP header to tell the server the data they expect to receive...

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

By default, the mouse pointer is at location (0,0) in a Playwright suite. For newly added elements that cover (0,0), hovering events (like mouseenter) did not trigger...

This happens only when the mouse pointer was never moved and seems to be caused by the Chromium feature RenderDocument which Playwright disabled before 1.62.

apidock.com

This is somewhat similar to the touch command of Linux: FileUtils.touch 'example.txt', :mtime => Time.now - 2.hours If you omit the :mtime the modification timestamp will be set to the current time...

The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2, e.g. x86_64-linux includes binaries for 64bit Linux on Intel/AMD...

...This significantly speeds up installation of the gem, as Nokogiri no longer needs to compile libxml2. However, this also means that for each security issue with libxml2, Nokogiri maintainers have...

github.com

...is a cron replacement. It runs as a lightweight, long-running Ruby process which sits alongside your web processes (Mongrel/Thin) and your worker processes (DJ/Resque/Minion/Stalker) to schedule recurring work at...

...particular times or dates. For example, refreshing feeds on an hourly basis, or send reminder emails on a nightly basis, or generating invoices once a month on the 1st...

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

makandra dev
cpulimit.sourceforge.net

cpulimit is a simple program which attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). This is useful to control batch jobs, when...

...eat too much cpu. It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself...

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

Running rails server will start a local server that you can access via http://localhost:3000. When you are working on multiple web apps, they will likely set cookies with...

...generic names on localhost. This is annoying, since you will sign out your current user whenever you switch to another app. A better way is to use our own daho.im...