Language Before Framework

Several years ago, I came across a quote1 about how learning python via Django. The author said that if you don’t properly know python, you may not understand what is Django specific and what is not. FWIW, even after working with python, I never used Django in any of my main project. But I did learn python first before the frameworks. Fast forward to few days ago. I am working on Ruby code to read from Azure Service Bus.

Continue Reading »

Ameba: Rubocop for Crystal Language

Ameba seems like quite mature linter for Crystal language. As I start my first real world code in Crystal language, the real tools are very useful. (Side note: I didn’t write any non-real-world crystal code. I’m not sure it helps. REPL sessions are not code. they don’t count) It automatically uses built-in formatter in the --fix mode. There is also awesome emacs integration as well. Check ameba.el

Bang Methods in Ruby (and Rails)

Today I learned about Bang methods in Ruby. Methods ending with ! are potentially dangerous, because they update the object they operate on. ➜ irb --sample-book-mode >> name = "sample_string" => "sample_string" >> name.reverse => "gnirts_elpmas" >> name => "sample_string" >> name.reverse! => "gnirts_elpmas" >> name => "gnirts_elpmas" As we can see above, reverse! modified name itself. Most times (?) we don’t want that. But sometimes we do. Knowing that !

Continue Reading »

Read The Docs Carefully

Continuing with my Ruby language learning journey, I wanted to use it for more than Hello world. So I decided to try python’s request equivalent. Since I didn’t know where to begin, I just searched for requests on RubyGems Turns out Gem by the exact name exists and with description Because Requests for Python is awesome 🤗 But it isn’t updated in close to 5 years now. I also wanted to use something native (i.

Continue Reading »

Ruby Debugger

While there are multiple ways to use Ruby debugger, for my first Ruby script (?) I found starting the script via rdbg to be the easiest. Like rdbg myscript.rb Debugger has all the basic command I have used elsewhere. n for next pp for pretty print q for quit For subsequent times, using require 'debug' followed by binding.break may be better. This README has all the details.


If I were to explain bundler to pythonista (like myself) I would say Bundler in Ruby land is like poetry in python land, except it does not create sandbox environment To explain it a little more. It tracks dependencies in a Gemfile (and Gemfile.lock) which then goes in your repo. Other engineers sharing your code would then run bundle install, and they get exact same Gems (including versions) on their machines.

Continue Reading »

Where Are My (Ruby) Gems ?

As I mentioned earlier, I’m trying Lunar nvim starter kit. Latest version of nvim comes with LSP support, and while learning a new language LSP could be really helpful (I think) I had heard of solargraph. Running :LspInstall in nvim gave me option of sorbet as well. But I decided to stick with solargraph. nvim was successful in installing solargraph, or so it told me. But it did not work. LspInfo told me that it did not find solargraph Just to be sure I gem install solargraph from the terminal, before I tried to install LSP from nvim again

Continue Reading »

Exploring `irb`

Start clean I created an alias irb=irb --sample-book-mode This removes the complex prompt like irb(main):001:0> and gives plain and simple >> instead. Get Help! When programming in Python, even today I use dir in Python REPL. So I was looking for the equivalent in Ruby land. Turns out I was comparing apples and oranges (so to speak) As of early 2022, irb has awesome help built-in. It has good autocompletion. So just typing .

Continue Reading »

Ruby for Python Programmers

While I noted similarities and difference between Ruby and Python, as I was learning the basics here, here and here there is official document on the Ruby site. See this

Learning Ruby: Syntax (Part 3)

Methods Ruby functions start with def just like python, but end with end keyword. splat operator (*) to destructure an array into a List. This is similar to Python splat operator >>> x = [10, 20, 30] >>> a, *b = x >>> print(f'{a=}, {b=}') a=10, b=[20, 30] Python ☝️, Ruby 👇 >> first, *rest, last = ["a", "b", "c", "d"] => ["a", "b", "c", "d"] >> first => "a" >> rest => ["b", "c"] >> last => "d" >> But in Ruby, splat operator can also create an array.

Continue Reading »