Spotify Scannables

For my ‘sister project’ I had the idea to print physical albums for virtual Spotify albums. It works using the ‘new’ Spotify barcodes. Read the original blog-item.

My first attempt to create these was a very manual approach: I made a screenshot from Spotify on my phone (the only place where the barcode is shown), cropped the code, pasted this in a Pages-file (the Apple-equivalent of Word) and added an album cover + tracklisting I found on Wikipedia. This would take over half an hour per album!

Automatically creating album-covers with a Spotify code

In my 2nd attempt I tried to script as much of this process as I could. In addition, I decided to skip the tracklisting (keeping just the cover + Spotify code).

This means I no longer needed to print double-sided. Which in turn meant I can have the covers be printed as ‘square photos’, so they look great now!

Bash-scripting

I had to dust-off my scripting capacities and my first attempt went a bit ‘overboard’. I created a script that:

  • automatically cuts the Spotify-code, the album-title and artist-name from an Android screenshot, using GraphicsMagick
  • uses Tesseract (an OCR-engine) to parse the album-title and artist into text
  • asks the user if the OCR was done correctly (with the option to provide a better album/artist)
  • uses Glyr (a metadata search-engine for music) to get a load of album-covers
  • finds the best-looking album-cover (approximately, using filesize) using the artist/album from the previous step
  • pastes the Spotify-code on top of the album-cover (in two versions: with the code either in the left or right bottom-corner)

Which worked GREAT! Except that all albums returned by Glyr were kind of ‘meh’-quality. I introduced several improvements, but in the end it never was ‘great’.

You can download v1 here to play around with.

Version 2 of the Bash-script

I took my losses and re-examined my options. I found that the resolution of the cover in the Android-screenshot was actually a lot better than whatever Glyr returned. So I greatly simplified my Bash-script. Now it only:

  • automatically cuts the Spotify-code and the cover from an Android screenshot, using GraphicsMagick
  • pastes the Spotify-code on top of the album-cover

Optionally, you can enable Tesseract to have a cool filename as well.

Ofcourse v2 is also available to play around with.

The end-result

Here’s some example albums. You can scan them with Spotify (on mobile: tap ‘search’ and then the ‘camera’ in the search bar).

Adele - 25 Anouk - Fake It Till We Die Fleshgod Apocalypse - King

Generating JPG

If you plan to do this as well, you’ll you need to convert the PNGs to JPG before you can print them, which is easy with GraphicsMagick:

for f in result/*.png; do gm convert $f -unsharp 2x0.5+0.7+0 $f.jpg; done

This adds some sharpening as well, which looks a bit nicer when printing IMHO

Bitcoin and Monero

When I first heard about Bitcoin (8 years ago), I thought it would pass. It didn’t and I’m one of those suckers who’s thinking “why didn’t I just get a couple when they were worth nothing…“

But, better late than never!

Bitcoin

I wanted to learn more about Bitcoin, so I bought a small amount and lo-and-behold: it got transferred into my wallet. A couple of hours later on Wikipedia/Youtube and I think I’ve got a pretty good idea how it works.

That’s it for Bitcoin, it’s too established to really do something ‘interesting’ with it (or invest in it, IMHO).

Monero

Monero is an alt-coin, which is constructed in a more privacy-concerned manner than Bitcoin. But that’s not the reason I got interested in it; The other interesting property is that the coin is designed so that ‘mining’ is more CPU-friendly.

For Bitcoin, the best mining happens on specifically designed machines (ASICs) and 2nd best happens on GPU. For Monero, it’s still possible to do decent mining (generating random hashes) on a CPU.

Which is interesting for two reasons:

  • I get to play around with it (I have an old GPU, but a decent CPU)
  • the naughty people online can steal your processing power with javascript to generate coins

The latter reason is why I think Monero has a shot towards becoming a viable coin as well 😁

Mining Monero

After about an hour I managed to compile both the GPU and CPU miner for Monero on OSX. Now I could find out for myself the Hash-rate difference between CPU and GPU!

Interestingly, the GPU miner completely locks up my computer but spits out a rather disappointing 10.5 H/s (NVIDIA GeForce GT 650M 512 MB).

As expected, the CPU fares a lot better: 37 H/s per core! My i7 has 4 cores, so if I leave one for myself, I get a nice 111 H/s without locking my computer up. According to the Monero IRC my processor would fare even better on Linux/Windows because of optimization in xmr.

Mine for yourself

If you want to join the cool kids and mine some Monero, you can do so on my blog, just press the button:

0 hashes per second

my computer averages 60 H/s in javascript, higher is better! To stop mining, simply refresh the page

Send me some e-dough

If you like, you can send me some Monero:

45wPmJdbfy6ALtNBQPbgMBEdmzA6KrhRGdgKUJ4wqXSdg5Nm77qxrPzNQRr7vXok4HCXQqYCYbtaBAFMb6iujU45T7wxYSs

For sending me Bitcoin, let me know and I’ll generate you a link 😇

Blog now in Git

Here’s something that was on The List for a long time: adding this blog to a git-repository. Why did that take so long?

I wanted to have my own, personal git-server instead of GitHub to push stuff to, so I can have a post-hook do cool stuff like auto-deploy the website. That is possible with GitHub as well (if you pay for it), but I thought it would be ‘fun’ to play around with all this 🤓

My workflow used to be:

  • write article & jekyll serve
  • when satisfied: do a complicated rsync-command (hidden behind an alias)

My new workflow:

  • write article & jekyll serve
  • make commits while writing
  • when satisfied: git push

My server then checks out the most recent commit, runs jekyll build and rsyncs the new items. Since that all happens automatically it’s a lot less fault-sensitive.

You are now reading the first article published with git push 😇. Currently only matth-ijs.nl works like this, but in the near future I’ll port 1001ideas.org as well.

My setup

I’ve installed both git and jekyll on my VPS and added a new user there (git). In the home-folder of git I’ve setup blank repositories for all my projects (like this site). On my local machine I created a new RSA-key specifically for the git user (not strictly necessary, but I was in an experimenting mood).

I then created a new repository for this blog locally, added all files and set the origin to the server. Done!

Steps

Remote:

  • in the home-folder of your git user: git init --bare <sitename>
  • add script to the hooks-folder (see below)
  • make a var/www/<sitename>/public_html which is owned by the right user
  • add virtual-server for Apache for that folder

Local:

  • git init in the right folder
  • git remote add origin <ssh-credentials>:<sitename>
  • git push --set-upstream origin master
Script
#!/bin/sh
site="1001ideas.org"
mkdir /tmp/${site}
rm -rf /tmp/${site}/*
git --work-tree=/tmp/${site} --git-dir=/home/git/${site} checkout -f
cd /tmp/${site}
jekyll build
rsync -av _site/ /var/www/${site}/public_html/ --itemize-changes

Matth-ijs.nl recommends...

I’ve got a rather peculiar taste; apparently I’m a “Harbinger of Failure”* - someone who likes things the general population doesn’t like 😇

In other words: the kind of stuff Netflix and Spotify don’t recommend. The goal of this project is that others with similar tastes (other Harbingers of Failure) find my blog and discover new stuff to try out!

So check it out: Matth-ijs.nl recommends! Of course, there’s also an RSS-feed.

*NOTE: I should get a t-shirt of that.

Now running my own VPN and PiHole

During my “nerdy-hour on Sunday” I installed OpenVPN on my home-server :)

Installation was a breeze (using this guide), with the following caveats:

  • the IP-address you use in step 1 if you’re behind a NAT-router is NOT your external IP, but rather the IP of the server you’re installing VPN on
  • the installation script has some oddities: it sometimes writes a number instead of a value (the script for instance asks: “Which protocol do you want to use: 1. UDP, 2. TCP” and instead of writing proto=udp it writes proto=1). So double check your server.conf and client.conf)

Even easier was installing PiHole for capturing all ads- and tracking-code (using this guide). I’ve left most settings as-is, but I also block facebook.com to stop ads from appearing in my PodCasting app (added bonus is less procrastination).

So that’s it! No more ads on my devices, safe internet on public WiFi and always the Dutch selection of Netflix.

By the way, running Bungie on Ubuntu right now and that’s a very pleasurable experience. Recommended!