...external commands from within Ruby, but the most powerful ones are Open3.capture3 and Open3.popen3. Since those can do almost everything you would possibly need in a clean way, I prefer...
...to simply always use them. Behind the scenes, Open3 actually just uses Ruby's spawn command, but gives you a much better API. Open3.capture3 Basic usage is require 'open3'
Use the click method on the DOM element: let link = document.querySelector('a') link.click()
Consider the following: describe '#something' do context 'with lots of required arguments' do it 'should work' do subject.something(:foo => 'foo', :bar => 'bar', :baz => 'baz').should == 'Hello world' end it 'should...
...is actually called. This way you can manipulate objects or other data before using the short-hand reference to your method call. Yes, it is quite similar to using variables...
...alpha channel value, you can use Gimp: Use the color picker tool Hold the Shift key while clicking the pixel A window will appear, containing color information, including the alpha...
When testing JavaScript functionality in Selenium (E2E), you may need to access a class or function inside of a evaluate_script block in one of your steps. Capybara may only...
...your tests (and neither in the dev console). The following principles/concepts also apply to Sprockets. Say we have a StreetMap class: // street_map.js class StreetMap { function getLatitude() { // ... } function renderOn(mapElement) { // ... } }
Spreewald comes with a selector_for helper that matches an English term like the user's profile into a CSS selector. This is useful for steps that refer to a...
...particular section of the page, like the following: Then I should see "Bruce" within the user's profile ^^^^^^^^^^^^^^^^^^ If you're too lazy to manually translate English to a CSS...
...case Ruby does not detected the expected encoding of a file automatically you can specify the known encoding manually. Example with File.open file = File.open('some.bin', encoding: Encoding::ASCII_8BIT)
text.encoding => # Example with File.read text = File.read('some.bin', encoding: Encoding::ASCII_8BIT) text.encoding => # More details about the encoding of strings in Ruby can be found here...
If you want to make your Rails application be capable of sending SMTP emails, check out the action mailer configuration section in the Ruby on Rails guide.
...will end up having an smtp_settings hash that looks something like this: smtp_settings = { address: ..., domain: ..., port: ..., user_name: ..., password: ..., authentication: ..., tls: ..., enable_starttls_auto: ..., } This hash can be...
Code splitting is a feature of esbuild that can keep huge libraries out of the main bundle. How code splitting works Like Webpack esbuild lets you use the await import...
...code on demand: // application.js const { fun } = await import('library.js') fun() However, esbuild's code splitting is disabled by default. The code above would simply inline (copy) library.js into application.js:
I was recently asked to optimize the response time of a notoriously slow JSON API endpoint that was backed by a Rails application. While every existing app will have different...
...be used to reproduce the results. I tried to mimic the case where things started out fast but did not scale well: There is an existing Rails App with a...
For my computer science bachelor's thesis I programmed and evaluated a CLI Test Case Prioritization (TCP) tool for makandra. It has been written as a Ruby Gem and was...
...as T2 > T3> T1 > T4 > T5 > T6. Selection of a strategy In the preselection coverage-, search-based, model- and combinations of different prioritization methods. History- and fault-based approaches could...
Luckily, this is simple. Just install three packages: sudo apt install ipheth-utils libimobiledevice-dev libimobiledevice-utils Then turn on the "Personal Hotspot" in iPhone settings, connect it to your...
...programmers dislike meetings so much is that they're on a different type of schedule from other people. Meetings cost them more...
whatsmydns.net is an online service that allows you to instantly perform a DNS lookup to check a hostnames current IP Address and other DNS information against a selection of random...
...name servers around the world. This is especially useful to check the current state of DNS propagation after making changes to your domains zones...
In a recent post, Stephan Schmidt makes several suggestions in order to write "Next Generation Java". Unfortunately, I disagree with most of them
Let's say you have a gem which has the following module: # within the imaginary super gem module SuperClient def self.foo 'Foo' end def bar 'Bar' end end
...library extensions). Try to avoid it if possible. Add a lib/ext/super_client.rb to your project (see How to organize monkey patches in Ruby on Rails projects) Add the extension, which overrides...
Get "PuTTY Link" and "Pageant" (an SSH key agent) from the PuTTY download page. Run pageant.exe, find its icon inside your system tray and add your SSH key.
...a cmd and put the full path to PuTTY's plink.exe into the GIT_SSH environment variable, e.g.: set GIT_SSH=D:\PuTTY\plink.exe You can then use Git like...
2.ordinalize # => "2nd" 1002.ordinalize # => "1002nd" 1003.ordinalize # => "1003rd" -11.ordinalize # => "-11th" -1001.ordinalize # => "-1001st...
When storing floating-point numbers such as prices or totals in an SQL database, always use a DECIMAL column. Never use FLOAT or kittens will die. DECIMAL columns are parametrized...
...with a precision and a scale. These parameters describe which numbers can be stored in that column. E.g. a decimal with a precision of 5 and a scale of...
...be answered with an empty response if the underlying content hasn't changed. This saves CPU time and reduces the bandwidth cost for a request/response exchange to about 1 KB...
...can be considered secure. Random masking of CSRF tokens was introduced to mitigate BREACH, a side-channel attack against HTTPS that was published in 2013. BREACH is pretty hard to...
I recently stumbled upon the Rails feature composed_of. One of our applications dealt with a lot of addresses and they were implemented as 7 separate columns in the DB...
...and Rails models. This seemed like a perfect use case to try out this feature. TLDR The feature is still a VERY leaky abstraction. I ran into a lot of...
Is your application doing something expensive every few seconds? Maybe an animated slider that rotates images? Maybe you are updating data over the network every five minutes? It's a...
...this if the your document tab is not even visible to the user. This saves your user's battery and data plan. You can ask document.visibilityState or document.hidden whether this...