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

Embedding videos on a website is very easy, add a tag to your source code and it just works. Most of the time. The thing is: Both the operating...

...an 0.x version and has quite some development dependencies. It has the Apache license. streamio-ffmpeg seems to be perfect, but had its last release in 2016. It offers...

...request to save the movie. Select the request from the list and go to the sub-tab Payload. You should see your request's payload as a list of key/value...

...used the square brackets in the payload keys to group all movie attributes into one sub-hash, params['movie']. Let's take a look at only the movie-related attributes...

Matching the "space" character class For matching whitespaces in a regular expression, the most common and best-known shorthand expression is probably \s. It matches the following whitespace characters:

...in some cases these may not be good enough for your purpose. Non-breaking spaces (nbsp) Sometimes a text may contain two words separated by a space, but the author...

Any form fields where users enter numbers should be an . Numeric inputs have several benefits over : On mobile or tablet devices, number fields show a special virtual keyboard that shows...

...mostly digit buttons. Decimal values will be formatted using the user's language settings. For example, German users will see 1,23 for . Values in the JavaScript API or when...

makandra dev
gist.github.com

...cases beyond that to make your life easier. For this cheatsheat I tried to structure the most useful commands by different use cases, such that a practical oriented overview of...

...some commands I added some tips for their usage and further details on their subcommands For most of the commands shortly explained here, there are some examples along with a...

gedd.ski

...intrinsic width of your content play together. The attached article explains the differences. In summary: If a flex-basis is set, that is used as the basis

...basis is set, the width is used as the basis If neither flex-basis nor width is set, the content's computed width is used as the basis

...consider processing your images with libvips instead of ImageMagick. Reasons for libvips There are several upsides to using libvips over ImageMagick: libvips is considerably faster and uses less memory.

...has a large attack surface that has repeatedly caused security incidents in the past (compare ImageMagick CVEs with libvips CVEs). Ubuntu is sometimes slow to fix the numerous ImageMagick vulnerabilities...

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

Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common task, we should have an efficient way to do it...

...Let's say I need this HTML structure: item 1 item 2 This card compares various approaches to fabricating DOM elements for testing. Constructing individual elements While you can use...

...operators typeof and instanceof which work very differently. JavaScript has some primitive types, like string literals, that are not objects (as opposed to Ruby, where every value is an object...

...Some values are sometimes a primitive value (e.g. "foo") and sometimes an object (new String("foo")) and each form requires different checks There are three different types for null (null...

api.rubyonrails.org

...However, you need to be aware of the overall transaction nesting constellation, because creating proper sub-transactions can lead to unwanted or too early triggering of after_commit callbacks:

...project> Country.first.name # => "Afghanistan will not change" Wait. What happened to the rollback in the after_save-callback? From the Rails docs: Transaction calls can be nested. By default, this makes...

By default, Rails views escape HTML in any strings you insert. If you want to insert HTML verbatim, you need to call #html_safe. However, #html_safe does not "unescape...

...a string. It merely marks a string as safe for unescaped insertion. How html_safe works Calling html_safe on a String returns a new object that looks and acts...

TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set. Proxy caching is a good feature to serve your publicly visible application...

...server SHOULD include a Vary header field with any cacheable response that is subject to server-driven negotiation. Doing so allows a cache to properly interpret future requests on that...

...is hard coded. A popular example is extension_allowlist, which returns an array of strings and let's you only upload files that have a filename with an extension that...

...matches an entry in that array. Another useful validation can be size_range, which gives you a little bit of control over how your storage gets polluted.

thegnar.com

View specs are a powerful tool to test several rendering paths by their cases instead of using a more costing feature spec. This is especially useful because they become quite...

...used with Capybara::Node::Finders and Capybara::RSpecMatchers. This allows to wirte view unit specs as you can isolate specific parts of the rendered view and then use readable and...

makandra dev

This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques...

We will be using this example tree (from the acts_as_nested_set docs): root | +-- Child 1 | | | +-- Child 1.1 | | | +-- Child 1.2 | +-- Child 2 | +-- Child 2.1 | +-- Child 2.2

makandra Operations

on the bash (issued as postgres user) Start/Stop/Restart PostgreSQL pg_ctl -D $configdir start|stop|restart Start/Stop/Restart the corresponding PostgreSQL using the given configuration directory. The configuration directory should contain...

...the postgresql.conf file. The following example would start the PostgreSQL of our governor instances: pg_ctl -D /var/lib/postgresql/config start PostgreSQL fast shutdown pg_ctl -D $configdir stop -m fast

...update your window title whenever you switch directories, simply specify a PROMPT_COMMAND environment variable. set-window-title() { echo -en "\033]0;$(pwd | sed -e "s;^$HOME;~;")\a" } if [[ "$PROMPT...

...COMMAND" ]]; then export PROMPT_COMMAND="$PROMPT_COMMAND;set-window-title" else export PROMPT_COMMAND=set-window-title fi You may put that into your ~/.bashrc to persist and automatically activate...

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

github.com

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

makandra dev

This is a presentation from 2019-01-21. Summary We want to move away from jQuery in future projects Motivations are performance, bundle size and general trends for the web...

...can polyfill the missing pieces Unpoly 0.60.0 works with or without jQuery Is jQuery slow? From: Sven To: unpoly@googlegroups.com Subject: performance on smartphones and tablets Hello I just used your...

Slides for Henning's talk on Sep 21st 2017. Understanding sync vs. async control flow Talking to synchronous (or "blocking") API print('script start') html = get('/foo') print(html)

Script outputs 'script start', (long delay), '...

...', 'script end'. Talking to asynchronous (or "evented") API print('script start') get('foo', done: function(html) { print(html) }) print('script end')

This is an attempt to list some of those things: On the server Always optimize: Don't do stupid things with the database. Avoid "n + 1" queries. Don...

...Use form models. Optimize on demand: Don't optimize without knowing what's actually slow. Measure first, for example by using a performance monitoring tool like NewRelic, Scout, AppSignal, Skylight...