Simone Web Design

Hi — I’m Simone Vittori, a software developer based in London.
I have experience in web development with a variety of languages, such as Ruby, Rust and Elixir. I’m passionate about good software design and I use this blog to write about anything programming related that I find interesting. You can follow me on Twitter or subscribe to the RSS feed. Happy reading!

Multiple Git Config For Different Folders

I wanted to have a clean separation between work-related repositories and my personal projects, as I often need to use a different email: for example, I’d like to sign git commits in the work repo with my work email, but keep using my personal email for the rest. How do you achieve this?

It’s actually pretty simple: I’ll show you how.

Inserting values of multiple types in Rust's HashMap

I was building a generic data store with Rust and I needed to implement a heterogeneous collection of keys and values. Essentially what I needed was a dictionary, but with values of dynamic type, like both strings and integers at the same time.

Rust is a statically typed language and, due to the memory safety guarantees we are given, all values of some type must have a known, fixed size at compile time, therefore we are not allowed to create a collection of multiple types. However, dynamically sized types also exist, and in this article I’ll show how to use them.

How to fix “Untracked working tree would be overwritten by merge” error

Let’s say you have two Git repositories: one on GitHub, and one on your computer.
They contain identical (or very similar) files, and what you want to do is “synchronize” them (i.e. make them look exactly the same). Maybe all you need is to download a few missing files from GitHub to your computer, or simply push some changes from your machine to GitHub.

You have tried git pull, but you’re getting this error:

error: Untracked working tree file * would be overwritten by merge.
fatal: read-tree failed

You need the changes, but obviously you don’t want to overwrite or lose any files. Don’t worry, the fix is actually straightforward!

How to enable Dark Mode on macOS with the command line

If you want to toggle between light and dark mode, it can be done with a single shell command:

osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode'

Try it and it will switch the mode immediately. No need to restart or install anything.

A pure CSS onclick context menu

Context menus are one of those very useful UI widgets that still haven't reached the HTML spec. There have been attempts, but for now everyone tends to make their own custom implementation.

Especially with the advent of React, the tendency is to write a custom menu component that uses JavaScript to open/close itself, perhaps by using an invisible overlay to detect clicks outside the menu and close it accordingly. This works fine in practice, however it doesn't have to be so complicated. If you need a simple dropdown menu that:

  • Has no dependencies;
  • Can be triggered with a click/tap on any element;
  • Is fully cross-browser;
  • Doesn't need JavaScript!

Then look no further. It's much simpler than you think!

Blog Archives →