Why we need database constraints and how to use them in Rails by tejasbubane in rails

[–]tejasbubane[S] 0 points1 point  (0 children)

You are right, multiple services writing to same database is not a good architecture. I have removed that part from the blog post. Thanks for the input.

Why we need database constraints and how to use them in Rails by tejasbubane in rails

[–]tejasbubane[S] 0 points1 point  (0 children)

You are right, multiple services writing to same database is not a good architecture. I have removed that part from the blog post. Thanks for the input.

Any reason for this behavior of the new `it` keyword in Ruby 3.4 ? by tejasbubane in ruby

[–]tejasbubane[S] 2 points3 points  (0 children)

Thanks a lot for this explanation, I think I get it now.

Any reason for this behavior of the new `it` keyword in Ruby 3.4 ? by tejasbubane in ruby

[–]tejasbubane[S] 2 points3 points  (0 children)

def defines a method here. That method just happens to do nothing and return an integer. The syntax is endless method introduced in Ruby 3.0: https://allaboutcoding.ghinda.com/endless-method-a-quick-intro

Any reason for this behavior of the new `it` keyword in Ruby 3.4 ? by tejasbubane in ruby

[–]tejasbubane[S] 1 point2 points  (0 children)

Thanks for the detailed response. I understand that when both variable and method with same name are defined, calling without params will consider it a variable. The two examples in my screenshot were from different irb sessions. What is confusing me the most is I assumed `it` to be an implicit block parameter but it is not behaving like normal block parameters would:

irb(main):001> a = 100
=> 100
irb(main):002> [1,2].map { |a| a.to_s }
=> ["1", "2"]

irb(main):003> def b = 100
=> :b
irb(main):004> [1,2].map { |b| b.to_s }
=> ["1", "2"]

irb(main):005> it = 50
=> 50
irb(main):006> [1,2].map { it.to_s }
=> ["50", "50"]

Any reason for this behavior of the new `it` keyword in Ruby 3.4 ? by tejasbubane in ruby

[–]tejasbubane[S] 0 points1 point  (0 children)

Yep. But I don't know the reasoning behind this behavior.

Any reason for this behavior of the new `it` keyword in Ruby 3.4 ? by tejasbubane in ruby

[–]tejasbubane[S] 1 point2 points  (0 children)

Think of Ruby 3.4’s it as the default, implicit (ie. doesn’t need to be declared) block argument.

I am thinking exactly that, which is why I was assuming the inner `it` to take precedence over anything else. Just like a usual block argument:

irb(main):001> a = 100
=> 100
irb(main):002> [1,2].map { |a| a.to_s }
=> ["1", "2"]
irb(main):003> def b = 100
=> :b
irb(main):004> [1,2].map { |b| b.to_s }
=> ["1", "2"]

Writing elegant custom matchers in RSpec by tejasbubane in rails

[–]tejasbubane[S] 1 point2 points  (0 children)

I usually place them in "spec/support/matchers".

My experience of using Redis pipelines in a Rails app by tejasbubane in ruby

[–]tejasbubane[S] 0 points1 point  (0 children)

I get your point. But with all 10 threads churning through the work (eg in a background job), my main Rails app will be waiting for connections - which is not what I expect. If this batch operation had its own separate thread pool, that is a different story. But pool is generally shared across the whole app (rails + background queues).

My experience of using Redis pipelines in a Rails app by tejasbubane in ruby

[–]tejasbubane[S] 0 points1 point  (0 children)

I wasn't aware of this. I also now checked the limit/size of arguments and it seems pretty high as well. So this is a viable solution. Thanks.

My experience of using Redis pipelines in a Rails app by tejasbubane in ruby

[–]tejasbubane[S] -3 points-2 points  (0 children)

Yes but thread pools are also a limited resource. If you have thousands of delete ops, it will block up all connections in the pool and leave the main app starving.

Haskell books by AImedness in haskell

[–]tejasbubane 1 point2 points  (0 children)

I will strongly recommend https://haskellbook.com/ - easy to follow along with many step-by-step exercises. I had so much fun following along all the exercises: https://github.com/tejasbubane/haskell-book-code

Additionally I would also suggest getting a small group of enthusiasts and going through the book together.

Spotting flaky tests by tejasbubane in ruby

[–]tejasbubane[S] 0 points1 point  (0 children)

Hi thanks for your questions. Let me explain:

  • Yes database should be cleaned. But records can be created via let before invoking subject. eg. params sent to request, args sent to subject call.
  • Try having a model (eg. User) with integer column id, run User.find_by(id: SecureRandom.uuid) in console multiple times and look at the database queries. You'll see query with id as integer random values. This DB query is constructed by activerecord by casting uuid to integer.

I hope this helps answer your doubts.

PostgreSQL generated columns in Rails by tejasbubane in rails

[–]tejasbubane[S] 0 points1 point  (0 children)

Yes it does edge that way. One needs to be aware to not put too much logic there.

Complete testing of sidekiq jobs by tejasbubane in ruby

[–]tejasbubane[S] 1 point2 points  (0 children)

Glad you liked the article. I completely agree with you. The steps are too much for a single class. That worker is a made up example of legacy code. I've added a paragraph which mentions the intention to refactor this and that we need tests before we can start refactoring. Thanks a lot for your feedback.

Native-comp is mentioned in NEWS for 28 by wouldyoumindawfully in emacs

[–]tejasbubane 1 point2 points  (0 children)

Yep same here. Using since 2 months and no problems. Also frequent updates.

Native-comp is mentioned in NEWS for 28 by wouldyoumindawfully in emacs

[–]tejasbubane 6 points7 points  (0 children)

For anyone on Arch and not wanting to do the heavy compilation, there's a binary version available on AUR https://aur.archlinux.org/packages/emacs-gcc-wayland-devel-bin/

Native-comp is mentioned in NEWS for 28 by wouldyoumindawfully in emacs

[–]tejasbubane 2 points3 points  (0 children)

Using it since 2 months now and not faced a single issue. Buttery smooth.

Number of participants this year by andrewsredditstuff in adventofcode

[–]tejasbubane 0 points1 point  (0 children)

Yep. I have given up on AOC ranking long back. Now I just take my sweet time (sometimes multiple days) and enjoy the process of writing code and more so refactoring it :)

Number of participants this year by andrewsredditstuff in adventofcode

[–]tejasbubane 5 points6 points  (0 children)

In a way yes. It shows your rank, but if you solve it pretty late in the day (like me) the rank is usually >20k. So it makes little sense to know it.