Setting up shop, proximity mines and Dokku

I decided to bite the bullet and get myself an actual server on the internets to host my thingamabobs, and here I write about my experience.

I was pointed to Digital Ocean. $5/month/server for a 512MB an actual VPS on an SSD (actually, $0.007/hour since you can turn your server off and on), not bad!

But that's not all!

Like other server providers, they let you create servers with pre-installed software like WordPress, and Dokku. Wait, Dokku? What’s that?

In the words of a friend:

I set one up at cloud.example.com. Then I git pushed a Go web app to cloud.example.com:goapp and it was up and running at goapp.cloud.example.com.

That sounds fun! So I decided to get my old WebMines game running with Dokku, and all it took was one change to the code (I had host the server on the port specified by the PORT environment variable), two files

requirements.txt (naming the versions of libraries I’ve used)

Cheetah==2.4.4
CherryPy==3.2.4

and Procfile (pointing to the name of the main file),

web: python webmines.py

and two commands:

git remote add dokku dokku@server.ip.address:webmines
git push dokku master

And done! My terrible, three year old long-polling-based Python-powered incomplete minesweepers game has a place on the internet, and when I want to update it, all I have to do is another git push. Be warned, it’s occasionally broken and doesn’t include a concept of points/success/failure.

WebMines screenshot

Multiplayer Minesweeper!

As for hosting static pages like Plotter and Automa, all I had to do was make sure the main page was called index.php, and dokku figured out it was a php application and set up an ngnix server for me. This makes me very happy because it means I get to continue my run of never having have to learn how to actually set up a web server properly.
P.S: Once I get a bunch of my things up and running, I’ll probably do a post about it. Or just make a page for them and post about the page. Or maybe a post about how much I’m annoyed that NodeJS’s API has changed so much in three years that I basically have to rewrite half of everything I made back then, but how it’s really my fault for not keeping track of which versions of which modules and nodejs runtimes I was using for which app. *grumble*

Removing dead files from iTunes

So, I made a blog. Mainly so I have a place to put my things. I used to have a website which I meticulously handcrafted and put all my stuff on, but it got wiped from the internet and now I’m significantly lazier, WordPress is a much more attractive option.

Without further ado, I begin the reverse chronological journey through the catalogue of Crap I Made with an underwhelming but still kind of useful entry: an AppleScript which goes through whatever songs you have selected in iTunes and removes any which don’t actually point to any files.

Here’s the gist. My first Applescript! Hacked together from various bits and pieces on The Internet. And because I feel it will make the blog post look nicer, I’ll put the code here too:

tell application "iTunes"
	set selectedTracks to selection
	repeat with i from 1 to (length of selectedTracks)
		if class of item i of selectedTracks is not shared track then
			tell item i of selectedTracks to set {loc} to {get location}
			if loc is missing value then
				tell application "iTunes"
					delete item i of selectedTracks
				end tell
			end if
		end if
	end repeat
end tell

And here’s a python script to accompany it which goes through all your subfolders and deletes the newest of any two files which have the same name except for a different extension.

Can you guess what I’ve been doing today? That’s right, failing to import things in to iTunes properly and then writing code to patch up my mistakes. Could I have combined the two scripts in to a single applescript which actually does the job of hunting for duplicates and deleting the newest? Probably, yes.

Edit: want easy access to that AppleScript, or indeed any script for iTunes? /Library/iTunes/Scripts. Create the folder if it doesn’t exist already, then it’ll show up in a funky little scripts menu in the menubar.