Mads Ohm's Avatar

Mads Ohm

@ohm.codes.bsky.social

Mostly using Ruby to put 0️⃣s and 1️⃣s in the wrong order.

581 Followers  |  125 Following  |  69 Posts  |  Joined: 24.09.2023  |  2.0734

Latest posts by ohm.codes on Bluesky

I kept reading "na-noid" and was very confused about this new technology I had missed. 😅

"Nano ID" 😂

09.05.2025 13:07 — 👍 2    🔁 0    💬 1    📌 0

Ruby scales! It also transforms, rotates and other operations. 😂

08.05.2025 09:16 — 👍 1    🔁 0    💬 0    📌 0

Does a RuboCop cop already exist? Otherwise, I might be tempted to try and write it.

25.04.2025 21:04 — 👍 0    🔁 0    💬 1    📌 0
class Module - RDoc Documentation

I thought you meant that you prefer

```
def prefix
@ prefix
end

def prefix=(value)
@ prefix = value
end
```
😂

Using `attr_reader`, `attr_writer`, `attr_accessor` or even `attr` seems like a good choice! Note that some forms of `attr` are deprecated (ruby-doc.org/3.4.1/Module...)

25.04.2025 09:22 — 👍 1    🔁 0    💬 1    📌 0

$ bin/rails test

Finished in 0.000218s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

In all fairness, I did just do a `rails new`. 😅

23.04.2025 07:19 — 👍 1    🔁 0    💬 1    📌 0

Next time, I'll plan the meeting in the HOA better. 😔

05.03.2025 13:09 — 👍 2    🔁 0    💬 0    📌 0

I haven't relapsed into Magic, but Disney's Lorcana is nice too. I repeatedly "fell" on a purchase button and accidentally spent ~$1500 over a couple of months. 😅

19.02.2025 08:26 — 👍 2    🔁 0    💬 0    📌 0
Saving Ruby on Rails with my free UI kit – Nitro Kit for Ruby on Rails
YouTube video by Mikkel Malmberg Saving Ruby on Rails with my free UI kit – Nitro Kit for Ruby on Rails

Saving Ruby on Rails with my free UI Kit, Nitro Kit. The reason, a brief introduction and some hope for the future.

With a guest appearance by DHH (un-paid actor.)

On PapayaTube youtu.be/Li-RPk561l8

15.02.2025 18:57 — 👍 15    🔁 1    💬 2    📌 1

As long as you call it 17:45.

14.02.2025 07:13 — 👍 5    🔁 0    💬 1    📌 0

Adding

require "rails_helper"

I now get

Finished in 0.22914 seconds (files took 4.91 seconds to load)
1 example, 0 failures

06.02.2025 13:08 — 👍 1    🔁 0    💬 0    📌 0

We use RSpec. I've created a new file with

RSpec.describe do
it "works" do
expect(true).to eq(true)
end
end

and get

Finished in 0.00231 seconds (files took 0.1367 seconds to load)
1 example, 0 failures

06.02.2025 13:08 — 👍 1    🔁 0    💬 1    📌 0

The filepath for the JSON file wasn't updated when reorganizing the code. We would have to update that e.g. using relative paths or an absolute path from the root folder.

06.02.2025 09:54 — 👍 2    🔁 0    💬 1    📌 0

I see the same error (rand(1..5) gives a number between 1 and 5, but the grid is 0-indexed) for both x and y, which will surface in two different ways. If x = 5, you'll get a row with 6 entries, since you'll add the 5 index. If y = 5, you'll get a NoMethodError, since there's no row present at 5.

09.01.2025 19:17 — 👍 2    🔁 0    💬 1    📌 0

What's the use case? You can already call `x` and `y` as a method on your `Point` class, where `z` will raise an `NoMethodError`. So, you can use `send` (or `public_send`) with your method name.

08.01.2025 13:20 — 👍 0    🔁 0    💬 1    📌 0

Sure it can. Let’s just agree that the first working day in a new year always falls on a Monday. 🎉

03.01.2025 16:37 — 👍 4    🔁 0    💬 0    📌 1

I was a bit confused at first, since “i“ usually denotes the imaginary number (squareroot of negative 1), but yeah, the sum of the first 9 (10, if you count from 0) cubes equals 2025.

02.01.2025 21:12 — 👍 0    🔁 0    💬 0    📌 0

I saw the same numbers w/o YJIT just scaled down bit.

31.12.2024 14:34 — 👍 2    🔁 0    💬 0    📌 0

For sure they are fast. I was expecting to see a little better performance from variables, but not much in this small test. 😅 So, yeah, my mental model, too, is that Ruby methods are fast.

30.12.2024 21:49 — 👍 1    🔁 0    💬 1    📌 0
Preview
Benchmarking var vs. attr vs. def Benchmarking var vs. attr vs. def. GitHub Gist: instantly share code, notes, and snippets.

I actually thought the def-solution would be a bit slower than instance variables, since Ruby has to traverse the call tree to see where to call the method, but they seem same-ish: gist.github.com/omegahm/9bfb...

30.12.2024 21:16 — 👍 3    🔁 0    💬 1    📌 1

What’s the benefit here vs., for example, constants or attr_reader?

30.12.2024 19:37 — 👍 1    🔁 0    💬 4    📌 0

I've never thought about _not_ committing Gemfile.lock. I guess you'd need a tighter Gemfile. Do you have dependabot (or similar) set up to monitor your Gemfile and try to update the dependencies? That would give you a PR where the failure comes from, but would ultimately still fail on main.

30.12.2024 19:14 — 👍 0    🔁 0    💬 1    📌 0

I have it on my shelf as well, but haven't had the time to actually play yet. I've only heard good things about it! 😍

30.12.2024 08:39 — 👍 0    🔁 0    💬 0    📌 0

"Friend" here is a synonym for "dad". 🫠

27.12.2024 19:01 — 👍 0    🔁 0    💬 1    📌 0

Yeah, I totally agree. I even think the name is bad. "endless", of course, means "without end", so it makes sense, but to me, I read "endless" as "infinite", which these methods (hopefully) are not.

27.12.2024 18:59 — 👍 1    🔁 0    💬 0    📌 0

Do you want hints, solutions, or solitude? 😅

27.12.2024 01:53 — 👍 0    🔁 0    💬 0    📌 0
Post image

Visualization (part of) of the full adders from Day 24 of Advent of Code. I generated it with Ruby (github.com/omegahm/adve...) and copy-pasted it into dreampuf.github.io/GraphvizOnli... to render i online.

24.12.2024 12:54 — 👍 2    🔁 0    💬 0    📌 0

Why is it a _syntax_ error that you have a useless `else` without a ` rescue `? Should the interpreter even care?

21.12.2024 00:20 — 👍 0    🔁 0    💬 1    📌 0
Video thumbnail

It wasn't until I made this animation that I discovered that there's only one path through the maze for Advent of Code day 20. 😅 Dijkstra's might have been a bit overkill then.

20.12.2024 15:39 — 👍 2    🔁 0    💬 0    📌 0
Preview
GitHub - omegahm/advent-of-code: My Advent of Code answers (https://adventofcode.com/) My Advent of Code answers (https://adventofcode.com/) - omegahm/advent-of-code

My solutions are on my GitHub page: github.com/omegahm/adve...

It’s done in Ruby. Using the RMagick gem to generate individual images and then saving a bunch (in an ImageList) as a gif. Using gifsicle to optimize the gif afterwards.

18.12.2024 16:39 — 👍 4    🔁 0    💬 2    📌 0
Video thumbnail

Last possible path for Advent of Code Day 18. Those historians better run fast!

18.12.2024 09:32 — 👍 4    🔁 0    💬 1    📌 0

@ohm.codes is following 20 prominent accounts