makandra dev
ruby-doc.org

[ ] [ ]= ** ! ~ + - * / % + - >> << & ^ | <= < > >= <=> == === != =~ !~ && || .. ... ? : = %= { /= -= += |= &= >>= <<= *= &&= ||= **= defined? not or and if unless while until begin/end For more information see Table 18.4 in The Pragmatic Programmer's...

makandra dev
begriffs.com

The attached article explains options you have to store the order of items in a database table. The simplest solution of course is to use a position column. However the...

github.com

Leads to awesomeness and unicorns when used in production.

makandra dev

Sometimes a test is flaky if it is run in a specific order. There are many global states which all need to be reset after each scenario. Here...

...state you need to prove that it both fails and succeeds for a same order. This order is called seed in term of tests. With Cucumber you can run tests...

developer.mozilla.org

Touch devices have their own set of events like touchstart or touchmove. Because mobile browsers should also work with with...

makandra dev

A lesser known fact about PG enums is that they are ordered. This can be really handy when values have an implicit ordering. Let's imagine a record Issue(criticality...

...possible values: critical, medium, low. Sorting with Issue.all.order(criticality: :desc) will return the following order: The 'medium' issue The 'low' issue The 'critical' issue This happens because the database column...

...The function returns an array-like value with all created elements, in the same order they appear in the HTML string. Text nodes (like whitespace between elements) are also created...

...fragment.childNodes] const parsedElements = parsedNodes.filter((node) => node instanceof Element) // Traverse the new subtrees in pre-order and build an array of created elements const collectElements = (root) => [root, [...root.children].map(collectElements)]

...They will simply run at the same time. There is no guarantee of the order. When two concurrently running transactions are done, they will each try to commit their changes...

...When two threads (two database connections) try to lock the same rows in different order, you might get a deadlock. For instance, transaction A wants to change row #1 and...

...list of records that is somehow limited via a .limit clause, make sure your order is deterministic, otherwise you'll receive different records in different runs. For example:

...bigint, ends_on: Date) User.order(:ends_on).limit(5) # Bad, because the order is not deterministic if a lot of users end on the same date User.order(:ends_on, :id...

In Rails, the implicit_order_column (added in Rails 6) is a configuration option that helps you define the default sorting behavior of ActiveRecord queries when no explicit ORDER BY...

...specify a column that Rails will use to automatically sort records in a particular order when no specific ordering is given. Since the id is typically the primary key and...

jakearchibald.com

...you think. This can be the reason why callbacks are not executed in the order that they are queued. Please read this article! This is an extract of the example...

...in the article which demonstrates the execution order of tasks and microtasks. console.log('script start'); setTimeout(function() { console.log('setTimeout'); }, 0); Promise.resolve().then(function() { console.log('promise1'); }).then(function() { console.log('promise2'); });

...User.where_array_matches(:movie_ids, [1, 2, 3])).to include(matching_user) end it 'is order-independent' do expect(User.where_array_matches(:movie_ids, [2, 1, 3])).to include(matching...

...User.all.where_array_matches!(:movie_ids, [1, 2, 3])).to include(matching_user) end it 'is order-independent' do expect(User.all.where_array_matches!(:movie_ids, [2, 1, 3])).to include(matching...

api.rubyonrails.org

For example, the following raises an error. Page.includes(:current_version => :primary_medium).order('page_versions.updated_at').to_a # => ActiveRecord::EagerLoadPolymorphicError: Cannot eagerly load the polymorphic association :primary_medium

...Rails will automatically JOIN your includes so that your order or where statements work as expected. This is exactly why it can no longer eager-load the polymorphic association.

...tsquery('simple', :query) SQL end This implementation only finds matching records, without a particular order. We will learn how to rank results later. The string 'simple' denotes the PostgreSQL dictionary...

...match somewhere Message.search('"foo bar"') The phrase foo bar must match in that exact order Message.search('foo -bar') foo must match, but bar must not Searching in multiple columns

geekytidbits.com

...have a query where you want only one record for a set of specifically ordered attributes. How to use? Let's say we look at the example how to query...

...the latest post for each user: SELECT DISTINCT ON (user_id) posts.* FROM posts ORDER BY user_id, published_at DESC; In Ruby and ActiveRecord it is just: Post.select('DISTINCT...

...vendors will apply standard rounding here. Some vendors always round down item totals in order to demonstrate exceptionally good business practices to their clients. When calculating the amount of VAT...

...for destruction. Best practice example Here we will use what we learned above in order to create a correct invoice implementation. We require one table to store invoices, and another...

github.com

...to granted high priority within the calculated prioritization. Test Case Prioritization The testsuite is ordered in a such a way that tests with higher priority are placed before tests with...

...have coverage for a modified line of code. Now the detected specs can be ordered by different strategies. The most common strategies to achieve this are total and additional coverage...

Code splitting is a feature of esbuild that can keep huge libraries out of the main bundle. How code splitting...

makandra dev

...concrete RObject then points to this singleton class instead of the class directly. In order to not lose the chain, the superclass (super) of the singleton class points to the...

...to mention that class_eval may also be used equivalently to instance_eval in order to define singleton/class methods: class User end User.class_eval do def self.shout! "Hey!" end

postgresql.org

...PostgreSQL docs): WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales > (SELECT...

product, SUM(quantity) AS product_units, SUM(amount) AS product_sales FROM orders WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product;

...in that category: class NotesController < ApplicationController def category @notes = Note.scoped(:conditions => { :category => params[:category] }, :order => 'created_at DESC') end end So far, the code is fine. We will now introduce...

...Note#author association: class NotesController < ApplicationController def category @notes = Note.scoped(:conditions => { :category => params[:category] }, :order => 'created_at DESC', :include => :author) end end This controller action works until someone calls the...

...the HTML source. You can use CSS (e.g. flex-direction) to change the visual order without changing the order in the HTML markup...

makandra dev

...a dark background etc.) is accessible. See Barrierefreie Webseiten. It navigates through elements in order (or in an order that makes sense). You can test that by clicking into the...

...query = User.order(:last_name, :created_at).to_sql puts query # => SELECT "users".* FROM "users" ORDER BY "users"."last_name" ASC, "users"."created_at" ASC 2. Add an index in your...