We structure our CSS using the BEM pattern. Our naming convention for blocks, elements and modifiers has evolved over the years. This card shows our current style and various alternative...
...styles that you might encounter in older projects. The difference between the various styles are mostly a matter of taste and optics. I do recommend to not mix styles and...
...function can be a new instance method of all arrays (by patching Array.prototype) or a stand-alone function that takes an array argument. Write a JavaScript function mySelect that works...
...function can be a new instance method of all arrays (by patching Array.prototype) or a stand-alone function that takes an array argument. Did you learn how this works?
...the test, as if the callback function is not executed in the test. However, since the test does not fail, the method :my_method must have been called during the...
...where the method :my_method should be called This will execute the original implementation (see here...
...investigate by running that example again using rspec . However, this does not work with shared examples, since Rspec doesn't know in which context the shared example should be run...
...But there is a different way: You can run the shared example using the -e, --example option. It takes a string value and runs all scenarios containing that substring in...
...write complex migrations in Rails Discuss with your mentor Instead of migrations, could we simply log into the production server's SQL console and alter tables there whenever we need...
...Actor#total_movies: This field should cache the total number of movies an actor stars in Actor#first_movie_id: This field should cache the first movie to which the...
...ae]y => grey or gray => but NOT graay or graey [0-9] matches a SINGLE digit in the range from 0 to 9 [0-9a-fA-F] hexadecimal digit...
...with caution. Mostly you'll want to use it for small expressions, e.g. for nested sub-regexes. For more details have a look at the card on quantifier modes.
If you're using a Redis cache in Rails (e.g. :redis_cache_store), it's possible to configure additional parameters for your Redis connection. Example config for Rails 7.2
...store = :redis_cache_store, { pool: { timeout: 0.5 }, read_timeout: 0.2, # default 1 second write_timeout: 0.2, # default 1 second # Attempt two reconnects with some wait time in between reconnect_attempts...
Option 1: Creating a self-signed certificate with the openssl binary As igalic commented on this gist. openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key...
make it an X.509 certificate, not a Certificate Signing Request. Option 2: Creating a self-signed certificate with the mkcert binary The linked tool mkcert helps you to setup...
...offset, e.g. Thu, 28 Mar 2019 16:00:00 CET +01:00. Ruby's stdlib TZInfo also has time zones, but with different identifiers. Unfortunately, not all timezone codes can...
...time zone has a pretty abbreviation. In such cases, you'll end up with a semi-broken offset identifier that humans won't understand. What to do?
...universe multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu yakkety-security...
10 http://de.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 Packages 10 http://security.ubuntu.com/ubuntu yakkety-security/main amd64 Packages 2:7.4.1829-1ubuntu2 10 10 http://de.archive.ubuntu.com/ubuntu yakkety/main...
...are usually believed to have worse performance than those defined via def. Hence, developers sometimes prefer using class_eval to define methods using def, like this: class_eval "def #{attribute...
...for_realsies?; do_things; end" You can benchmark methods defined like this and will see that those defined via def actually do perform better. Basically, it ranks like this:
Git is our version control system. Goals Understand why we use git. Learn how to work with your local repository: Create a local repository (git init) Commit changes (git add...
See the history (git log) See changes (git diff) Work with branches Create new ones: git switch --create or git checkout -b. Switch to existing branches: git switch...
When you need to add a event listener to hundreds of elements, this might slow down the browser. An alternative is to register an event listener at the root of...
...for events to bubble up and check whether the triggering element (event.target) matches the selector before you run your callback. This technique is called event delegation. Performance considerations
Ctrl + Alt + S > search "rubocop on save" Under "Inspections", check the highlighted box on rubocop -a Caveat: This adds a little time overhead to saving. When you're editing many...
...really want to get their arguments processable as keyword arguments. Don't change the syntax, or you'll experience pain. Always call super inside of your overridden #initialize method. A...
...things happen in the ActiveRecord world. Just let them happen, otherwise kittens will die somewhere. You don't want that. Example class Item < ActiveType::Object def initialize(attributes) super
If the project team consists of at least 2 members, do a daily standup. It should not take much longer than 15 minutes. Format Tell everyone else
if there are new developments everyone needs to know about A "still working on X, will probably be done today" is totally fine. No need to tell...
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...
Version 3.7.0 broke some things in complex forms. Sorry for that. Concurrent user input is hard. 3.7.1 This change fixes two regressions for form field watchers, introduced by 3.7.0:
...a validation for a fragment while a validation request for the same target is still loading. Validations no longer throw an error if a targeted fragment is destroyed while a...
...window manager that provides neat features like automatic layouting of windows, good multi-display support with per display workspaces and more. Since it is only a window manager, you will...
...menus, automatic updates etc. Fortunately, you can run Awesome within MATE, by following these steps (tested on Ubuntu MATE 16.04): Awesome + MATE Create the following file at /usr/share/xsessions/Xsession.desktop: [Desktop Entry...
...with additional margin towards their container. Starting with version 121, Chrome now also supports the spec-compliant properties scrollbar-width and scrollbar-color. These allow less styling. You may only...
...track and thumb colors, and a non-specific width like auto, thin, or none. .example { scrollbar-width: thin; scrollbar-color: blue lightblue; } Styling the -webkit-scrollbar-* pseudo elements is still...
In order to have monitoring for Sidekiq (like queue sizes, last run of Sidekiq) your application should have a monitoring route which returns a json looking like this: { "sidekiq": {
...queue_sizes": { "dead": 0, "retries": 0, "monitoring": 0, "low_priority": 0, "mails": 0, "default": 0, "elasticsearch": 0, "high_priority": 0, "file_upload": 0, "scheduled": 0 }, "active_workers": 0 }, "timestamps": {
First we export the checks on the nodes we want to monitor: @@nagios_service { “check_unicorns-${::hostname}”: host_name => $::hostname, service_description => ‘Unicorn Status’, check_command => ‘check_unicorn-${::hostname...
...Then we realize the resources on the Nagios server Nagios_service <<| |>> Now it is quite easy to create new monitoring checks with Puppet. With the ease of creating monitoring checks...
...or every even-numbered item. However, :nth-child can do more. In modern CSS specifications (Level 4), there’s an additional feature that lets you use :nth-child in combination...
...with a list of css selectors. This way, you can target the nth-child within a subset of siblings matching a selector. For example: .container .foo %span.my-selector .bar
...bodies with a maximum of 4096 characters. You can work around that limit by splitting the text into smaller fragments and stitch together the resulting mp3 files with a CLI...
...tool like mp3wrap or ffmpeg. Example Ruby Implementation Usage input_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...