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

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

makandra dev

...is just awesome. Install via apt-get or brew. Handy commands t ("tree"): Directory-structure based access. You'll see the current directory annotated with the latest change date and...

...date and author. d ("diff"): Like ENTER on a commit, but arrow keys will scroll the diff! /: Search current view (e.g. commit list, diff). Jump to next hit with n...

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

When filling out forms in Selenium tests, Chrome shows the (usual) bubble, asking to store those credentials. While the bubble does not interfere with tests, it is annoying when debugging...

...tests. Here are two ways to disable it: Option 1: prefs You can set profile preferences to disable the password manager like so: prefs = { 'credentials_enable_service' => false, 'profile.password_manager...

makandra Curriculum

...about half of our curriculum deck! 🎉 We've covered the basics of your future stack and are about to dive deeper in some more advanced topics. One shift worth knowing...

...about now: in a few cards the agent starts writing your code, and your job becomes directing and reviewing it. That is a bigger change than it sounds, and it...

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

Sometimes you might want to check a short link for it's destination before clicking on it. Additional you get information about the redirects. Use the magic + at the end...

...of the short url! Google: https://goo.gl/TXe0Kx => https://goo.gl/TXe0Kx+ Since the original publication of this post, Google's URL shortening service goo.gl has been discontinued. Bitly:

It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your file system access is slow because it goes over the...

...or modification times, whereas your application could determine all this from your database. Introducing strace One option it to use strace for this, which logs all system calls performed by...

If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it. To get the grand-parent element, call find(:xpath, '../..'). Example

...href]).to eq("http://twitter.com/") About XPath There is a good overview on XPath syntax on w3schools. But as XPath expressions can get quite complex and hard to understand for...

makandra dev

...instead of using the UI or creating records in the Rails console. This approach saves time and gives you useful defaults and associations right out of the box.

Using rem only ever makes sense when the root font size is dynamic, i.e. you leave control to the user. Either by a) respecting their user agent defaults, or...

...by b) offering multiple root font sizes in your application. By defining @media queries in rem, they will accommodate to the root font size of your page. At a larger...

...some beyond 50MB. Unless you need to offer this large files, you should always shrink uploaded files to a reasonable resolution. class ImageUploader < CarrierWave::Uploader::Base process resize_to_limit...

relishapp.com

In most projects I know, Cucumber test suite speed is not an issue. Of course, running 350 features takes its time, but still each test for itself is reasonably fast...

...There is nothing you can do to fundamentally speed up such a test (of course, you should be using parallel_tests). However, in projects that go beyond clicking around in...

Compiling Sass is probably the slowest part of your build, so this is worth a try if you're using Sass...

...If you're using the sass npm package to compile your SASS/SCSS, consider switching to sass-embedded. It should be a drop-in replacement in a large app and it...

Sometimes you'll find yourself with a set of tasks that require similar code for different models. For example, if you start working at a new application that allows CRUDing...

...pears and apples, each commit might look similar to this: commit 41e3adef10950b324ae09e308f632bef0dee3f87 (HEAD -> ml/add-apples-12345) Author: Michael Leimstaedtner <michael.leimstaedtner@acme.com> Date: Fri Aug 11 09:42:34 2023 +0200 Add Apples...

bibwild.wordpress.com

...is much more than a lightweight wrapper around Ruby's net/http. In particular: A single HTTPClient instance can re-use persistent connections across threads in a thread-safe way.

...a custom and configurable SSL certificate store (which you probably want to disable by default) Manages cookies Can make asynchronous requests (spins off a thread internally) Allow to set a...

It's possible to implement simple custom RuboCop cops with very little code. They work exactly the same like existing rubocop cops and fail the pipeline if they find an...

...offense. This is handy for project specific internal rules or conventions. The following cop looks at every ruby file and searches for TODO or WIP comments and adds an offense...

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:

...and Redis.current=: `Redis.current=` is deprecated and will be removed in 5.0. If your application still uses Redis.current, you can only fix it by no longer using it. Here is how...

...There is probably already a constant like REDIS_URL that you use to configure Sidekiq or similar. So just use that one. redis = Redis.new(url: REDIS_URL) redis.get('example') # instead...

...automatically. If you delete records regularly, this may be an annoyance. Here is a solution which was adapted from the Carrierwave GitHub wiki and cleans up any empty parent directories...

class ExampleUploader < CarrierWave::Uploader::Base storage :file after :remove, :remove_empty_container_directory def store_dir # You implemented this in your uploaders already. end def remove_empty...

Let's say you want to find the element with the text hello in the following DOM tree: hello world You might think of XPath's contain() function: page.find(:xpath...

...contains(text(), 'hello') and not (./*[contains(text(), 'hello')])]") With jQuery jQuery has a custom selector :contains() that you can use in the same fashion: $(":contains('hello'):not(:has(:contains('hello...

...you store files for 500k records, that store_dir's parent directory will have 500k sub-directories which will cause some serious headaches when trying to navigate the file system...

...still only have 500 directories inside /app-root/public/users/avatar/. And inside each of them, at most 1000 sub-directories. But I have millions of files If you expect to store a lot...

The Web Animations API has great browser support, and you should be using it to animate DOM elements from JavaScript, or to control or wait for CSS animations.

...Its API probably a bit different from how your favorite frontend framework animates, but simple enough to get used to. Like for CSS animations, you specify keyframes to animate. This...