...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...

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...

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

...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...

...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.

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...

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

To do this, start your rails server using something like DISABLE_SPRING=1 strace -e trace=file -f bin/rails s The -e trace=file hides all non-file...

...calls, for example: Video Load (0.0ms) SELECT "images".* FROM "images" WHERE "image"."id" = $1 LIMIT $2 [["id", 975], ["LIMIT", 1]] [pid 264211] stat("/etc/localtime", {st_mode=S_IFREG...

...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...

...callbacks later Typical use cases for async Animations Network calls Delays (show tooltip after 100 ms, then animate) When you wait for I/O most of the time (web servers, crawlers...

...Each then() callback gets the settlement value of the previous callback: promise = Promise.resolve(1) promise = promise.then(x) { // x is now 1 return 2 } promise = promise.then(y) {

...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...

...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...

typeof x === 'string' || x instanceof String // => true Numbers Numbers can exist as literal (123) and as an object (new Number(123)), hence we cannot rely on typeof:

typeof new Number(123) // => "object" Your test should check both forms: x = 123 typeof x === 'number' || x instanceof Number // => true Functions x = function() {} typeof x === 'function' // => true

...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...

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...

Define a class and create objects: UserPreview = Struct.new(:gid, :email, :name) u = UserPreview.new(1, 'hans@peter.de', 'Hans Peter') => #<struct UserPreview gid=1, email="hans@peter.de", name="Hans Peter"> access attributes:

u.name => "Hans Peter" u['name'] => "Hans Peter" u[:name] => "Hans Peter" u[2] => "Hans Peter" u.to_a => [1, "hans@peter.de", "Hans Peter"] u.to_h => {:gid=>1, :email=>"hans@peter.de", :name=>"Hans...

Tested on Ubunut 22.04 1. Opener script Create a file ~/.local/bin/coverage_zip_opener with: #!/bin/bash tmp_folder="/tmp/coverage-report-opener" if [ -z "$1" ] then echo "Usage: coverage_zip_opener [filename]" exit -1 fi

...1" =~ ^.*Pipeline.*Coverage.*\.zip$ || "$1" =~ ^.*merged_coverage_report.*\.zip$ ]]; then file-roller "$1" exit 0 fi rm -Rf $tmp_folder unzip -qq "$1" -d $tmp_folder index_filename=$(find /tmp/coverage-report-opener...

...to 4 reduced test failures by 80% while only increasing test runtime by 10%: CPUs Test runtime Test runtime (%) Failures Failures (%) 8 308 100% 14 100% 8 304 99%

6 43% 4 343 111% 1 7% 4 346 112% 6 43% 4 333 108% 2 14% 4 340 110% 3 21% 3 378 123% 2

api.rubyonrails.org

...Load (0.7ms) SELECT "page_versions".* FROM "page_versions" WHERE "page_versions"."id" IN (1, 2, 3) Image Load (0.4ms) SELECT "images".* FROM "images" WHERE "images"."id" IN (1...

...Video Load (0.5ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" IN (1) Accessing any page.current_version.primary_medium will then happen without any extra queries. Be careful when adding conditions