...into errors like this: I18n::InvalidPluralizationData: translation data {...

...} can not be used with :count => 1. key 'one' is missing. They seem to appear out of the blue and the error...

...the user attribute, but the user model! Now it invokes the translation with count: 1. I18n tries to pluralize the derived key (i.e. the user model, and fails. Instead of...

...for all environments by adjusting your config/database.yml: default: &default adapter: postgresql # ... variables: statement_timeout: 10s # or ms, min, etc Test that it works: ActiveRecord::Base.connection.execute("show statement_timeout;").map { |row...

=> [{"statement_timeout"=>"10s"}] begin ActiveRecord::Base.connection.execute("SELECT pg_sleep(15)") rescue ActiveRecord::QueryCanceled => e Rails.logger.error("Query was canceled: #{e.message}") end Adjust or disable the timeout for a single transaction...

makandra dev

...code, we use ESLint. The workflow is similar to integrating rubocop for Ruby code. 1. Adding the gem to an existing code base You can add the following lines to...

...varsIgnorePattern': '^_', 'argsIgnorePattern': '^_', 'caughtErrorsIgnorePattern': '^_', }], '@stylistic/arrow-spacing': ['error', { before: true, after: true }], '@stylistic/block-spacing': ['error', 'always'], '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }], '@stylistic/comma-dangle': ['error', { 'arrays': 'always-multiline', 'objects': 'always-multiline', 'imports': 'always-multiline', 'exports': 'always...

sgruendel.blogspot.com

When you install Type 1 fonts (like makandra's corporate typeface), they won't show up in OpenOffice. OpenOffice requires some additional files to process them. Stefan Gründel found out...

Using .includes or .eager_load with 1-n associations is dangerous. Always use .preload instead. Consider the following ActiveRecord query: BlogPost.eager_load( :comments :attachments, ).to_a

...post_id" = "blog_posts"."id"; Now assume there is a single blog post with 100 comments and 10 attachments. The OUTER JOINs will cause the query to return 1000 database...

y: number; } function printPoint(p: Point2D) { console.log(`(${p.x}, ${p.y})`); } const point3D = { x: 1, y: 2, z: 3 }; // has extra property z printPoint(point3D); // [LOG]: "(1, 2)" TypeScript Code...

TypeScript will actually help me catch bugs due to its static typing: printPoint({ x: 1 }); // Error: Property 'y' is missing printPoint({ x: 1, yy: 2 }); // Error: Object literal may only...

// Equivalent if/else function numberOrOne(n: number | undefined): number { if (n === undefined) return 1; else return n; } // Terse || function numberOrOne(n: number | undefined): number { return n || 1; }

...even when they are valid values. function numberOrOne(n: number | undefined): number { return n || 1; } numberOrOne(3); // 3 numberOrOne(0); // 1, but should be 0! The same trap applies to...

...the content type of a file attachment. Normally we would not expect content_type_1 to be a valid content type with the used regular expression image\/(jpeg|png). But...

...as ^ and $ will match lines, it matches both content_type_1 and content_type_2. Using \A and \z will work as expected instead and excludes content_type_1.

...PLAN ------------------------------------------------------------------------------------------------------------------------------- Seq Scan on users (cost=0.00..332518.66 rows=343223 width=422) (actual time=143.706..61621.403 rows=213865 loops=1) Filter: (search_text ~~* '%max%'::text) Rows Removed by Filter...

...true, Deforming true Timing: Generation 5.688 ms, Inlining 0.000 ms, Optimization 8.882 ms, Emission 132.362 ms, Total 146.931 ms Execution Time: 61856.303 ms (9 rows) With a GIN index

...Here is an example where this diff is helpful while comparing two hashes: {a:1}.should match(a:1, b:2) Failure/Error: {a:1}.should match(a:1, b...

...expected {:a=>1} to match {:a=>1, :b=>2} Diff: @@ -1,3 +1,2 @@ :a => 1, -:b => 2, Unfortunately, this diff is not as clever as it would need to...

...may cause the relation to select more records than expected: authorized_users = User.where(id: [1, 2]) filtered_users = User.where(id: [2, 3]) authorized_users.merge(filtered_users).to_sql # => SELECT * FROM users...

...merged relation select the users (2, 3), although we are only allowed to see (1, 2). The merged result should be (2). This card explores various workarounds to combine two...

github.com

...been included for download at the end. This card is roughly structured as follows: 1. Research approach 2. Background 3. Implementation 3.1 Usage 3.xx Implementation details 4. Evaluation

...complete project for all modified files. T1 T2 T3 T4 T5 T6 F1 0 10 5 0 2 0 F2 1 6 0 4 0 0 F3 0

...mentioned below for your deployment on request. If you're lucky DO_NOT_TRACK=1 opts you out of CLI telemetry - it's not widely adopted. When you're using...

...yarn config set --home enableTelemetry 0 Next.js https://nextjs.org/telemetry export NEXT_TELEMETRY_DISABLED=1 Prisma https://www.prisma.io/docs/orm/tools/prisma-cli#telemetry export CHECKPOINT_DISABLE=1 Angular https://angular.io/cli/analytics Note: The default...

...efficient way to do it. Let's say I need this HTML structure: item 1 item 2 This card compares various approaches to fabricating DOM elements for testing. Constructing individual...

...let list = document.createElement('ul') list.type = 'square' jasmine.fixtures.appendChild(ul) let item1 = document.createElement('li') item1.innerText = 'item 1' list.appendChild(item1) let item2 = document.createElement('li') list.appendChild(item2) For a reader it is hard to...

...like seconds, minutes, etc. Example usage >> new Duration(42).humanized() => '42 Sekunden' >> new Duration(123456).humanized() => '1 Tag' >> new Duration(123456).humanized('es') => '1 día' Code Here is the code...

...this.years = this.days / 365 } humanized(locale = 'de') { const humanizer = new Duration.Humanizer(locale) if (this.minutes < 1) { return humanizer.humanize(this.seconds, 'second') } else if (this.hours < 1) { return humanizer.humanize(this.minutes, 'minute') } else if (this.days < 1...

blog.bigbinary.com

...eager_load or includes queries. Thus, as a general guideline.includes or .eager_load with 1-n associations are dangerous. We recommend to mainly use .preload instead. ActiveRecord::Relation#joins

SELECT "users".* FROM "users" SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1) Accessing each user's posts will not produce extra queries. If all you want is...

...do ES6 classes translate to prototypes and vice versa? We will spend the first 10 minutes to cover some JavaScript basics and then dive deep into details. Level 1: Objects...

height: 20, computeArea: function() { return this.width * this.height } } shape.width // => 30 shape.height // => 20 shape.height = 100 Note how "methods" are just properties with a function value: shape.computeArea // => function() { return this.width * this.height...

ruby-lang.org

def splat_kwargs(**kwargs) # ... end def no_kwargs(*args) # ... end explicit_kwargs(x: 1, y: 2) # works explicit_kwargs({x: 1, y: 2}) # raises an ArgumentError explicit_kwargs(**{x...

...1, y: 2}) # works splat_kwargs(x: 1, y: 2) # works splat_kwargs({x: 1, y: 2}) # raises an ArgumentError splat_kwargs(**{x: 1, y: 2}) # works

moncefbelyamani.com

...you just need to know "are there any records" use any?. This uses SELECT 1 AS one FROM...

...LIMIT 1 under the hood. If you just need to know "are...

...there no records" use empty? or none?. This uses SELECT 1 AS one FROM...

...LIMIT 1 under the hood. In short: Replace foo.count > 0 with foo.any? or foo.count == 0 with...

...easily loose track of the desired example. Nesting index syntax looks like this: spec/models/user_spec.rb[1:2:1]. It describes a path in the nesting tree of the spec file, with...

...1-based indexes. Example # spec/models/user_spec.rb describe User do it 'validates presence of its email address' describe '#full_name' do it 'combines first and last name' it 'does not crash if...

makandra dev

...nslookup will be sufficient. host simple DNS lookup utility. >host heise.de heise.de has address 193.99.144.80 heise.de has IPv6 address 2a02:2e0:3fe:1001:302:: heise.de mail is handled by 10...

...domain name servers. Nslookup has two modes: interactive and non-interactive. >nslookup heise.de Server: 146.254.160.30 Address: 146.254.160.30#53 Non-authoritative answer: Name: heise.de Address: 193.99.144.80 Name: heise.de

api.rubyonrails.org

...execution failed: #{stderr}" unless status.success? if (match = pdf_info.match(/^Pages:\s*(\d+)/)) page_count = match[1].to_i blob.update!(metadata: blob.metadata.merge(page_count:)) end end blob.metadata[:page_count] end end

...execution failed: #{stderr}" unless status.success? if (match = pdf_info.match(/^Pages:\s*(\d+)/)) { page_count: match[1].to_i } else {} end end rescue StandardError => e Rails.logger.error("PdfAnalyzer failed to parse metadata: #{e.message...

...hash_including argument matcher with a nested hash: describe 'user' do let(:user) { {id: 1, name: 'Foo', thread: {id: 1, title: 'Bar'} } it do expect(user).to match( hash_including...

...id: 1, thread: {id: 1} ) ) end end The example will fail and returns a not very helpful error message: expected {:id => 1, :name => "Foo", :thread => {:id => 1, :title => "Bar"}} to...

1. Saving files to a directory that is not shared between deploys or servers If you save your uploads to a made up directory like "RAILS_ROOT/uploads", this directory goes...

...one path like "public/system/images/4.jpg" and then replacing the record ID (4) with values from 1 to 9999999999. So don't store confidential stuff in there. Non-public files should by...