Making a custom datetime in python:

from datetime import datetime


Make git log much more readable and compact:

git log --oneline


Copy a file

cp -i example.txt ~/Documents

Copy and rename

cp -i example.txt ~/Documents/file.txt

Note: -i or --interactive means you'll be asked to confirm before overwriting a file in the new destination. By default cp will overwrite any existing file with the same name.


Found this Reddit post useful today, when I wanted to do some Ruby gem setup so fastlane can update itself.

Here's what the fastlane docs suggest adding to your ~/.bashrc or ~/.zshrc file:

export GEM_HOME=~/.gems
export PATH=$PATH:~/.gems/bin

But since I use fish, according the Reddit post, the same thing can be done with fish by editing ~/.config/fish/ like so:

set -x GEM_HOME $HOME/gems

And a helpful note from the Reddit user who posted this solution:

"-x" for exporting to all subshells, notice that there is no "=" between variable and value you set it to.


Trying out FastAPI today. Here's how to make a path:

@app.get('/', response_class=HTMLResponse)
def read_root():
    return {'Hello': 'World'}



Filter out merge commits when using git log:

git log --no-merges

Or, only show merge commits:

git log --merges


Creating a virtual environment in python

First, create the directory for your project and cd into it.

python -m venv name_of_virtual_env

You can pass a path to venv but I like to cd into the right place first, then just use the name to create a directory where I am.

Activating the virtual env in fish:

. name_of_virtual_env/bin/

To deactivate in fish just type deactivate


Use git log for particular files by passing their paths:

git log --

You can omit the -- but it tells git the following arguments are file paths, not branch names, so always use it if your file path could be confused with a branch name.


Looking for a key in a dictionary in python will throw a KeyError if the key doesn't exist. We can check first if the key exists using in:

if "possible_key" in my_dictionary:
    # now we know the key exists, so we can access it
    values = my_dictionary["possible_key"]


Making a new object:

let user = {};

Alternative syntax (apparently this isn't common, though):

let user = new Object();


Iterate over a dictionary's keys and values

I keep forgetting you have to use .items() if you want the keys and values.

for key, value in d.items():
    # do stuff


Add a beta tester to TestFlight (use -g to specify groups to add the tester to, as well):

fastlane pilot add -a -g group-1,group-2

Removing a beta tester from TestFlight:

fastlane pilot remove -g group-1,group-2


CSS variables

:root {
    --main-bg-color: #F7B100;
p {
    background-color: var(--main-bg-color);