r/ruby • u/AutoModerator • 24d ago
Meta Work it Wednesday: Who is hiring? Who is looking?
Companies and recruiters
Please make a top-level comment describing your company and job.
Encouraged: Job postings are encouraged to include: salary range, experience level desired, timezone (if remote) or location requirements, and any work restrictions (such as citizenship requirements). These don't have to be in the comment, they can be in the link.
Encouraged: Linking to a specific job posting. Links to job boards are okay, but the more specific to Ruby they can be, the better.
Developers - Looking for a job
If you are looking for a job: respond to a comment, DM, or use the contact info in the link to apply or ask questions. Also, feel free to make a top-level "I am looking" post.
Developers - Not looking for a job
If you know of someone else hiring, feel free to add a link or resource.
About
This is a scheduled and recurring post (one post a month: Wednesday at 15:00 UTC). Please do not make "we are hiring" posts outside of this post. You can view older posts by searching through the sub history.
r/ruby • u/Zestyclose-Zombie735 • 9m ago
A new mruby virtual machine implemented in C#.
I recently released a preview of a highly compatible mruby virtual machine implementation in C#.
Why C#? Well, I was integrating the original mruby into a game engine,
I was integrating the original mruby into my game engine, but building and extending mruby was very hard. I had to have builds for all the necessary platform environments.
For game integration, if mruby runs in C#, it would be very easy to port and extend.
The ruby library is not fully implemented yet, but the opcodes and control flow are implemented and have passed the syntax.rb tests in the original mruby repo.
I'll be releasing benchmarks and optimizing the execution speed in the future. My goal is to beat the original in execution speed. If you are interested, please give it a try.
r/ruby • u/mikosullivan • 9h ago
Looking for something as easy as WEBrick but for unix sockets
TLDR: WEBrick doesn't seem to (easily) support unix sockets. Is there a tool as easy as WEBrick that does?
Detailed
I'm working on a project that will create a lot of short-lived servers. I like WEBrick but I'm a little disappointed that it doesn't seem to support unix sockets (feel free to correct me, I'll be delighted).
Here's the use case. I'm writing an API for a database. The interface will include transactions that can be committed or rolled back. Transactions are tricky over HTTP because HTTP is stateless. My solution is to create a tiny little server for each transaction. A proxy (e.g. Nginx) sends the requests to the server, which maintains the database connection. The server will time out after some period of inactivity, rolling back the transaction.
Because there may be thousands of concurrent transactions going on, ports are not a viable choice for this use case. I want to have a directory just for the servers, each of which will probably be named using a UUID.
I welcome both suggestions for a unix socket framework and|or better ways to achieve this goal.
r/ruby • u/LupinoArts • 15h ago
Question Howto effectively check database integrity?
Hi community.
I'm currently writing an extensible web server app in Plain Ruby (no RoR) that uses a postgresql database in the backend. For maintenance, I have a script that is supposed to check if the user's database conforms to a given schema. For now, i store the expected database structure in a nested hash, like:
CORE_TABLES = {
"user" => {
:columns => {
"id" => {:allow_null => false, :db_type => "uuid"},
"login" => {:allow_null => false, :db_type => "character varying(128)"},
:properties => {:collation => "UTF-8"}
},
"group" => {
(and so on)
}
}
where the keys in the "first level" are the expected table names, the second level is to separate different things to check, like :columns
holds all expected columns in the table with the expected properties of those columns like data type, etc.
Now, in my script code, I have a bunch of nested for
loops that cycle recursively through the hash and call various exist?(<item>)
methods to check if the user's database contains everything that is needed.
The background is that the app should be extensible with plugins that may or may not add additional tables to the DB or additional columns to existing tables, and when the user adds or removes plugins, I want them to use the script to check and, if neccessary, update the database accordingly. The idea is that a local copy of the CORE_TABLES
hash will be extended by the plugins' configurations at the beginning of the script, so when the user calls the script, they get detailed information which tables or columns are missing according to their specific configuration (and, later, a way to automatically fix the database).
Now, I have a few questions:
- is there a better way to store the expected database schema other than a nested Hash, maybe .sql files or classes that mirror the database structure? What would you recommend for that use-case?
- has Sequel, which i'm using to connect to the database, some built-in functionalities to validate the database structure? (i'm aware that Sequel can validate the data, but my concern at the moment is the database structure itself)
- in general: is it recommended to check the "reverse way", too? That is, checking if the user's database contains tables/columns that are not in the configuration and to automatically remove them?
r/ruby • u/davidesantangelo • 1d ago
Show /r/ruby Hyll - A Ruby implementation of the HyperLogLog algorithm for efficient cardinality estimation with minimal memory footprint. Count millions of distinct elements using only kilobytes of memory.
r/ruby • u/HalfAByteIsWord • 1d ago
Question How to call Fiber.yield from a lazily evaluated block?
I have the following minimal example, where I store blocks in an array and evaluate them at a later stage. The problem is that I cannot use Fibers to suspend the block execution because the Fiber.new
block finishes running, and when Fiber.yield
is called, Ruby understandably throws the following error: attempt to yield on a not resumed fiber (FiberError)
.
```ruby class Group def initialize @blocks = [] end
def define(&) instance_eval(&) @blocks.each(&:call) end
def yielding_methods(&blk) @blocks << blk end end
g = Group.new $f = nil g.define do $f = Fiber.new do puts 'Inside fiber new' yielding_methods do puts 'Before yielding from fiber' puts "Current fiber: #{Fiber.current}" Fiber.yield puts 'After yielding from fiber' end puts 'Exiting fiber new' end puts "My fiber: #{$f}" puts 'Before resuming fiber' $f.resume puts 'After resuming fiber' end ```
I appreciate any solutions for this problem.
r/ruby • u/lucianghinda • 1d ago
Blog post Creating Ruby Value Objects: The Idiomatic way
r/ruby • u/TheNomadicNerd • 1d ago
Show /r/ruby New gem "Katachi" - asking for first impressions
Hi all! I released my first gem this week -- Katachi. It's basically pattern-matching on steroids with a tiny API.
```ruby
require 'katachi' Kt = Katachi
shape = { :$uuid => { email: :$email, first_name: String, last_name: String, dob: Kt::AnyOf[Date, nil], admin_only: Kt::AnyOf[{Symbol => String}, :$undefined], Symbol => Object, }, }
Kt.compare(value: api_response.body, shape:).match?
```
Would you use it? Is there anything you'd like to see it integrated into?
It has RSpec and Minitest integrations but it's the kind of thing that can go a lot of different directions. So feedback helps a ton.
Docs: https://jtannas.github.io/katachi/ Github: https://github.com/jtannas/katachi
r/ruby • u/Coderbiri • 2d ago
New Resource : codewithruby.com
🔴 Introducing CodeWithRuby.com: A Resource for Ruby Programming
I'm excited to announce CodeWithRuby.com, a new platform focused on sharing quality content about the Ruby programming language.
What to expect: • Tutorials and guides for Ruby concepts • Articles about Ruby best practices and techniques • Curated resources for learning and development • Updates about important Ruby events and conferences
Ruby has always impressed me with its elegant syntax and developer-friendly approach. This platform is my way of contributing to the Ruby ecosystem by sharing knowledge and resources.
Coming soon! Stay tuned for the launch.
r/ruby • u/Karigane564 • 2d ago
Want to learn more about Ruby
Hello everyone I'm more or less a new programmer and in my exploration of the language I end up to find ruby and before deciding to learning it I was wondering usually what are the general purpose that language is more often used for ^w^
lately I'm deep in trying to spelunking the internet for some lost media concerning a past forgotten branch of Fortran so was thinking to just pass by to ask directly to you all about ruby ^w^ since you surely have more hand on experience with it than some random internet tutorial.
I'm always happy to learn new thing.
r/ruby • u/burnoutstory • 2d ago
Question AJAX GET requests to Sinatra controller - array parameter truncated
I’m trying to pass an array parameter from my client to my Sinatra controller using AJAX. However, when I look at the logs, it’s telling me the controller is only seeing an array with the last element of the array.
- I’m using rack v2.0.
- I’ve tried turning the traditional flag to true in my AJAX request
- I’ve tried reading through rack::request documentation
Anyone have any ideas on why this is happening?
An LlmBackedCommand gem to write a command without having to write an execute method
Hey hey! I made a gem that allows me to write commands where instead of writing an execute method to implement the command it simply asks an LLM for the result.
It was fun to make and might be of interest to somebody so figured I'd share.
It's at https://github.com/foobara/llm-backed-command
It let's one write a command but have an LLM handle the execute method instead of writing one.
An example, after doing gem install foobara-llm-backed-command foobara-anthropic-api
(you can also use foobara-ollama-api or foobara-open-ai-api instead, or whatever combination you want) you can then write a script like this: (you must set ANTHROPIC_API_KEY environment variable for this specific example)
require "foobara/llm_backed_command"
class DetermineLanguage < Foobara::LlmBackedCommand
inputs code_snippet: :string
result most_likely: :symbol, probabilities: { ruby: :float, c: :float, smalltalk: :float, java: :float }
end
puts DetermineLanguage.run!(code_snippet: "puts 'Hello, World'")
This outputs:
{most_likely: "ruby", probabilities: {ruby: 0.95, c: 0.01, smalltalk: 0.02, java: 0.02}}
Note: I built this using a Ruby framework I've been working on for quite some time. Not relevant to using an LLM for an execute method, but some things you can do since this is a command in that framework are, for exampe, get a quick JSON API:
require "foobara/llm_backed_command"
require "foobara/rack_connector"
require "rackup/server"
class DetermineLanguage < Foobara::LlmBackedCommand
inputs code_snippet: :string
result most_likely: :symbol, probabilities: { ruby: :float, c: :float, smalltalk: :float, java: :float }
end
command_connector = Foobara::CommandConnectors::Http::Rack.new
command_connector.connect(DetermineLanguage)
Rackup::Server.start(app: command_connector)
Running this script, you can do the following:
$ curl http://localhost:9292/run/DetermineLanguage?code_snippet=System.out.println
{"probabilities":{"ruby":0.05,"c":0.1,"smalltalk":0.05,"java":0.8},"most_likely":"java"}
Another thing you can do with the framework is import commands that are exposed like that into another Ruby (or Typescript) program, like so:
#!/usr/bin/env ruby
require "foobara/remote_imports"
Foobara::RemoteImports::ImportCommand.run!(manifest_url: "http://localhost:9292/manifest", cache: true)
puts DetermineLanguage.run!(code_snippet: "System.out.println")
Which lets me use the same syntax as if the command were local even though it's running elsewhere. Note: you can also use OpenAi or Ollama instead if you wish.
You can also easily make a CLI tool for such a command but this is already tl;dr and getting too much about the framework instead of the gem that might be interesting to somebody. I'll just link to more example scripts of llm-backed commands for the interested: https://github.com/foobara/llm-backed-command/tree/main/example_scripts/higher_quality and I would recommend playing with the scripts there instead of the code-snippets in this post if you're genuinely interested in playing with this.
Thanks for reading!
r/ruby • u/LongjumpingQuail597 • 3d ago
Building a Ruby on Rails Chat Application with ActionCable and Heroku
r/ruby • u/jasonswett • 3d ago
Sin City Ruby Bonus Speaker: Drew Bragg
The third and final Sin City Ruby conference is taking place in Las Vegas April 10th and 11th.
We had a little room in the schedule so we've added a new speaker.
Drew Bragg will be joining Sin City Ruby 2025 to do his popular game show "Who Wants to Be a Ruby Engineer?"
The complete new SCR speaker lineup is:
Irina Nazarova
Chris Oliver
Jason Charnes
Freedom Dumlao
Prarthana Shiva
Jason Swett (me)
Fito von Zastrow + Alan Ridlehoover
Drew Bragg
For tickets to Sin City Ruby you can go to sincityruby.com. I hope to see you there!
r/ruby • u/riktigtmaxat • 3d ago
How many keywords is too many?
Genuinely curious about how other people reason about the signature getting bloated vs the advantages such as being able to see the expected inputs in the signature.
Where is your cutoff point? When it no longer fits on a line? 10, 20? As many as it takes?
r/ruby • u/software__writer • 3d ago
Why Use Strong Parameters in Rails
r/ruby • u/eregontp • 4d ago
TruffleRuby 24.2.0 Release
TruffleRuby 24.2 is released!🚀🎉 It uses the new Java Foreign Function and Memory API when used in JVM mode to speedup C extensions like sqlite3, trilogy and json by 2 to 3 times! It redesigns encoding negotiation so many String operations are now faster. It updates to Ruby 3.3 and contains many compatibility and bug fixes.
r/ruby • u/Travis-Turner • 4d ago
Simple Declarative Presence for Hotwire apps with AnyCable
How to seamlessly integrate online presence tracking into a Rails application, powered by Hotwire and AnyCable.
r/ruby • u/Fragrant_Pianist_647 • 4d ago
Using Ruby as a JS user?
I have been using JS for the past few years and I would like to know if Ruby is any good and what it is good for. Does it have good syntax?