Category: code

  • A Challenging Introduction to Rust

    Learning a new programming language is rough without using it regularly. When I tried to learn Go a while ago, I struggled because I was not using it a lot. Then I my team at work started using Go and it clicked into place really well. When I decided to pick up Rust, I ran into the same challenge. This time, work wasn’t going to save me. I decided to challenge myself to write all new personal code in Rust.

    As part of a college course I’m doing, I have a security and cryptography module this year and I decided to try to write the code for that module with Rust. In some particularly tricky sections, I had to write the code in Python first and then figure out how to convert that into Rust. I’m pretty sure my code isn’t the most perfect, it helped me get a sense for using the language constructs and reading a lot of documentation.

    Some useful things I learned

    • Read the docs. Duh. I also enjoyed Rust by example.
    • Clippy helped improve my code into something marginally elegant.
    • Learning to write tests early increased my velocity a lot. The code-edit-run cycles are a lot easier if unit tests do the work for you.

    Following a book or a full guide bored me a bit, so this was a nice middle ground and I got to submit this for my assignment. The code is at cipher-suite and I can’t really think of any real world use cases for it. It was fun playing around with it.

  • An Upgrade to Salary Converter

    I wrote salaryconverter.nigelb.me over 10 years ago, when I was interviewing for a job. It was a fun project to build. I’ve sort of updated the data on and off, but haven’t made major code changes since. In 2021, when I upgraded the Flask version, I had to make some changes to deal with the changing Flask ecosystem. In the last few months, I’ve given it some major upgrades, some superficial and some not.

    Tailwind CSS

    Almost all the web frontends that I’ve written in the last several years used Bootstrap. It was easy to learn and easy to customize. I liked that I could build a decent website with it. I’ve been yearning to it to look slightly different for a while. Looking around, I decided to experiment with Tailwind CSS. I was looking for something that didn’t have a sharp learning curve and something that could help me build a responsive website within a few hours.

    Tailwind was definitely the right tool for the job. It was easy to learn and the website now looks pretty different from back the day. It’s perhaps the most visible change I’ve made to the website in a long time.

    Python to Golang

    In the last 4 years or so, I’ve been writing more Golang and less Python. This has motivated me to try to learn how to write web services in Golang. This is the first project I’m experimenting with. I decided to stick with a framework, so I’m using Gin. It only looks subtly different from the native libraries. This migration was a good clean up the codebase. My original build of this website involved a manual data import. This seemed like a good idea at the time, after all, I wasn’t going to update the data every month, was I?

    Automation

    It turns out, a lot of people use this website. I often get emails asking me if the data could be updated. I haven’t had a lot of free time in the last few years, mostly because life. A manual data update isn’t exactly the most exciting thing. Thankfully, I know how to write better automation now than I did over 10 years ago. As part of the migration, I spent some time automating the entire workflow of fetching the data automatically. This means the site will have new data every week without me having to do anything about it!