Today I completed “Rust: The Complete Developer’s Guide” course on Udemy ๐ŸŽ‰

Here is the certificate

Rust: Unit tests in a separate file

In rust, tests are written in the same file as the code. But I want to have the tests in a separate file.

Conventionally, only the integration tests are written in files under tests folder. 1

I just wanted to have the unit tests in a separate file. So I created a file src/my_tests.rs and moved all the tests there.

But cargo test kept saying running 0 tests

Turns out, I’m not the only one. 2

Continue Reading »

Updated the README for the Theme Repo

It has been little over 2 years since I forked and updated jnjosh’s internet-weblog theme

While I made several changes to my fork, I never updated the README.

till now that is.

During last few days, I updated the README to match my fork.

These are minor changes, and majority of the README is still from the original (For the things that have not changed)

If you are curious, have a look ๐Ÿ˜„

Jujutsu: Working With Git

After reading (not done) Steve’s Tutorial and Official doc 1 (which mentions Steve’s tutorial anyway) I decided that actually using it on real projects is the way to go.

Here is the workflow (after a few 2 iterations 3) that works

  1. jj new : Declare your intention to start new work.
  2. jj describe : Intention alone is not enough ๐Ÿ˜€. What will you be working on ?
  3. Now work. Make changes.
  4. Time to make our “change” available in git. Get the change id from jj log
  5. jj bookmark set main -r <change_id_from_previous_step>
  6. jj bookmark track main@origin (or appropriate branch on origin). You’ll need this step only once.
  7. jj squash -i : Select the files that need to be “added” to the commit
  8. jj git push --allow-new -b main --remote origin 4 Done!

Finally, I must say that I’m blown away (and humbled) by the fact that “The Steve Klabnik” who wrote the Jujutsu tutorial and the Rust book, helped me 5 (Near real time responses) with my problem.

Continue Reading »

Jujutsu : git compatible but better DVCS

I learnt about Jujutsu from the “Rust in Production” podcast episode about Git Butler

One of the attractive quality about it is that it works with existing git repos 1

First superpower : Start using it with existing git repo locally cloned using jj git init --git-repo=. 2

This creates a .jj folder in the existing repo. .jj and .git co-exist peacefully

But I didn’t know that.

So for the first project to try Jujutsu, I jj git cloned my existing repo in a new folder, so that I have “old” git repo as well as jujutsu repo.

Continue Reading »

Rust: Doubly Linked List

No, this is not a post about how to implement doubly linked list in rust.

Or ir could be a very short post, since doubly linked list in built-in the std::collection as LinkedList

Following functions are available:

  • new : Creates new/empty linked list
  • push_back : Adds an element to the list
  • push_front : Since this is doubly linked list, element can be added at the beginning as well. Nice!
  • pop_back and pop_front : Remove an element from the list
  • clear : empty the entire list
  • append : Append one list to another to make bigger list. One that got appended becomes empty though.
  • contains : Searches through the list for the element 1
  • There are iter, iter_mut and len as well.

[Documentation](https://doc.rust-lang.org/std/collections/ struct.LinkedList.html) is easy to understand

Continue Reading »

Waydroid

I wanted to use Openvibe - an app that allows having a single timeline across multiple social media networks like mastodon and bluesky. It also supports cross posting (and more)

But currently it only has mobile apps (for both iOS and Android)

While the Desktop app is “in the works” - no specifics are provided.

I do not use mobile apps if at all possible. (Except for podcast and messeging apps to keep in touch with Family - on the go. If I’m at my desk, I use the Desktop version)

Continue Reading »

No One is (really) Evil

NSQ episode about evil led me to thinking about this.

Takeaways from the episode

  • Evil is attributed only to humans.
    • If an animal attacks and kills human(s) we do not label the animal as Evil.
  • Intentionality matters.
    • Accidental killing/death does not mean Evil
  • People do bad things because their brain is not “well”
    • Amigdala is the part of the brain that is responsible for fear and morality.
    • Should bad people be locked away longer (cause they may be threat to the society)
  • Phil zimbardo prison experiment
  • Bad barrel (Vs Bad Apple)
  • People become evil due to surrounding 1
  • Stanley Milgram Experiment
    • People are OK doing bad things if
      • They are in position of power and
      • Are told by their superiors to “punish” others
      • 2 out of 3 volunteers shocked the (the actors playing) students upon giving wrong answers, because they were “instructed” to do so 2

My thoughts

  • Only movies/TV has pure evil person
    • In good movie/TV, they have some explanation about why the person become “evil”
  • When people do bad things to you, do not hate them
  • Consider some of the points above.
  • What made them behave the way they did
  • (Most of the times) it is not personal [^3]

  1. One can choose to become Oskar Schindler in Nazy Germany. Do the right thing even if the surroundings are wrong. (But takes courage) ↩︎

Continue Reading »

How to run multiple postgres docker instances on local machine

When working on multiple projects, I run separate postgres instance for each of them.

Since these are docker instances, this is not a problem as long as they are not running at the same time

If I’m actively working working on multiple projects parallelly, then there are two problems :

  1. Resources : My laptop becomes slow. There is no solution for this 1
  2. Assuming you have LOTs of memory, second problem still remains. Both instances try to bind to local port 5432 the default port. Which does not work. So you need to bind other postgres instances to different local ports like 5433, 5434 and so on. This is controlled via -p in the docker command.

The format is :

Continue Reading »

How to Turn Off Inlay Hints in VS Code

I initially tried to turn off the type hints via rust-analyzer extension setting, but that did not work ๐Ÿ˜ž

Turns out it is very complicated (at least for me) documentation did not help ๐Ÿ˜ž

Here is what worked for me. Thanks to SO 1

  • Open Command Palette Cmd+Shift+P
  • Select Preferences: Open User Settings (JSON) from the drop down
  • Add the following to existing settings
    • Or create new one, if empty. You may need to enclose it within { } though.
	"editor.inlayHints.enabled": "offUnlessPressed"

This will turn off the type hint inlays.

Continue Reading »