Weeknotes 30
23rd January, 2022
“Quality of life improvement”
-
I discovered recently that Ruby’s Struct has a
keyword_init
option which was introduced in version 2.5. It makes using Structs much more pleasant not having to rely on the positional argumentsBuild = Struct.new(:built_on, :slug_id, keyword_init: true) Build.new(build_on: now, slug_id: 123)
-
In other Ruby news, recently released 3.1 has some very nice quality of life improvements with IRB now supporting suggestions/completions with the introduction of a new readline compatible library called reline.
Ruby has been lagging behind in good developer tooling. This has become more apparent to me after using Elixir and Rust, both of which put a lot of effort into it. These changes are very welcome 👏
-
I wondered this which gems had native extensions and a quick Google and Stack Overflow later this one liner told me:
bundle show --paths | ruby -e "STDIN.each_line {|dep| puts dep.split('/').last if File.directory?(File.join(dep.chomp, 'ext')) }"
Useful in the context of Apple’s new silicon future.
-
I’ve been dipping my toe back into JavaScript/TypeScript and this week I discovered the console.dir and console.table methods for logging to the console in a more structure way.
-
Turns out you can have syntax highlighting in Markdown fenced code blocks in Vim.
" Configure languages so we get syntax highlighting in Markdown files let g:markdown_fenced_languages = ['bash', 'elixir', 'fish', 'html', 'javascript', 'ruby', 'rust', 'typescript', 'vim']
-
I found this nice utility called TRex which sits in the menubar on macOS and allows you to capture text from anywhere on the screen using OCR.
TRex captures any text right into your Clipboard with magic of OCR. But what is OCR anyway? Imagine you have a PDF file or a Web page where you can’t select the text, image with text on it, or even a YouTube video. Forget retyping it manually; with TRex, you can extract text from anywhere, and it is as easy as taking a screenshot.
From memory, I think Apple released some OCR related APIs fairly recently. I wonder if that’s what is used here. It does a single thing really well. I think it could become very useful to me.