Doing It Wrong

learn in public

Site Navigation

  • Home
  • Books
  • Work & Play

Site Search

You are here: Home / Archives for Reference

Measuring Temporal and Spatial Complexity

posted on November 27, 2023

What is Big O?

  • way to categorize your algorithm’s time or memory requirements
  • not an exact measurement
  • meant to generalize the growth of your algorithm

Why do we use it?

It helps us make decisions about what data structures and algorithms to use. Knowing how they will perform can help you make the right decision between performance and complexity.

Filed Under: Development Tagged With: Complexity, Reference, Spatial, Temporal

Useful Docker Commands

posted on December 19, 2022

Docker (Compose) Commands that I Find Useful

Burn it All to the Ground

docker compose up will take a long time after this, but you’re here because nothing is working anyway.

docker system prune --volumes --all

Run an interactive shell inside of a running docker container

docker ps # get the container ID / name of the service you're interested in
docker exec -it {container ID or name} bash # or maybe bin/bash if bash is not in your PATH?Code language: PHP (php)

Run a Docker container and start an interactive shell inside of it

docker run -it {image name, like nginx:alpine} bash # or maybe bin/bash if bash is not in your PATH?Code language: PHP (php)

Run a Docker container and start an interactive shell inside of it, bind mounting your current directory

docker run -it -v $(pwd):/{some path} {image name, like nginx:alpine} bashCode language: JavaScript (javascript)

Build a Docker image

docker build -t {image name, like transfer-suite} . # I think this assumes the default Dockerfile name
docker build -t {image name, like transfer-suite} . -f {image name, like transfer-suite}Code language: PHP (php)

Run a Docker image by name

docker run -p 80:80 {image name, like transfer-suite}

Filed Under: Development Tagged With: Docker, Docker Compose, Reference

Useful Git Commands

posted on December 10, 2021

Git Commands that I Find Useful

Many of these are initially sourced from Stack Overflow or great articles that have titles like “5 Must-Know Git Commands” then modified to fit my workflow (here’s one great example for popular git configs). Some are actually put together by reading the docs.

Delete Branches that have been Remove from Remote

For this to delete branches, local must know that remote has removed branches (which git branch -v lists as [gone]). One way to accomplish this is to configure your fetch to always prune.

git branch -v | awk '/ \[gone\] /{ print $1 }' | xargs git branch -dCode language: JavaScript (javascript)

Always Prune on Fetch

From the docs, “…remove any remote-tracking references that no longer exist on the remote.” git pull and git fetch would both have the following setting applied, since git pull is (in my mind) like running git fetch and git merge.

git config --global fetch.prune trueCode language: PHP (php)

Viewing the global git config (cat ~/.gitconfig) should now show

[fetch]
    prune = trueCode language: JavaScript (javascript)

Always Rebase on Pull

git config --global pull.rebase trueCode language: PHP (php)

Viewing the global git config (cat ~/.gitconfig) should now show

[pull]
    rebase = trueCode language: JavaScript (javascript)

List Subtrees

git log | awk '/git-subtree-dir: / { print $2 }' | uniqCode language: JavaScript (javascript)

As an alias (global .gitconfig):

[alias]
    subtrees = !git log | awk '/git-subtree-dir: / { print $2 }' | uniqCode language: JavaScript (javascript)

Delete Orphaned Local Branches

Prerequisite to this your local branches must have references removed to non-existent remote branches.

git branch -v | awk '/ \[gone\] /{ print $1 }' | xargs git branch -dCode language: JavaScript (javascript)

As an alias (global .gitconfig):

[alias]
    prune-delete = !git branch -v | awk '/ \\[gone\\] /{ print  }' | xargs git branch -dCode language: JavaScript (javascript)

Filed Under: Development Tagged With: git, Reference

Profile Links

  • GitHub
  • Buy Me a Coffee?

Recent Posts

  • Event Listeners
  • A Philosophy of Software Design
  • The Programmer’s Brain
  • Thoughts on Microservices
  • API Design Patterns

Recent Comments

No comments to show.

Archives

  • May 2025
  • September 2024
  • July 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • December 2022
  • December 2021

Categories

  • Development