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

It turns out that after I imported a bunch of databases from mysql all the ownerships were wrong so any future django migrations would fail.

Based on this stackoverflow.com answer I made a quick script to mass change several databases and its tables all at once.


Category: tech, Tags: database
Comments: 0
@ wrote... (6 years, 7 months ago)

I'm in the process of merging databases with identical schemas. This will cause primary key collisions which one generally wants to avoid.

So there are a few things you have to do:


Category: tech, Tags: database
Comments: 0
@ wrote... (6 years, 7 months ago)

I kept getting Incorrect string value warnings when trying to import UTF-8 strings into Mysql. It turns out that Mysql has pretty questionable utf-8 support as seen from this stackoverflow.com question.

Well enough was enough so I decided to migrate some datbases to Postgresql. Here are some notes/scripts that helped me.


Category: tech, Tags: database
Comments: 0
@ wrote... (6 years, 8 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... (6 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... (6 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... (6 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... (6 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... (6 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... (6 years, 10 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