...a web developer, you know Google Analytics (GA). Probably you've dropped the GA snippet into more than one website, maybe you've even used its Javascript API to implement...

...configurable without changing anything in the application's code base (and much more beyond, see below). Only prefer GTM if the customer requests it, or if he is updating his...

DevOps Curriculum

Goals After finishing this lesson you should be able to read and write simple Ruby programs. Gain an understanding of the following concepts: Working with basic datatypes: String, Integer...

Classes and inheritance The difference between class methods and instance methods (def self.method vs. def method) Modules and include Input and output Simple regular expressions Resources Tutorials

A recent patch level Ruby update caused troubles to some of us as applications started to complain about incompatible gem versions. I'll try to explain how the faulty state...

...care of a few things: The new Ruby version is installed The Bundler version stated in the Gemfile.lock is installed Geordi is installed (for database dumps) The gems of the...

When giving a presentation where you do some coding, the font size you usually use is probably a bit too small and makes code hard to read for users on...

...smaller screens or low-bandwidth connections when the image quality is lower. Here are two solutions. Presentation Mode RubyMine offers a "Presentation Mode" which you can use. Simply navigate to...

...a new callback to your model that (e.g.) caches some data when it is saved. Now you need to run that callback for the 10000 existing records in the production...

Write a clever migration, possibly by embedding the model into the migration script. Open the Rails console after deployment and re-save every single record. You should probably...

github.com

When internationalizing your Rails app, you'll be replacing strings like 'Please enter your name' with t('.name_prompt'). You will be adding keys to your config/locales/*.yml files over...

...the right place is a challenging task. The gem i18n-tasks has you covered. See its README for a list of things it will do for you. Note

When you do a bitwise copy using the dd tool you will not see any output until it completes or an error occurs. However, you can send a command signal...

...to the process to have it show its progress so far. From another terminal, simply call (be root or use sudo): pkill -USR1 dd This makes dd write something like...

...listen to other events. Quirks The "default behavior" in this case is not to show an alert, and preventing this default means the alert is being shown. In ancient browsers...

...customize the alert text, but this is no longer possible. You might want to set event.returnValue = true, as a truthy returnValue was necessary to trigger the alert in Chrome...

api.jquery.com

jQuery's removeClass removes the given class string from an element collection. If you want to remove multiple/unknown classes matching a given pattern, you can do that. For example, consider...

...node for the following HTML. We'll reference it by $element below. Option A: Selecting classes, then removing them You can iterate over existing classes, and select matching ones. The...

Let's say you have a form that you render a few times but you would like to customize your submit section each time. You can achieve this by rendering...

...form partial as layout and passing in a block. Your template or partial then serves as the surrounding layout of the block that you pass in. You can then yield...

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

Let's say we have posts with an attribute title that is mandatory. Our example feature request is to tag these posts with a limited number of tags. The following...

...In most cases you want to use Option 4 with assignable values. The basic setup for all options looks like this: config/routes.rb Rails.application.routes.draw do root "posts#index" resources :posts, except...

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

makandra dev
web.archive.org

When testing your command line application with Aruba, you might need to stub out other binaries you don't want to be invoked by your test. Aruba Doubles is a...

Install the gem as instructed by its README, then put this Before block somewhere into features/support: Before do ArubaDoubles::Double.setup prepend_environment_variable 'PATH', ArubaDoubles::Double.bindir + ':' end

...If you are plucking from the id column in particular you can also say: User.active.ids => [1, 5, 23, 42] For a DISTINCT selection, use distinct on your scope (not the...

...resulting array). Article.distinct.pluck(:state) # SELECT DISTINCT state FROM articles => ['draft', 'published'] In Rails 3 and 4 you must use uniq instead of distinct: Article.uniq.pluck(:state) # SELECT DISTINCT state FROM articles...

...at the same time. When assets did not change, we do not want to spend time compiling them. Here is our solution for all that. Its concept should work for...

...all test suites. Copy the following to config/initializers/webpacker_compile_once.rb. It will patch Webpacker, but only for the test environment: # Avoid hardcoded asset hosts in webpack, otherwise all chunks would be loaded...

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

makandra dev

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

tl;dr: Ruby's Bundler environment is passed on to system calls, which may not be what you may want as it changes gem and binary lookup. Use Bundler.with_original...

...env to restore the environment's state before Bundler was launched. Do this whenever you want to execute shell commands inside other bundles. Example outline Consider this setup: my_project/Gemfile...

...use the puppetdb_query feature. This can result in more complex code but has several benefits: you can use more complex puppetdb queries to get the resources you want than...

...db', $vhost['parameters']['dbuser'], { 'password' => $vhost['parameters']['dbpassword'], 'type' => $type, 'extensions' => $vhost['parameters']['dbextensions'], 'schemas' => $vhost['parameters']['dbschemas'], 'charset' => $vhost['parameters']['dbencoding'], 'collate' => $vhost['parameters']['dbcollate'], 'host' => $host, }) }

...optimize the experience. Using capistrano-rails capistrano-rails is a Gem that adds Rails specifics to Capistrano, i.e. support for Bundler, assets, and migrations. While it is designed for Asset...

...Pipeline (Sprockets) assets, it can easily be configured for Webpacker. This brings these features to the Webpacker world: Automatic removal of expired assets Manifest backups # config/deploy.rb # No need to include...

github.com

The issue: You are using stub_const to change a constant value for your test. stub_const "SomeClass::CONST", 'test' All of a sudden, tests fail with undefined method 'some...

...method' for # . The reason When using stub_const before the Class containing the constant has been loaded, a module is automatically created with the name. Since RSpec does no autoloading...

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. A few things before...

...curriculum cards every other monday Read the article "Parting advice from an older Software Engineer". Try to memorize the key takeaways of 1-5 on the list. Watch Dominik's...

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