Pipenv to UV

Posted on 12 April 2025 in Technology • Tagged with pip pipenv python uv

I have been (mostly) happily using Pipenv for many years now on all of my Python projects. Recently, I heard about UV so I'm giving it a try with the very small set of Python dependencies used for this blog.


Continue reading

Ubuntu on a Macbook Pro Mid 2019 (MacBookPro15,1)

Posted on 15 February 2022 in Technology • Tagged with apple, linux

Apple's T2 Security Chip gets itself in the way as much as possible when attempting to install Linux on a Mid 2019 Macbook Pro and a lot of the available documentation for Linux-on-the-mac online is pre-T2. After quite a bit of back and forth and eventually finding the right resources I managed to get Ubuntu installed on my MacBook Pro with everything working... except the microphone.


Continue reading

Back to PHP

Posted on 11 August 2018 in Asides • Tagged with drupal, php

A few months back I started a new job with a much greater focus on development work over IT systems management. Unfortunately this has led to a pretty big drop off in amount of time spent on personal side projects, but happily my new employer is fully supportive of open source and I am able to release much of what I work on to the wider community.


Continue reading

Pip, Pis, Pandas and Wheels

Posted on 07 May 2018 in Technology • Tagged with arm, baby buddy, pip, pipenv, python, raspberry pi, troubleshooting

A user attempting to install Baby Buddy submitted an interesting issue with the following error during the pipenv install process:

THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock!. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    docopt==0.6.2 from https://www.piwheels.org/simple/docopt/docopt-0.6.2-py2.py3-none-any.whl#sha256=0340515c74203895f92f87702896e45424bf51dc71bf15b4748450f50be04346 (from -r /tmp/pipenv-vf5_eub9-requirements/pipenv-k7_dvsro-requirement.txt (line 1)):
        Expected sha256 49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491
             Got        0340515c74203895f92f87702896e45424bf51dc71bf15b4748450f50be04346

Hash checking and Pipfile.lock are a part of the pipenv toolchain and meant to verify the integrity of packages being installed. Committing the lock file is recommended practice and generally something I have not had many problems with. There are some old tickets on GitHub reporting issues with this hashing between operating systems, but the latest versions of pipenv supposedly do not have these problems.

Why is this user getting a hash match error? I had a Pi lying around, so I decided to try replicating the issue. Many hours later, I got Baby Buddy up and running on my (second) Pi and learned a lot about the Python packaging process and how it can go wrong on ARM devices.


Continue reading

Advent of Code 2017: Days 16 - 20

Posted on 20 December 2017 in Technology • Tagged with advent of code, python

This post is part of the series, Advent of Code 2017, where I work my way through (part of) the 2017 Advent of Code challenges in order to re-learn some of the basics of Python and reflect on some simple concepts and functionality. All my challenge code is available in cdubz/advent-of-code-2017 on GitHub.

Day 16: One Billion Permutations in 0.535 Seconds

Ok, not really (: This challenge involved making specific modifications to a list 1,000,000,000 (one billion) times. Out of curiosity, the first thing I did was set up a progress bar loop to run the actual modifications all one billion times. The resulting progress bar estimated that the entire operation would take around 133 days. So... a different approach:

1 2 3 4 5 6 7 movements = [...] possibilities = [positions] while True: positions = move(positions, movements) if positions in possibilities: break possibilities.append(positions)

Because the movements are always the same, eventually the positions list elements will return to their initial state. In this case, that happened on the 41st movement, making for a possibilities list of size 42. Armed with the answer to the ultimate question of life, the universe, and everything, it was much easier to determine the value of positions at the one billionth permutation:

9 10 answer_key = pos - int(pos/len(possibilities)) * len(possibilities) print(possibilities[answer_key]) # 1,000,000,000!

This all takes a little over half a second, as opposed to the 133 days of processing that would be needed to run all one billion permutations. Phew!


Continue reading

Advent of Code 2017: Days 11 - 15

Posted on 15 December 2017 in Technology • Tagged with advent of code, python

This post is part of the series, Advent of Code 2017, where I work my way through (part of) the 2017 Advent of Code challenges in order to re-learn some of the basics of Python and reflect on some simple concepts and functionality. All my challenge code is available in cdubz/advent-of-code-2017 on GitHub.

Day 11: Navigating a Hexagon Grid

I fought with how to create and navigate a hexagon grid for a bit before I stumbled on an extremely useful post by Chris Schetter: Hexagon grids: coordinate systems and distance calculations. Working in 2d grids (with four possible movement directions) in Python is fairly easy with some dictionaries, but a hexagon grid means there are six potential directions and simple calculations of x,y coordinates won't quite get the job done. What Chris explains so well is a simple concept: flip the grid and add a z-axis.

For my solution, I "flip" the grid by turning it to the right twice such that north and south become east and west:

  \ n  /
nw +--+ ne              sw +--+ nw
  /    \                \ /    \ /
-+      +-    ---->    s +      + n
  \    /                / \    / \
sw +--+ se              se +--+ ne
  / s  \

This puts north and south along the x-axis instead of the y-axis. Next, adding the z-axis and shifting all axises 120 degrees means that each hex can be made up of three points instead of two. Again, I refer to Chris's post and this image that illustrates the concept wonderfully:

Hex grid with coordinates Credit Chris Schetter (Hexagon grids: coordinate systems and distance calculations)


Continue reading

Advent of Code 2017: Days 6 - 10

Posted on 10 December 2017 in Technology • Tagged with advent of code, python

This post is part of the series, Advent of Code 2017, where I work my way through (part of) the 2017 Advent of Code challenges in order to re-learn some of the basics of Python and reflect on some simple concepts and functionality. All my challenge code is available in cdubz/advent-of-code-2017 on GitHub.

Day 6: max(x, key=y)

Another simple revelation on built-ins from this challenge: the key argument can be used to modify what is evaluated by the max function. This concept is explained in detail as part of the accepted answer to this Stack Overflow post: python max function using 'key' and lambda expression.

For Python dictionaries, this means that the get() method can be used to return the key of the maximum value in a dictionary. This works because the max function sends each of the dict keys to the dict.get() method and evaluates that result instead of the key itself. Without this argument, max will actually evaluate the dictionary's keys, which isn't terribly useful:

1 2 3 4 >>> max(d) 3 # This is the *maximum value of the dictionary's keys*. >>> max(d, key=d.get) 2 # This is the *key of the maximum value in the dictionary*.
Continue reading

Advent of Code 2017: Days 1 - 5

Posted on 05 December 2017 in Technology • Tagged with advent of code, python

This post is part of the series, Advent of Code 2017, where I work my way through (part of) the 2017 Advent of Code challenges in order to re-learn some of the basics of Python and reflect on some simple concepts and functionality. All my challenge code is available in cdubz/advent-of-code-2017 on GitHub.

Day 1: zip()

This challenge taught me about Python's built-in zip function. The basic goal is to compare values in a list with specific positional relationships to other values (e.g. next to, X steps from, etc.) in the same list. zip assists with this task by combining multiple lists in to tuples. My initial solution used a construct similar to:

1 2 3 4 total = 0 for a, b in zip(digits[::1], digits[1::1]): if a == b: total += a
Continue reading

Advent of Code 2017

Posted on 30 November 2017 in Technology • Tagged with advent of code, python

I taught myself Python a few years ago by following the wonderful Learn Python the Hard Way (LPTHW) series by Zed A. Shaw. Since then, I have spent a decent amount of time in Python largely in the Django framework. Django is a lot of fun to work with because it abstracts away much of the complexities of developing a full-featured web application in Python. In this way, however, it has also led me to forget some of the basic Python that I learned through LPTHW.

In order to recapture some of those early lessons (and maybe learn a few more Python 3 specific ones), I worked through (part of) the 2017 Advent of Code, a 25-day, language agnostic programming challenge series developed by Eric Watsl. I originally thought about using the series to learn a new language, but eventually realized that I still have a long way to go in Python.

This series explores my (often very basic) revelations and lessons learned while completing 20 of the 25 days of challenges (vacation travel cut the series short for me). The code I used for each day is available on GitHub. Also check out the advent-of-code and advent-of-code-2017 GitHub topics to see the many solutions people have developed in various languages.


Continue reading

Consistent Selenium Testing in Python

Posted on 01 September 2017 in Technology • Tagged with django, python, saucelabs, selenium, testing, timestrap

Back in April, I learned about Timestrap, a self-hostable, Django-based time-tracking project from a post on HackerNews by Isaac Bythewood. As I have been learning Python in the past year or so, I reached out to Isaac and started contributing to the project. After getting familiar with the core application, I turned my attention to testing and eventually found my way to Selenium, a collection of browser automation tools used for frontend testing.

I had never worked with Selenium or other automated testing products, so it struck me as a great opportunity to get my feet wet in something new. After getting things up and running, we quickly learned that the test results were quite inconsistent across development environments - even to a point that occasionally tests would succeed when run individually, but fail with the full test case.

After much trial and error, we have settled on a (mostly) consistent setup for testing with Selenium, Python and SauceLabs. This produces much better results than testing in development environments and crossing fingers during CI. Hopefully this primer will help others facing similar challenges (as we had a lot of trouble finding good material on the subject).


Continue reading