Abhay Rana aka Nemo

Home Server Build

I’d been planning to run my own home server for a while, and this culminated in a mini-ITX build recently. The exact part list is up at https://in.pcpartpicker.com/list/krc8Gf.

In no particular order, here were the constraints:

  • The case should be small (I preferred the Elite 110, but it was unavailable everywhere).
  • Dual LAN, if possible (decided against it at the end). The plan was to run the entire home network from this directly by plugging in the ISP into the server.
  • Recent i3/i5 for amd64 builds.
  • Enough SATA bays in the cabinet for storage

The plans for the server:

  1. Scheduled backups from other sources (Android/Laptop)
  2. Run Kodi (or perhaps switch to Emby)
  3. Run torrents. Transmission-daemon works. Preferably something pluggable and that works with RSS
  4. Do amd64 builds. See https://github.com/captn3m0/ideas#arch-linux-package-build-system
  5. Host a webserver. This is primarily for serving resources off the internet
    • Host some other minor web-services
    • A simple wiki
    • Caldav server
    • Other personal projects
  6. Sync Server setup. Mainly for the Kindle and the phone.
  7. Calibre-server, koreader sync server for the Kindle
    • Now looking at libreread as well
  8. Tiny k8s cluster for running other webapps
  9. Run a graylog server for sending other system log data (using papertrail now, has a 200MB limit)

No plans to move mail hosting. That will stay at migadu.com for now.

I had a lot of spare HDDs that I was going to re-use for this build:

  1. WD MyBook 3TB (external, shelled).
  2. Seagate Expansion: 1TB
  3. Seagate Expansion 3TB (external, shelled)
  4. Samsung EVO 128GB SSD

The 2x3TB disks are setup with RAID1 over btrsfs. Important data is snapshotted to the other 1TB disk using btrfs snapshots and subvolumes. In total giving me ~4TB of storage

Software

Currently running kodi-standalone-service on boot. Have to decide on a easy-to-use container orchestration platform. Choices as of now are:

  1. Rancher
  2. Docker Swarm
  3. Shipyard
  4. Terraform
  5. Portainer

Most of these are tuned for multi-host setups, and bring in a lot of complexity as a result. Looking at Portainer, which seems well suited to a single-host setup.

Other services I’m currently running:

  1. elibsrv. Running a patched build with support for ebook-convert
  2. ubooquity for online reading of comics

Project Updates

Over the last couple of years, I’ve been involved with lots of side projects, both online and offline. Some of them, I’ve written about on the blog, like my music visualizer project. A few of them, got their own project page, like the website for my niece (but no blog post) while some didn’t even get a mention. I thought I’d write about the many-many side projects I’ve started (and abandoned). You might also wanna visit the /projects page for the larger projects.

Sushi Go
Summer 2017 This is a work-in-progress conversion of Sushi Go (original), the popular card game by Gamewright into Ruby.
youtube-ripper
June 2017 Downloads music-compilations from YouTube and rips them into multiple tagged MP3 files.
cosmere-books
September 2017 Wrote a EPUB generator for multiple books in the Cosmere. Currently covers 4 different serializations at Tor.com. Also created a project page on all of my ebooks projects at /ebooks/
ideas
Ongoing I maintain a CC0 licensed list of personal ideas. Feel free to use.
spectrumyzer
May 2017 Created an animated wallpaper using spectrumyzer. Wrote a blog post about it.
google-sre
Feb/Sep 2017 EPUB generator for the Google SRE ebook. Started in February in Python. Gave up and redid it properly in September.
CodeChef Offline
March 2012 I attempted to make a offline repository for CodeChef problems. I spent some time in May 2017 upgrading the project with a cleaner scraper and a Jekyll base.
Hoshruba
June 2015 I wrote a script that scraped Tor’s serialized publication of the first book in Hoshruba series to generate EPUB and MOBI files. I would recommend the book if you are interested in reading what many would term the “original fantasy book”
HackerTray
December 2013 - I wrote a Linux PyGTK application that sits in your taskbar using Indicator Applet to show you the latest stories from Hacker News. Looking for a maintainer.
MagicMuggle
May 2017 I wrote a script to convert Magic Muggle (A Harry Potter fanfic about a muggle who accidentally gets into Hogwarts) books from their original reddit posts to EPUB and MOBI files.
Kerala IT Policy
March 2017 Attempted to transcribe the draft IT policies put up by the Government of Kerala. Lots of OCR followed by manual fixes. I stopped working on this when I realized that the government had actually put up a really nice website for this (with clear plaintext, not the bad PDF I was using as the source).
lightsaber
August 2015 I created a DNS based HTTP-3xx redirect service. Useful if you own a domain and you want it to be redirected, but don’t have a webserver with you. Made as part of the Django Hackathon organized by HackerEarth in Ruby.
HackerCouch
November 2015 My hack during hackbeach 2015. Created something best described as “couchsurfing for hackers”. Simple Jekyll/Ruby website hosted on GitHub Pages.

Building the perfect audio visualization

I made this as my animated wallpaper recently (Click to play/pause):

above video has a audio component, click at your own peril.

What follows is the story and the tech behind making this.

The Wallpaper

I have a long history of using custom wallpapers. This was my wallpaper from 2014-:

Old Wallpaper

When I asked Vikalp to design a new one, I knew I wanted something that was slightly more softer. This is what he came up with, after a few iterations:

New Wallpaper

This wasn’t the final iteration, and both of us agreed that there was something missing.

Visualizations

I saw a colleague using cava and spent a bit of time trying out different visualization software. The ones that I tried out:

cava
works perfectly with i3, runs on a terminal. I couldn’t get it to work cleanly with transparency. Cava screenshot using tiling
mildrop
Winamp’s legacy. This works great for parties, but is not really an everyday-use visualizer. Milkdrop Running using projectM on Linux
spectrumyzer
Worked with transparency, but limited to bars visualization.

I decided to go ahead with Spectrumyzer (This is the default config):

Default Spectrum Config

The Traffic Jam

The very same day, stuck in a traffic jam1, I asked Vikalp for some color ideas on the visualization.

The obvious 2 were tried first:

Spectrum Dark Blue Config

Spectrum Yellow Config

It finally dawned on us to use the light blue variant with padding set to zero:

Spectrum Light Blue

Here is one showing the actual positioning (set using the offsets):

Spectrum Offset

Bezier Curves

With the padding set to zero, it already looked great. I ended up using this as my wallpaper for the next one week. Vikalp wanted to make the bars non-rectangular, and I spent some time figuring out how to make waveforms using bezier curves2. The basic learning from my experiments were:

  • Cairo has methods for drawing cubic bezier curves.
  • Cubic bezier curves have 2 control points.
  • The control points must be symmetric (equidistant) as well as parallel to the origin points.
  • The parallel part ensures that the ending and starting line segments are always tangential giving a smooth joining.

This is roughly what you want to do when drawing waveforms:

Waveform bezier curve

If you are interested in playing around with Bezier curves, see Animated Bézier Curves. A Primer on Bézier Curves is a math-heavy explanation if you want to read further3.

The code I wrote picks the midpoints of the bars and then connects them using bezier curves:

# control point cords
# Make sure these are symmetric
c1x = rect_top_mid_x + 16
c2x = next_rect_top_mid_x - 16
c1y = rect_top_mid_y
c2y = next_rect_top_mid_y

I also had to make the number of bars configurable (this is default=64, which doesn’t look great):

Spectrum water 64

Here is the complete final result in HD:

What I learned

  • Bezier curves are not magic.
  • Drawing pixels on screen and filling them was quite easy with Cairo and Python.
  • Coding is wizardry. The things that I take for granted every day (take a multi-page website and get useful tabular data out of it, for eg) are unthinkable for most people. The idea of doing water waves was something I knew would be possible before I even looked at the codebase.

If you’d like to replicate this setup, or build upon it, here is my spectrum.conf file. I also filed a PR (now merged!) to the spectrumyzer project adding support for curve based renders.

  1. Sony World Junction - Where startup ideas are born. 

  2. The Spectrumyzer codebase turned out to be fairly easy to understand. It was just cairo and pyGTK. 

  3. A Primer on Bézier Curves was published on HN just a few days after I finished this project.