Ruby's Hash is a Swiss-Army Knife
TL;DR: Ruby has a single Hash class to manage key-value pairs. It's a very flexible data structure. It can act as a data object, a dictionary, a hash table, a sorted list, and much more. Like almost everything in Ruby, it's a sharp knife that you can use to cut yourself, but can also use to cook great food; I mean, write good programs.
Ever wanted to modify an ENV variable, an instance or class variable for the duration of a block or all tests of a group? This pattern emerged repeatedly in my suites and as I don’t like to bloat my spec helper, about time for the lightweight and dependency-free minitest-substitute gem. Drop cumbersome before and after handling with one or more easy to read `with "ENV['FOO']", "bar"` or `with "@run_at", on: Config { Time.now }` declarations. Happy testing! https://github.com/svoop/minitest-substitute #ruby #minitest
Django has auth/perms/roles builtin, works great. Laravel has auth/perms/roles built-in and is fabulous. Spring Boot, Catalyst, similar deals.
Rails has nothing built-in, so a lot of us end up using a 3rd-party POS called Devise that is broken for months at a time blocking other important gem dependency updates. And don't even get me started on those fugly ERB templates.
Is there still nothing better? I DuckDuckGo'd but kept ending up on Devise 😩
What is the ideal design for a REST API client that you would prefer to follow for your new API clients?
Please select or suggest from the list the closest!
#ruby #crystal #api #helpwanted
I just released v1.3.7 of the Jekyll theme called SpaacedOut. Check out the details at https://jasong.us/3sE4dQU.
#jekyll #jekylltheme #cms #css #dev #webtheme #webthemes #spaacedout #ruby #gem
#jekyll #jekylltheme #cms #css #dev #webtheme #webthemes #spaacedout #ruby #gem
Just a General FYI for #Ruby users of #Mongoid
I believe there is a bug in Mongoid 4.15 that breaks expectations of querying has_and_belongs_to_many relationships. Ticket here:
Bomb mechanics and enemies in a metroidvania I'm working on. Made with DragonRuby Game Toolkit. https://youtu.be/J7hXDCxc_W0
Well, managed to fix one issue by dealing with a horrible anti-pattern with refinements.
Unfortunately, I've got another scoping problem that I can't quite tease apart, nor can I diagnose it, since the default #ruby gem "did_you_mean" is causing segmentation faults when I try to trace the error! Isn't that fun.
I’ve become a co-maintainer of https://rubyconferences.org.
My first order of business was to link out to this awesome iCal feed. #ruby #conferences
Here’s my open source status update for August, in which we get a couple of chonker PRs merged, setting us up for our downhill run towards finishing assets support, also now tracked in a handy dandy GitHub proejct.
https://timriley.info/writing/2023/09/10/open-source-status-update-august-2023/
Ok, I'm going to stop with the screenshots for a while now (sorry for the bombardment), but just quite pleased with this:
All the application code showcased in this picture is pure #Ruby other than Xorg and the window manager (hmpff...).
* The terminal
* The shell (by Geir Isene)
* The desktop / file manager
* The text editor...
Including:
* The font renderer
* The X11 client code.
The terminal and shell are not 100% my daily drivers yet - they need a few more fixes first, but close.
Okay, it's now officially my new file manager. It has next to *no* functionality. No scrollbars yet, no dragging files, no actions other than clicking on them, but it opens folders and opens (some) stuff based on mime type. It's "enough" for my very limited use.
I really need to commit these #ruby X11 bindings and this code as well soon.
Does this officially make me a proper #ruby zealot?
(No, it's not functional yet; yes it is a pure Ruby program rendering my desktop icons via the raw X protocol, and using the pure-Ruby ChunkyPNG to load the icons)
I'm curious what is the most elegant way in Ruby to create a scale of Symbol values (high, medium, low, etc) such that you can compare Symbols and filter objects that have a value less than a specific value on the scale?
The least elegant way is to map the Symbols to Integer values and filter/select based on:
SCALE = {low: 0, medium: 1, high: 2, ...}
objs.select do |obj|
SCALE[obj.severity] < SCALE[:high]
end
Testing double-width and double-height support in my Ruby terminal (left), xterm (middle), and st (right).
My support isn't *correct* yet - if you just use the escapes for one half the clipping is broken, but still - most terminals doesn't even try, which is a shame because it's an easy addition.
Link blog entry for "Let's Implement the Map Method from First Principles": Those new to functional programming often wonder when to use higher-order functions (or blocks/procs/lambdas in Ruby). I did, too. In this post, we'll implement the map method from scratch, in turn gaining an intuitive understanding of higher-order functions and when to use them. (https://www.akshaykhot.com/map-from-first-principles/?ref=akshays-blog-newsletter)
#ruby, explainer, proc, lambda, map
#Buongiorno
Un Paese impegnato da giorni a dibattere sulle parole allucinanti di #Giambruno, compagno di #Meloni, e quindi difese a spada tratta a destra, dove nessunə ha un sussulto di dignità , come già successo per "#Ruby nipote di #Mubarak".
La politica in Italia (e si potrebbe allargare il discorso all' informazione).
#buongiorno #Giambruno #meloni #ruby #mubarak #9settembre
Ruby Outperforms C: Breaking the Catch-22
Link: https://railsatscale.com/2023-08-29-ruby-outperforms-c/
Discussion: https://news.ycombinator.com/item?id=37422705
👋 If you know folks looking for help on Ruby/Rails projects, I'm available for freelance work right now.
Old app rescues, big upgrades, feature work, you name it, I either truly enjoy doing it or reluctantly became good at it over the years, and now here we are.
I can also do some pretty nifty DIY heat pump installs and home espresso setups but that'll take a bit longer. 😅
DM or hi@olivierlacan.com to discuss.
PS: double points if you work on climate or science-related work
@jsrn I did some work a while ago using a combination of the ‘parser’ and ‘rugged’ gems to trace the git history of a #ruby method which might be relevant.
I wrote a couple of blog posts about it and the code is open-source:
* https://gofreerange.com/tracing-the-git-history-of-a-ruby-method
* https://gofreerange.com/building-a-git-repository-of-ruby-method-definitions
* https://github.com/freerange/method_log