@ wrote... (3 years, 7 months ago)

Packages change pretty frequently when you're using Homebrew on OSX, including Python.

I noticed that I had several instances of lots of large packages installed (Boot, MacVim, Python, etc) so I ran brew cleanup and that freed up approx 9 gigs of disk! Unfortunately it also broke many virtual environments since the version of python that they were pointing at no longer existed.

What to do what to do…

Based on this Stack Overflow question I wrote a script to update a single virtual environment or all of them.

Note, this only updates virtual enviroments created with virtualenvwrapper. Also, you may have to reinstall your packages, but hopefully not.


if [ -z "$1" ]; then
    echo "usage: $0 virtualenv|all"
    exit 1

if [ -z "$WORKON_HOME" ]; then
    echo "you must export WORKON_HOME"
    exit 1

if [ "$1" = "all" ]; then
    echo "udpating all virtualenvs"

    for name in $(find . -type d -maxdepth 1 -mindepth 1|xargs -n1 basename); do
        $0 $name

    exit 0


echo "deleteing $1"

rm -f  $virtenv/.Python
rm -f  $virtenv/bin/pip
rm -f  $virtenv/bin/pip2
rm -f  $virtenv/bin/pip2.7
rm -f  $virtenv/bin/python
rm -f  $virtenv/bin/python2
rm -f  $virtenv/bin/python2.7
rm -fr $virtenv/include
rm -f  $virtenv/lib/python2.7/* 2> /dev/null
rm -fr $virtenv/lib/python2.7/distutils
rm -f  $virtenv/lib/python2.7/site-packages/easy_install.*
rm -fr $virtenv/lib/python2.7/site-packages/pip
rm -fr $virtenv/lib/python2.7/site-packages/pip-*.dist-info
rm -fr $virtenv/lib/python2.7/site-packages/setuptools
rm -fr $virtenv/lib/python2.7/site-packages/setuptools-*.dist-info

source `which virtualenvwrapper.sh`

echo "creating $1"
mkvirtualenv -q $1
Category: tech, Tags: osx, python, virtualenv
Comments: 0
@ wrote... (3 years, 8 months ago)

I seem to need to find files and sort them on modification time just often enough to never remember how but knowing that there's a good way to do it.

Here's the best way I've found so far, it handles spaces correctly and executes a command (ls in this case) on a per file basis. Change (or delete) -n1 to execute the command on multiple files simultaneously.

find . -type f -printf "%T@ %p\0" \ # list all files "seconds-since-epoch filename NULL"
  | sort -z -nr \                   # reverse sort based on seconds
  | cut -z -d' ' -f2- \             # only print filename
  | grep -zZ txt$ \                 # only keep txt$
  | xargs -0 -n1 ls                 # for each line, execute ls

or on one easy copy-paste line:

find . -type f -printf "%T@ %p\0" | sort -z -nr | cut -z -d' ' -f2- | grep -zZ txt$ | xargs -0 -n1 ls

The key here is \0 to output a null character at the end of each filename and then having each command in the pipe honour that null character (via -z|-Z|-0).

Category: tech, Tags: linux
Comments: 0
@ wrote... (3 years, 8 months ago)

There are dozens of similar programs on the the ol' internetz and here's mine.

I'm not a cryptographer.


Category: tech, Tags: python
Comments: 0
@ wrote... (3 years, 8 months ago)

Now that's is so easy for me to create new containers and VMs with Proxmox, that's exactly what I've been doing. However, I like to be a good netizen and use https.

Here's my nginx config that lets me easily add a new LetsEncrypt certificate to a new vm/container for a new webapp.


Category: tech, Tags: linux, nginx
Comments: 0
@ wrote... (3 years, 8 months ago)

When I was setting up Deluge to run headless on my linux server the deluge-web wasn't saving any settings and nothing was working. Turned out to be an easy fix if you know how.

The problem was the that the web-ui wasn't auto connecting to the deluged backend. This caused the connection manager to always pop up.

Anyhow, assuming your web-ui and deluged are running on the same machine edit the web.conf file and make sure that default_daemon is populated.

# /var/lib/deluge/config/web.conf -- your path will likely be different
"default_daemon": "localhost:58846",
Category: tech, Tags: linux
Comments: 0
@ wrote... (3 years, 9 months ago)

Just a quick note before I forget what little I understand. Something happened (or because I installed proxmox on top of an existing debian install, I honestly can't remember since it was like 4 weeks ago) during my install of proxmox. Long story short is that the nfs server doesn't work on reboot.

$ showmount -e
clnt_create: RPC: Program not registered

So then if you manually run rpc.mountd

$ rpc.mountd

$ showmount -e
Export list for proxmox-1

But then you can't actually mount anything until you run rpc.nfsd

$ rpc.nfsd
$ mount proxmox-1:/tank/etc /tmp/etc
# totally works
$ ps auxw |grep rpc.nfsd
# no results

So I'm not sure what's going on. I do know that the half init.d half systemd scripts are somehow buggy.

The really crappy thing is that until I figure out the real solution I can't safely reboot my boxes.

Category: tech, Tags: proxmox
Comments: 3
@ wrote... (3 years, 9 months ago)

I've been making LXC containers in Proxmox like a fiend. I'm toally loving Proxmox, if you want several virtual machines I highly recommend it.

Anyhow, trying to run avahi-daemon in the containers often fails. I'm not the first to notice this but the answers were unsatisfying until I found a suggestion to try running with --no-rlimits. That seems to do the trick!

But how to get systemd to run it that way? Very simply as it turns out.


systemctl edit avahi-daemon.service

Add then in the text editor that opens up, enter the following:

ExecStart=/usr/sbin/avahi-daemon -s --no-rlimits

see comment #2 for a script friendly way to do this


libnss-mdns sometimes doesn't install properly though. If you can't ping/lookup other .local hosts then edit /etc/nsswitch.conf and change…

hosts:          files dns


hosts:          files mdns4_minimal [NOTFOUND=return] dns

If anybody wants to write me an ansible script to do that I would totally buy you a beer.

Too late, I had to write it myself, container.yml.

Category: tech, Tags: linux, lxc
Comments: 2
@ wrote... (3 years, 9 months ago)

At work we have a large project that is comprised of several nested git repos so having your bash prompt get updated with some vital information such as repo, branch, etc makes life much easier.

Here's an example of my prompt and how it shows the current git repo:

[kurt@machine-1 ~/src/foo/bar/baz venv:foo git:bug_branch repo:bar]


Category: tech, Tags: shell
Comments: 1
@ wrote... (4 years ago)

I've recently been wasting time on Empire of Code instead of doing productive and paying work.

Anyhow, the description of the Speed Boost puzzle Landing Holes was the most confusing thing I've ever read.

I'm pretty sure they're describing a Gatling gun. But then mentally s/pipe/barrel/ and s/canon/breach/ and then the description starts to make sense.

As for the function, the first list is a list of barrels, the second is a list of working breaches. The puzzle is asking you for a list of how many times you can rotate the barrels so they align with working breaches.

Category: tech, Tags: Empire-of-Code
Comments: 0
@ wrote... (4 years ago)

Well, I finally released alkali into the wild.

Alkali is a simple database that makes it very easy to specify the on-disk format of your data. This makes it easy to use your existing data files as tables in a database. Plus the api is based off of Django models.

This is my first real project that I've released and it's a surprising amount of work. I have a new level of appreciation for all the libraries that I just blithely download and use without a second's thought.

For instance, it took about the same amount of time to write the docs as it did to write the actual code. Plus there are a lot of moving pieces to release open source software the right way.

  • use git as your source code control
  • write documentation, learn Sphinx and reStructuredText
  • when you push to github, triggers are fired
  • push release to PyPi, writing setup.py is very non-trivial, learn how that works
  • try to do some marketing on Reddit. Given my zero karma I suck at marketing and/or programming.

So yeah… please go check out alkali!

Category: tech, Tags: alkali, python
Comments: 0