Somewhat regularly, you will need to filter a list down to some items and then map them to another value. You can of course chain map and compact, or select/filter...
...if i.even? }.compact => [4, 8, 12] or >> [1, 2, 3, 4, 5, 6].select(&:even?).map { |i| i * 2 } => [4, 8, 12] you can just do...
...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.
Native promises have no methods to inspect their state. You can use the promiseState function below to check whether a promise is fulfilled, rejected or still pending: promiseState(promise, function...
// `state` now either "pending", "fulfilled" or "rejected" }); Note that the callback passed to promiseState will be called asynchronously in the next microtask. Usage example: Tests Note Since this card...
When you have string contents (e.g. a generated binary stream, or data from a remote source) that you want to store as a file using Carrierwave, here is a simple...
While you could write your string to a file and pass that file to Carrierwave, why even bother? You already have your string (or stream). However, a plain StringIO...
...Before merging back: reinstate reverted features in a temporary branch, then merge that branch. Scenario Consider your team has been working on several features in a branch, made many changes...
...fix them, if necessary. Maybe tests were added that expect the removed functionality as a side-effect. Merge the master into your branch regularly, especially when you have multiple teams...
tl;dr When browsers start to adapt proposals from Open UI, it might not be necessary to use any 3rd party libraries to have nice components and controls in web...
...applications e.g. selects. It would require only a minimum of CSS and Javascript to get them working and looking good. The purpose of the Open UI, a W3C Community Group...
Sometimes the need arises for SSL in local development. We have guides for different webservers, this one is for puma. make sure mkcert is installed create an SSL certificate for...
...bundle exec rails s Accept the certificate in your browser See also Creating a self-signed certificate for local HTTPS development
...to run JS tests. Given a Vue project that uses Jest (via vue-cli-service) with the following package.json: { "scripts": { "test": "vue-cli-service test:unit --testMatch='**/tests/**/*.test.js' --watch...
...allows us to run Jest tests with yarn test. The only downside of this setup is that debugger statements are ignored with the CLI approach - there are no Browser Devtools...
Starting Terminator with split screens is quite simple: Just store a layout and start Terminator with the --layout option. However, if you want to run custom commands in your terminals...
...command exits. You accomplish this by tweaking bash to run a command before actually starting. Pimp your .bashrc Add this to the end of .bashrc: # hack to keep a bash...
Git log offers useful options for filtering. This card provides a short overview. By message Only commits that include a specific string in their commit message git log --grep="tracker...
By file Only commits that introduced changes to a specific file git log -- foo.rb bar.rb Note In case the file was renamed or moved the --follow option can be...
...type of network card is used for a given network interface on a linux system, e.g. because the system has multiple network cards, try and match the driver to the...
...interface name: $ ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback...
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...
This is for people recovering from Subversion. Get an existing from the server for the first time git clone git@example.com:repositoryname See what's changed git status Check in locally...
...git commit -m "good description" Push local commits to the server git push Get and merge updates from the server git pull Stage a file for the next local commit...
...git rebase -i main. What it does: Opens an interactive rebase UI to choose squash/edit/fixup for each commit of your branch until the first commit (the base). Keeps your branch...
...s base intact (no rebasing onto main). Lets you squash, reorder, edit, or drop commits. Info This is not the same as git rebase -i main, which would rebase your...
...multiple custom ways to format Dates or DateTimes. This often leads to duplicated format strings, wrong formats and unnecessary introduction of new formats. to_fs also supports to refer to...
...those formats by name e.g. to_formatted_s(:iso_8601) or to_formatted_s(:short). to_fs is an alias for to_formatted_s. Those names are defined in Time...
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...
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...
...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...
JavaScript objects can have getter and setter functions that are called when a property is read from or written to. For example, if you'd like an object that has...
...person.firstName and person.lastName: var person = { firstName: 'Guybrush', lastName: 'Threepwood', get fullName() { return this.firstName + " " + this.lastName; }, set fullName(name) { var parts = name.split(" "); this.firstName = parts[0]; this.lastName = parts[1]; } }; The code below shows...
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...
...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...
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": {
...a RubyMine plugin that enables you to review and process merge requests within RubyMine! Setup Open RubyMine settings (Ctrl + Alt + S) > Plugins > Search for "GitLab" > Install (You might need to...
...re-open settings afterwards.) In the RubyMine settings > Version Control > GitLab > Connect your GitLab account with "+" Working with merge requests From the Actions menu (Ctrl + Shift + A), choose "View merge...
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...