In a nutshell: return statements inside blocks cause a method's return value to change. This is by design (and probably not even new to you, see below) -- but can...
...a problem, for example for the capture method of Rails. Consider these methods: def stuff puts 'yielding...' yield puts 'yielded.' true end We can call our stuff method with a...
If you want to see how long your database queries actually take, you need to disable MySQL's query cache. This can be done globally by logging into a database...
SET GLOBAL query_cache_type=OFF; and restart your rails server. You can also disable the cache on a per query basis by saying SELECT SQL_NO_CACHE...
...into your Webpack's assets folder or write an npm package with an own sass file that can be imported from the Webpack manifest. Load fonts from your assets folder...
...The first option turns out to be straightforward: Import the stylesheets in the index.js of the pack you're using: // webpack_source_path/application/index.js import './stylesheets/reset' import './stylesheets/main' // loads the fonts...
The closest is probably Nimbus Sans L, which is released under the GPL, AFPL, LPPL licenses. However, I couldn't find a way to convert Nimbus Sans L into a...
I finally settled with Liberation Sans, which is awesome for some reasons: Although it's available for free, it's a high quality font because its creation was...
gem install foobar --version="=2.3.0.alpha2" Also bundle update will never update a stable version to a pre-release version unless the user explicitly requests it in the Gemfile...
...gem 'foobar', '=2.3.0.alpha2' A note on Semantic Versioning Semantic Versioning has a naming convention for pre-releases that is incompatible with that from RubyGems. In Semantic Versioning, the version...
This card shows you how to format a card's content using Markdown. We use the Commonmarker interpreter, so here are examples for its dialect. Formatting **Bold** Bold _Italics_
Add a new line for a paragraph. Headlines Underline headlines with an equals sign or dash -- or start a line with a hash symbol: Hello World ----------- Lorem ipsum...
...has its weak points, but I want to point out that it has clear strengths, too. Pro Simple and beautiful interface. Outstandingly organized source code. Have never seen a JS...
...toolbar buttons, pass various callbacks, etc. Features a collection of great plugins. Easily extendable by self-made plugins. It is really simple to write one – see example below.
You can scale background images in CSS to the container size using background-size (Demo). Commonly, we use contain or cover because we want to preserve the image's aspect...
If you do not want to do that, simply provide scaling values for X and Y: background-size: 100% 100% (a simple 100% would mean 100% auto and respect...
Sometimes you may want to print files from the command line, especially when you have lots of them. You can use lp for that. To print a single example.pdf file...
...on your default printer, simply say: lp example.pdf lp accepts multiple filenames, so to print all PDF files in the current directory: lp *.pdf You can specify a printer via...
The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" The format identifier % stands for...
...this example we are using %s identifier to replace strings. class Fetcher FIND_URI = 'https://someapi.com/3/search/record?query=% s&include_many=% s&language=en-US&page=1' # some public methods
Chromedriver (or selenium-webdriver?) will not reliably scroll elements into view before clicking them, and actually not click the element because of that. We've seen this happen for elements...
...a 40px button). Our assumption is that the element is considered visible (i.e. Capybara::Selenium::ChromeNode#visible? returns true for such elements) but the Selenium driver wants to actually click...
When you are using the #selector_for helper in Cucumber steps, as e.g. Spreewald does, the following snippet will save you typing. It recognizes a prose BEM-style selector and...
...maps it to the corresponding BEM class. For a variation on this idea, see An auto-mapper for ARIA labels and BEM classes in Cucumber selectors. Examples "the main menu...
When a nginx reverse proxy complains about upstreams sending too big headers, tweaking the buffers responsibly can help to prevent this issue. Example log message: upstream sent too big header...
...while reading response header from upstream, client: 192.0.2.100, server: localhost, request: "GET /index.html HTTP/1.1", upstream: "http://198.51.100.123:80/index.html", host: "192.0.2.10:80" The cause This behaviour was caused by an application...
See the attached link for a useful overview of modern (and classic) DOM API methods, like matches, contains, append, cssText, etc. You will still need to look up some documentation...
...e.g. on how to modify a ClassList, but it's still better than browsing interfaces and superclasses of Element on MDN without knowing what to look for. When coming from...
You have an async function that rejects: async function failingFunction() { throw new Error("Something went wrong") } When you call that function in a test, your test will fail:
}) The failure message will look like this: Unhandled promise rejection: Error: Something went wrong You can fix this by expecting the state of the returned promise:
...test you can also use a handful of rake tasks to prepare the database structure directly. They can produce different results, though. In a nutshell, to ensure your test database...
...gains the correct structure: Don't use rake db:test:prepare carelessly or use rake db:test:clone_structure ← preferred :) or use rake db:migrate RAILS_ENV=test and don...
Similar to the Webpack Bundle Analyzer, Chrome's new Lighthouse feature … … shows a visualisation of your JavaScript bundles. It's compatible with sourcemaps and is great for understanding large JavaScript...
...in development. It also works on production code, where its usefulness depends on the structure of the productive Javascript code. Warning This will only work when your bundler emits source...
You can say: $(element).is(':visible') and $(element).is(':hidden') jQuery considers an element to be visible if it consumes space in the document. For most purposes, this is...
Emulate jQuery's implementation : element.offsetWidth > 0 && element.offsetHeight > 0; jQuery > 3 Query 3 slightly modifies the meaning of :visible (and therefore of :hidden). Emulate jQuery's implementation: !(window.getComputedStyle(element...
...open a dialog with the route to your dialog's view. tinymce.init({ // ... toolbar: 'myCustomButton', setup: function(editor) { editor.ui.registry.addButton('myCustom Button', { icon: 'document-properties', tooltip: 'Further describe your button here', onAction...
...insertContent', content: linkTag, }); window.parent.postMessage({ mceAction: 'insertContent', content: ' ', }) window.parent.postMessage({ mceAction: 'close' }); }) function buildLinkTag(form) { // do stuff } }) See here for more commands...
...what git checkout and git reset do. Git basics A commit holds a certain state of...
...a directory and a pointer to its antecedent commit. A commit is identified by a so-called ref looking something like 7153617ff70e716e229a823cdd205ebb13fa314d. HEAD is a pointer that is always pointing...
In CI test runs I noticed that string sorting order changed after switching from a debian-based PostgreSQL docker image to one that is based on Alpine Linux.
...sorting: bar Bar foo Foo Alpine image sorting: Bar Foo bar foo Explanation Alpine Linux is a very slim linux distribution that results in small docker image sizes (roughly 100MB...
jQuery's deferred objects behave somewhat like standard promises, but not really. One of many subtle differences is that there are two ways to chain callbacks to an async functions...
...is done, which only exists in jQuery: $.ajax('/foo').done(function(html) { console.debug("The server responded with %s", html); }); There is also then, which all promise libraries have:
...AWS elasticache is memcached) telnet foohost23.cs2631.0001.euw1.cache.amazonaws.com 11211 Once you're connected, find out which 'slabs' exist within the cache: stats items STAT items:1:number 3550 STAT items:1:age...
...STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0
Situation: You want to write a spec for a function inside an Angular service. This function at some point makes an API request and acts upon response. Notably, your Angular...
...uiRouter, although it is not used nor actually required for this test. Working test setup # Capitalized expressions are intended to be replaced with YOUR values describe 'SERVICE', -> beforeEach -> module 'MODULE...