James Adam boosted

Wish Ruby had a String#each_sub method that returned each string with each matching substring replaced, individually

# => ["X1A2A3", "A1X2A3", "A1A2X3"]

Or String#all_indexes(substring) or String#all_matches(regexp) methods to find all occurrences of a substring or regexp.

James Adam boosted
James Adam boosted

Hi everyone!
It's time for a belated :)
I'm Judith, living in the south of Germany and I love photography, forests, building things (mostly on the web), and ruby.
I'm also an introvert and not used to posting on social media because I dislike all the tracking and analysis of data. But mastodon is different, so I'm hoping to find like-minded people here and good conversations about software development, linux, ruby, ...
Maybe also I'm going to post a picture or two. Let's see.

@dge355 if you send me an example server where it works, I’ll take a look. It might just be a custom emoji for those servers

James Adam boosted

So what's the state of VSCode Intellisense, but for ruby gems? Can it automatically scan the RI index of all installed gems, or do projects have to generate their own API index file for VSCode?

James Adam boosted

RT @euruko@twitter.com

We're now accepting applications for diversity/scholarship tickets! These are mostly virtual tickets but we do also have some in-person tickets available too. (1/3) 2022.euruko.org/tickets/

🐦🔗: twitter.com/euruko/status/1527

James Adam boosted

It's only fitting that Bridgetown, which is open source, have a presence on ruby.social, which uses an open sourse platform written in Ruby (Mastodon :mastodon:). Rubies all the way down! :ruby: 😁

James Adam boosted

We were still learning about the security issue for rubygems when yet another vulnerability was discovered: CVE-2022-29218


This time Maciel also got another excellent piece of Impact Analysis:


But big Mensfeld didn't stop there, he actually created a tool (a gem in the whole extent of the word) to help you figure out if your bundle was compromised:


Please boost this toot for visibility.

Show thread
James Adam boosted

I often hear that the increased hosting costs associated with Ruby on Rails' larger than average footprint is more than offset by the increased dev productivity. It follows that Rails salaries being pretty high at the moment is offset by being able to maintain a smaller, more productive team.

Does anyone know of any case studies where someone's actually done the numbers on that?

It "feels right" to me, but I'd be interested to read other's experiences.

James Adam boosted

Finally a writeup for the rubygems.org vuln, CVE-2022-29176. Such a simple mistake. I feel like the take away lessons are:

1. do not query/trust composite columns. Query individual columns.
2. do not trust arbitrary user Strings.


James Adam boosted

P.S.A: Rails have released a new version fixing some issues added on the last security release.


The new stable versions have been pushed to these

- 7.0.3
- 6.1.6
- 6.0.5
- 5.2.8

These are some of the problems I note in my review:


As usual, it's recommended to test thoughtfully on your staging environments before proceeding to deploy to production.

James Adam boosted

In a code review i suggested extracting a well named function. They replied that it does not add any value to introduce a new function. They're right in the worst way, the computer doesn't care and they don't value the readers.

Do you have suggestions on how to respond to that?

@bcgoss might a well named local variable be a good compromise?

I think you've identified the important aspect though -- they need to value the comprehensibility of code.

Perhaps you can find some other examples in your codebase where a single-call function helps make another nearby expression much easier to understand.

@jsrn client stuff is Capistrano, but all my personal projects go via Dokku

James Adam boosted

@andy_twosticks @postmodern I did consider that, e.g.

hasha.select { |k,v| hashb.has_key?(k) && hashb[k] == v }

I think they're about as nice as each other, I don't mind an incline `rescue`.

The main gotchas to avoid with `[]` are making sure you don't accidentally get a default value, but `has_key?` should avoid that 👍️

@andy_twosticks @postmodern you also probably want to avoid using `hashb[k]` in a boolean expression in case the actual value is `false` 😄

For example:

hasha = {a: true, b: false}
hashb = {b: false, c: true}
hasha.select { |k,v| hashb[k] && hashb[k] == v }
# => {}, but it should be {b: false}

Instead, I'd suggest using `fetch`:

hasha.select { |k,v| hashb.fetch(k) == v rescue false }

Show older

A Mastodon instance for Rubyists & friends