...for gems allows to add metadata to your gem, some of which have a special meaning and are helpful for users. You can provide links to your Github bugtracker or...
...file that are then used on the rubygems page of your gem (in the sidebar, e.g. see gem page of consul). Here are some keys that should be filled:
When debugging slow SQL queries, it’s helpful to understand the database engine's query plan. Whenever you execute a declarative SQL query, the database generates a "query plan" that...
...outlines the exact steps the engine will take to execute the query. Most of the time, we don’t need to worry about this plan because SQL engines are highly...
...implementation changes. The information below is validated for the current list of browsers we support. By default your html and body elements are only as high as the actual page...
...html and body elements will only be around 40 pixels high, regardless of the size of your browser window. You might be surprised by this, since setting a background on...
Although regular expression syntax is 99% interchangeable between languages, keep this in mind: By default, the dot character (".") does not match a line feed (newline, line break, "\n") in any...
...use the /s modifier in Ruby. It changes the RegExp to interpret text as Shift JIS encoded which you probably don't want. Javascript There is no modifier to make...
...desktop users may encounter some weird quirks: Aside from allowing only digits and decimal separators, an "e" is also allowed (to allow scientific notation like "1e3"). Non-technical users will...
...be confused by this. Your server needs to understand that syntax. If it converts only digits (e.g. to_i in Ruby) you'll end up with wrong values (like...
When you need test images, instead of using services like lorempixel or placehold.it you may generate test images yourself. Here we build a simple SVG image and wrap it into...
...a data: URI. All browsers support SVG, and you can easily adjust it yourself. Simply set it as an image's src attribute. JavaScript Simple solution in modern JavaScript, e.g...
Event delegation is a pattern where a container element has a single event listener that handles events for all descendants that match a CSS selector. This pattern was popularized by...
...element was clicked!") }) This technique has some advantages: When you have many descendants, you save time by only registering a single listener. When the descendants are changed dynamically via JavaScript...
When building an application that sends e-mails to users, you want to avoid those e-mails from being classified as spam. Most obvious scoring issues will not be relevant...
...to you because you are not a spammer. However, your application must do one thing by itself: When sending HTML e-mails, you should include a plain-text body or...
Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this might be outdated since you manually have to update and...
...consistently up to date with no extra effort locally and/or remotely. How to always split by execution logs Parallel Tests The parallel_tests gem has the option flag --group-by...
...in coding lies in crafting precise prompts. The main challenge is learning how to structure prompts effectively to guide the model toward accurate results. Further evidence supporting this is the...
...that Aider already writes ~70% of its own code (as of 02/2025). However, when starting out, your results may fall short of efficiently generating large portions of your code with...
...has to decide whether and how to do authorization. The usual approaches are: Using send_file with a regular controller. This is secure, but potentially slow, especially for large collections...
...This is fast (because Apache can deliver assets without going through Rails), but less secure. When going with the "unguessable URL" approach, it is possible to somewhat increase security by...
This card is a general reminder to avoid the short version of a command option in shared code. It's much easier to understand a command and search for an...
...option when it's written out. You can still use the short version of the options in your own terminal or in code snippets that are more useful when they...
...or not to gem": Gem is really needed (prefer writing your own code for simple requirements without many edge cases) Gem is tested well (coverage and quality)
...the project requirement Try to avoid gems that do much more than your requirement scope needs Gem has a good maturity and maintenance Gem has a good / familiar DSL
...This release has many minor changes and fixes to prepare your application for Rails 3. Step-by-step upgrade instructions: Upgrade rails gem Change your environment.rb so it says RAILS...
...for a detailed list of changes. 2.3.9 to 2.3.10 Fixes Vulnerability in Nested Attributes code. Step-by-step upgrade instructions: Upgrade rails gem Change your environment.rb so it says RAILS...
...this card, we describe a wrapper for it that humanizes a given number of seconds in the "next best" unit, like seconds, minutes, etc. Example usage >> new Duration(42).humanized...
>> new Duration(123456).humanized() => '1 Tag' >> new Duration(123456).humanized('es') => '1 día' Code Here is the code as an ECMAScript module. Note that we default to German in...
...config={}). There also is a generate method which will run the generator in a subprocess. Call it with generate 'generator_name', 'command line args'. Expected (hard-coded) directory structure of...
... #{generator name, e.g. model}_generator.rb USAGE Templates If you want to use the supplied template, directory and other template methods, you must call source_root 'path/to/templates' inside your generator...
...Repeat Yourself (or DRY). In Ruby on Rails we keep our code DRY by sharing behavior by using inheritance, modules, traits or partials. When you reuse behavior you want to...
...writing integration tests with Cucumber, where you need to express yourself with Gherkin and step definitions instead of Ruby classes and methods. But don't dispair! Below you will find...
...are automagically available through accessors on the Active Record object. When you need to specialize this behavior, you may override the default accessors (using the same name as the attribute...
...and simply call the original implementation with a modified value. Example: class Poet < ApplicationRecord def name=(value) super(value.strip) end end Note that you can also avoid the original setter...
Icon fonts like Font Awesome are infinitely scalable, look great on high-DPI displays and will give your app a modern look. However, icon fonts can be very awkward to...
...use compared to raster icons. Elements are given icons by giving them a special class like icon-plus or icon-home: Create The icon font's stylesheet will then recognize...
...latest commits are not ready for production? Then use git merge master~n to skip the n-last commits. Tip A big advantage of merging vs. cherry-picking is that...
Browsers come with a set of built-in elements like or . When we need a new component not covered by that, we often build it from and tags. An alternative...
...Custom elements will be ignored for the purposes HTML validation, but their children will still be validated. Styling new elements Browsers will give unknown elements a default style of display...
...least one external REST API, machine-to-machine communication via GraphQL is less commonly seen. In this card, I'd like to give a quick intro on how to query...
Interacting with GraphQL feels a bit like querying a local database. You are submitting queries to fetch data in a given structure (like SELECT in SQL) or mutations to...
Phusion Passenger changed the way how it gets restarted several times. Through the project's history, these all were valid: touch tmp/restart.txt sudo passenger-config restart-app /path/to/app passenger-config...
gem 'capistrano-passenger', require: false Add to your Capfile: require 'capistrano/passenger' Declare which server role should be restarted (optional). Usually passenger tries to restart all servers with the app...
...exception, Rails will look at the exception's class and choose an appropriate HTTP status code and error page for the response. For instance, an ActiveRecord::RecordNotFound will cause Rails...
...render a red "The page you were looking for doesn't exist" with a status code of "404" (not found). The mapping from exception classes to error types is a...