In One percent better podcast 1, Joe interviews Matthew Dicks
Matthew explains the Homework for Life 2 as (paraphrased)
At the end of each day, write down important “stories” (not memories) of the day. Else life passes by, and we don’t remember what you did 12 years from today. (Cause all days look the same in past)
He is a teacher. He asks his students to narrate stories (on a Monday, start of the school) He mentions that 10-year olds can come up with excellent stories.
I switched to 1 Vivaldi browser after reading this post by Mike Kennedy
To be fair, I had installed and tried Vivaldi a long time ago. But I think things got better this time around.
I seem to have stuck with it for long time.
One benefit of chromium based browsers (like Vivaldi) is that user has access to vast amount of extensions from Chrome Web store. 2
Just today, I explored two other “features” which I’m not sure how I feel about.
When I published my previous post on mastodon, Sebastian pointed out 1 that using #[cfg] is better than cfg! macro.
Documentation explains that :
cfg!, unlike #[cfg], does not remove any code and only evaluates to true or false. For example, all blocks in an if/else expression need to be valid when cfg! is used for the condition, regardless of what cfg! is evaluating.
Thanks, Sebastian!
See this thread for the original discussion.
We all know we shouldn’t use print debugging, and yet we all do 😉 1
Jokes apart, when I’m still developing the code, I use the debugger where possible. But sometimes, I want to keep certain print statements to verify runtime behaviour, especially when rolling out new feature and when there are too many variations (some of them unknown) in incoming data.
I’m aware, logging is the right way to handle this (with loglevel set to debug or something), but it seems too much when developing toy projects.
At first, I assumed since we’ve declared the capacity upfront, it would be maximum capacity of the Vec
Turns out, since Vec is expected to shrink and grow, as needed, there is no maximum capacity for Vec
It just ensures that “sufficient” memory is allocated to the Vec, such that memory reallocation is not required.
On the other hand, if you need more that what you declared with with_capacity, you will get it, but there will need to be reallocation (of memory), so it will be inefficient.
Today I learnt that certain rust code can be marked such that it is compiled only for specific platform.
This makes sense for low level libraries that provide platform-specific functionality that is not available on other platforms.
This is achieved by tagging the function with #[cfg(target_os = "xyz")]
Here xyz can be one of the following :
“windows” “macos” “ios” “linux” “android” “freebsd” “dragonfly” “openbsd” “netbsd” Similar to target_os, here are other options :
Put @microblog.desipenguin.com@web.brid.gy in the search box.
Thanks to Bridgy.fed this site automatically gets it’s own mastodon account.
Following this account is like subscribing to the RSS feed (I think 😄)
Few days ago, I heard about this on some podcast (maybe changelog ? 🤷♂)
I have been using similar notation for my commits - even for this blog1 - but I did not know it is a specification.
The idea is that very first word of the commit message should indicate what sort of commit is it.
Most common ones are : fix, feat (To indicate bugfix and a feature)
Other useful ones are: docs, style, refactor, test
Then there is chore (catch all ? 😄)
I’ve used some of these at work as well.
As the website mentions, benefit of such style is that some tools can parse the git log to automatically generate the changelog.
Website also mentions, that
it’s not the end of the world if a commit lands that does not meet the Conventional Commits specification. It simply means that commit will be missed by tools that are based on the spec.
Since the commits are just addition or updates to markdown files, most of the tags are not used here. I only use Add and occasional Update. I do believe it is in the spirit of conventional commits 😄 ↩︎
At least for floating point numbers, it does not crash/panic! 🤷♂
fn main() { let x = 10.0; let y = 0.0; println!("{:?}", x/y); } This above code returns inf
But if we change the number to int, compiler catches this 1 at shows the following error:
error: this operation will panic at runtime
This is a contrived example. Instead of static values, if these were passed at runtime, it would (should?