Rust: Clone vs Copy

One of the strength of Rust is memory management. This also leads to compiler errors related to move or borrow When we assign an existing variable to new variable, two things can happen. Either the data is copied - in that case we can use both old and the new variable without worry. 1 Or data is moved - now we can only use the new variable, as the old variable is “out of scope”.

Continue Reading »

How to create IDE like experience in terminal using Zellij

(undocumented?) Zellij Keybindings Undocumented, because these don’t show up in the default configuration, which shows (I assume) most useful key bindings. I had to look for these, and found them in Github discussions/issues. Ctrl p d Ctrl p is for pane, but d after that (which I assume stands for down) is not documented. This creates a new terminal in horizontal split fashion 1 Ctrl n - to reduce the size of the terminal.

Continue Reading »

error: Unknown binary 'rust-analyzer'

As I am setting up my new machine, I came across this error when emacs tried to use rust-analyzer error: Unknown binary 'rust-analyzer' in official toolchain 'stable-x86_64-apple-darwin'. As mentioned in this SO question, which rust-analyzer did not show any error.1 Luckily, the same SO question also had the solution I needed to explicitly install it via rustup component add rust-analyzer Luckily, the comment in the accepted answer also explained why which works.

Continue Reading »

Format raw strings in rust

When refactoring code to make API call to Gemini, I learnt how to format raw strings in rust. fn main() { let var1 = "test1"; let formatted = format!(r#"var1 is: {}"#, var1); println!("{}", formatted); } This gives output as : var1 is: test1 If you want { in the output, then it needs to be escaped with additional { like: fn main() { let var1 = "test1"; let formatted = format!

Continue Reading »

How to use .env files with your rust project

It is very important that secrets are stored in environment variables during the runtime. During the development, it makes sense to use .env file. In my last project, there were probably 40+ variables in the .env. Although that project was in RoR the idea of .env itself is not new. But for me, using .env with rust is new. For my current (self) assignment, I needed to store an API Key.

Continue Reading »

Finally, my Macbook Pro is back!

As part of fixing, they put OS X Yosemite on it. 😭

Practically nothing worked. For some reason, Apple ID login also did not work. I checked on another machine, username/password was indeed correct.

There was no option to upgrade to macOS Monterey (last supported version on this hardware) from the App Store either.

App store listed macOS Sonoma, which I knew wasn’t supported, but tried it anyway. As expected, it said “Not supported” (Duh!)

Finally, resorted to Internet Discovery.

It offered to install macOS Monterey, as expected.

All is well.

(It took some time, downloading etc. But otherwise pretty uneventful)

Left Sage

Today was my last day at Sage (I joined Lockstep, which was acquired by Sage) I spent a little over two years working with the wonderful engineering team there. I learnt a lot from everyone on the team, and made some new friends (I knew one person before I joined) during my stay. Most of the team was junior to me (in terms of number of years of experience.) But as I worked with them, I noticed that every single one of them were exceptional engineers.

Continue Reading »

Why I switched to Zellij

I had tried switching to tmux for local shell sessions in past, but never truly understood why I might need it. I extensively used tmux for remote sessions. But why might I need it locally ? Then slowly I stopped using tmux and switched to wezterm which provided multiple tabs. Fast forward several years later. Recently I came across Zellij. I decided to give it a go. When I had tried tmux it took some time to get used to the keybinding.

Continue Reading »

How I generated 2000 parallel requests using nu-shell

At work, I need to load test new framework I had deployed. Usually, I work with QA team. They use JMeter (with Azure Load test) for such task. But today, the QA person was busy with other tasks, and I didn’t want to get blocked. Since I am learning rust, (nu-shell is built in rust) I remembered that it may be possible to run parallel requests in nu-shell. and it is!

Continue Reading »

My Macbook Pro won’t boot anymore :(

I was watching some Youtube videos in the evening, and then at night, it just became unresponsive.

Over the next few days, I tried various options.

Booted from external USB. Worked!

Tried Internet Recovery.

Turns out the SSD is recognised, but can’t be fixed/formatted/erased.

Looks like a hardware issue.