229,178 questions
1
vote
1
answer
60
views
How to parse and generate week strings for HTML week elements in Ruby/Rails? [closed]
HTML has a week selector <input type="week"> which provides a string such as 2026-W05 (Week 5 of 2026).
Ruby provides the strptime/strftime methods which seem to be able to handle this ...
Best practices
0
votes
10
replies
192
views
How to minimize number of lookups in a Hash?
say you want to find the first duplicate in an array. you could do something like this:
cnt = {};
[ 11, 22, 77, 22, 33 ].each_with_index { |x,i|
j = cnt[x]; ## <1>
break [x, j, i] ...
0
votes
0
answers
44
views
Hanami db migrate
I'm following the Hanami tutorial documentation for building a web app.
I run bin/hanami db migrate and I get the following error:
=> database db/bookshelf.sqlite migrated in 0.2763s
Error: in ...
0
votes
1
answer
58
views
msgpack gem failing to install on MacOS when running `bundle install`
I'm on MacOS Tahoe (26.3.1 (a)). I have a Ruby project which requires msgpack (1.4.2).
Unfortunately, when I run bundle install, I see:
Fetching msgpack 1.4.2
Installing msgpack 1.4.2 with native ...
0
votes
1
answer
63
views
How to use existing chromium profile for ferrum?
I have setup chromium profile and wish to use that with ruby ferrum library. I copied complete configurations directory into /tmp and passed browser switched, but profile extensions seems to not work....
Tooling
0
votes
4
replies
124
views
Automating repetitive tasks with Ruby and Selenium WebDriver
I followed the advice from this question and I started to experimenting with Selenium, but I feel like it has to many limitations. Could you recommend something more suitable?
A simple program that ...
0
votes
0
answers
196
views
Convert a string to only have regular alphabet characters, from any language
I had an issue this morning where someone was blowing up our school search function (which uses a MySQL MATCH function) by typing '𝓵𝓲𝓵𝓵𝔂𝓬𝓻𝓸𝓯𝓽' into the school search. This is within the ...
-1
votes
1
answer
143
views
Regex Named Capture Group also Include Complete String
Is it possible to have a Regex include the whole string as a named capture group as well as individual named capture groups?
I am trying to parse IIS logs and can successfully extract the details I ...
Advice
0
votes
2
replies
150
views
New DataTypes For Ruby
I'm Alex. I program science I was in school and I have concepts of Datatypes which I would like to have in programming language.
Ruby is My Favorite languge (10+ years of experience), Are there any ...
3
votes
1
answer
125
views
Rails 8.0.4 app build from scratch test ("bin/rails test") gives wrong number of arguments in line_filtering.rb
I started a new rails project and generated a model with
rails new nonono --css=bootstrap -j esbuild
bin/rails g scaffold State name
After that I run the test suite
bin/rails test
And got the ...
Advice
0
votes
5
replies
142
views
Remove un-numbered lines from vscode
In VSCode i am tying to increase amount of useful information displayed. A lot of screen space is taken up by UN-numbered blank lines between the lines of code. These are not actual lines as they ...
0
votes
0
answers
81
views
Ruby Nokogiri Sax parser does not unescape & attribute
With the following code:
require 'nokogiri'
class MyDocument < Nokogiri::XML::SAX::Document
def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
a = attrs.map ...
2
votes
1
answer
122
views
Heroku ruby buildpack breaks on second deployment push
I've upgraded Ruby from Ruby 3.1.7 to Ruby 3.2.8; after that, I've encountered a situation where my ruby bundle works for the first deployment on Heroku-deployed servers, but all subsequent ...
2
votes
1
answer
153
views
Negative Unix timestamp in Ruby
I have the following Unix timestamp:
time = Time.at(-8_640_000_000_000) # => -271821-04-19 19:00:00 -0500
time.strftime('%B %-d, %Y at %-I:%M %p') # => "April 19, -271821 at 7:00 PM"
...
Advice
0
votes
6
replies
82
views
Why are things magically available in the current scope in a ruby script in Jekyll?
My question could apply to many other ruby frameworks I guess. But here I have the case while programming a Jekyll project.
Let's see this Jekyll plugin as an example:
require 'dotenv'
module Jekyll
...