When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into its own matcher. RSpec makes this easy by allowing matchers...

We can extract the repeated matcher chains into a custom matcher called be_shouting: expect(foo).to be_shouting expect(bar).to be_shouting Instead of re-implementing the...

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

If you need to convert an SVG source to PS or EPS, the most common suggestion on the interwebs is to use Inkscape from the commandline. Inkscape is a fairly...

...converting is CairoSVG. CairoSVG is available on most Linux distros through their package management systems, e.g. apt install cairosvg on Ubuntu. It has few dependencies (most importantly Python 3 and...

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

Because your examples should not change global state, you should not need to care about the order in which RSpec processes your .rb files. However, in some cases you might...

...rb files in alphabetical order of their file paths by default (or when you specify --order defined). You run tests in random order by using --order random on the command...

stackoverflow.com

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?. If you don't do it...

def method_missing(method_name, *args, &block) if method_name == :bark 'woof!' else super end end end This will allow you to say: Dog.new.bark => "woof!" But: Dog.new.respond_to? :bark...

DevOps Curriculum

...und bedienen im DevOps- & Cloud-Bereich primär Kunden, die ebenfalls auf Linux als Ziel-System setzen. Entsprechend benötigen wir tiefgehendes Wissen über Linux. In diesem Kapitel lernst Du alles zum...

...Hintergrund und ein wenig Theorie zu Prozessen, Speicher, Konfiguration und viel praktisches zur Konfiguration, Ressourcenüberwachung und abschließend eine Anleitung zur Performance-Analyse von Unix-basierten Systemen in 60 Sekunden.

Why string sorting sucks in vanilla Ruby Ruby's sort method doesn't work as expected with special characters (like German umlauts): ["Schwertner", "Schöler"].sort # => ["Schwertner", "Schöler"] # you probably expected...

...Schöler", "Schwertner"] Also numbers in strings will be sorted character by character which you probably don't want: ["1", "2", "11"].sort # => ["1", "11", "2"] # you probably expected...

makandra Operations

How can I configure virtual IP's? There are two parameter to set up virtual ips in Keepalived: virtual_ipaddress Addresses defined here are included into the VRRP Packages and...

...specified interface instead of the one in `interface. Why are the floating getting dropped by systemd-networkd/netplan? Read Prevent systemd from dropping IP-Addresses configured from other processes.

When you have an Angular directive that transcludes content, you might want to do something in case there is no content inside your element, like showing some default content.

...you can not do something like default goes here . Angular will always empty that element's text, even if there is nothing to transclude. But you can use your directive...

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

You have uncommited changes (you can always check by using git status), which you want to discard. Context Now there are several options to discard these depending on...

...your exact situation. The headlines will differentiate the cases whether the files are staged or unstaged. Staged and unstaged changes Staged changes Unstaged Changes Staged and unstaged changes

...tough challenge. To get more detailed insights consider using the rack-mini-profiler gem. Setup with Unpoly Add the following gems: group :development do gem 'memory_profiler' gem 'rack-mini...

If you have slow views (Haml/Partials can be slow), consider caching them. Remove code & sql-queries that are not needed to render the page. Calling to_a blindly on...

...have 2 HTML boxes. The first one has a margin-bottom of let's say 30px and the second one a margin-top of 20px. After rules of collapsing margins...

...too. For example child elements with margins also collapse with margins of the previous sibling of the parent box. Nevertheless there are some exceptions where the behavior of vertical collapsing...

linux.die.net

...files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via e-mail). Creating a patch in git...

...changes and commit them. Run git format-patch COMMIT_REFERENCE to convert all commits since the referenced commit (not including it) into patch files. For example, let's say you...

...core and available in all ruby versions without the need to install anything. This serializes complete ruby objects including id, object_id and all internal state. Marshal.load deserializes a string...

...to an object. A deserialized object cannot be saved to database directly as the the dumped object was not marked dirty, thus rails does not see the need to save...

I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method on Enumerable that combines the three: module Enumerable

group_by(&block) .transform_values(&:count) .sort_by(&:last) .to_h end end Just paste that snippet into a Rails console and use #count_by now! Usage examples...

...to read the The framework field guide - Fundamentals, the first of a three part series to learn the basics of frontend technologies. I can highly suggest it for learning the...

...fundamentals. 'The framework field guide' is written by Unicron Utterances and there side has many high quality articles on web development and computer science related to programming. The Framework Field...

If the project you're working on has, say, 39 repositories and counting in GitLab and you need all the repos checked out for some reason, here's how to...

...a personal access token for GitLab that has the API permissions. In your terminal, store this key in an env variable. For each group you want to check out:

...pretty_print method As an example, consider the following class. class MyClass # ... def inspect "#<#{self.class} attr1: #{attr1.inspect}, attr2: #{attr2.inspect}>" end end Instances of that class will inspect like #<MyClass attr1...

...Alice", attr2: "Bob">, but IRB will apply a single color (green) for everything. That is because MyClass implements only inspect. If it were to implement pretty_print, IRB would use...

When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc. It may be a good idea to wait for all in-flight...

...AJAX requests to finish before ending a scenario: You may have client-side JavaScript that freaks out when the tab closure kills their pending requests. If that JavaScript opens an...

makandra dev

min-width is known as a CSS property that can be set to define a least width for an element. Surprisingly, it can also be used to set something that...

...it is more like "auto". This can make block elements take up much more space than desired, even stretching their container beyond the screen edge on small screens.

developer.mozilla.org

❌ Bad example Let's take a look at a common example: Clear Search The HTML above is being activated with an Unpoly compiler like this: up.compiler('[filter]', function...

...const queryInput = filterForm.querySelector('[filter--query]') function resetQuery() { queryInput.value = '' queryInput.focus() } up.on('click', resetQuery) }) The Clear search button has three issues: It cannot be focused with the keyboard It cannot be pressed...

Since I use this a lot in my daily work and there were no scripts working properly for me, I made one myself. It's actually not bound to Xfce...

...t tried it, though). Installation If you don't yet have xdotool, install it: sudo apt-get install xdotool If you don't yet have wmctrl, install it: