Weeknotes 42
17th April, 2022
“StandardError”
-
Hashrocket’s TIL site is great (I’m surprised I haven’t linked to it yet as I read it a lot). This time I learnt that you can do
Ctrl
+Command
+Q
to lock your Mac. -
I was listening to a recent Remote Ruby episode – Parsers, Interpreters, and YJIT with Kevin Newton – on the recommendation of my friend Harry and really enjoyed it. They covered several topics but the formatter related chat had me thinking about the impact of using formatting tools.
In general, I’m a fan of formatters – they are good for learning (I’ve found
rustfmt
helpful when learning Rust) and they can reduce endless bikeshedding when reviewing PRs. However, as long term Rubyist I’m not sure how I feel about being forced to write Ruby in a certain way.If a formatter had been around when Ruby was becoming popular would DSLs such as those used in RSpec and Sinatra have become so popular? And would that have been good or bad?
-
I learnt this week that
rescue
in Ruby defaults toStandardError
. I think this behaviour has changed. I’m sure that it used to be the case that rescuing without specifying the exception class was a very bad idea because it would include things like syntax errors.Two Ruby statements have default exception classes:
raise: defaults to RuntimeError.
rescue: defaults to StandardError.That seems to no longer be a problem, but I can’t help thinking that maybe it is worth being explicit and always choosing
StandardError
if something more specific is unavailable. -
Evil Martians released a font! – Martian Mono. It’s really nice, but I think I’m sticking with JetBrains Mono for now.
-
I was aware of Raycast when it first came out, but I was already using Alfred, and I didn’t really give it a good try. Well, a colleague brought it to my attention again recently and I’ve given it more of a chance this time.
It’s really good. I don’t know why, but it clicks with me more than Alfred ever has. Although a long time user of Alfred I never became a power user and ended up using it as a better Spotlight.
Stand-out Raycast extensions for me are those for GitHub and Jira. Especially Jira as I can lookup issues faster than loading the website (which is a sad state of affairs, but here we are).
My only worry is that it is free for individuals, so will it still be around in a few years?
Worth checking out.
-
In my experience people don’t tend to write unit tests for Rails helpers as much as they do for “other” code. Which is weird because those same people also love to make Rails helpers do all sorts of crazy stuff that shouldn’t be in a helper - like querying the database.
-
Only add memoization if a) you’re sure it’s needed and b) you have a plan to measure the before/after performance. Otherwise you’re not optimizing, you’re just randomly doing stuff.
Don’t automatically chuck in a
@foo ||= "bar"
just because memoization is convenient in Ruby. -
Ignore URLs and Acroynms While Spell-checking Vim – a useful tip on how to stop URLs showing up as spelling errors in Vim. This had been bugging me for a while.
syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
I can’t quite figure out how to make it happy inside my now Lua-based config, but it works in a regular Vimscript configuration file.
-
Lexical looks promising.
An extensible text editor framework that does things differently
React only at the moment, designed to work with other frameworks in the future too.
-
Custom Attribute Types in Rails 5+ – I’ve never used the Rails Attribute APIs directly. Maybe I should be?