in Hacker School

Hacker School Day 8 – Youtube to Gif in Go, Apache Spark

It’s been very busy at Hacker School and I couldn’t write at all yesterday. I started working on writing a site in Go for converting Youtube videos to gifs. I’ve had a bash script for this for a while, but it’s a pain to use ImageMagick to crop on the command line. I’m trying to make a site where I can drop some Javascript on for cropping. I had thought about doing this a while ago, but I noticed this book on HackerNews the other day and couldn’t resist.

I hit a whole slew of errors, since I haven’t touched Go in a while and normally keep myself in the CLI world. I had some fun trying to parse form bodies. This post was excellent:

I was getting annoyed with re-building the file after every save, so I hacked together a terrible inotify line:

inotifywait -e close_write -m youtube-gif-go.go | while read line; do pkill -QUIT -f ‘go run’; pkill -f ‘/tmp/go-build’;  go run youtube-gif-go.go & date 2>&1; done

I decided to throw Redis at this project too. Even though it’s just a toy project and the filesystem would work fine, it seemed like a good idea to get it under my belt. I got a very basic pubsub-powered model working yesterday. I’m working on the API first and plan on making the website a consumer of the API. Right now, after POSTing to /gifs:

  1. It’ll return HTTP 202 (Accepted)
  2. Throw the URL into Redis
  3. Publish the URL and ID serialized into JSON over the “download-queue” channel
  4. A separate Go script waiting on events on that channel begins work on downloading it
  5. When finished, resends info to the “chop-queue” channel. The same process continues for the “stitch-queue” channel

Splitting up the processes means I could potentially move each of these processes to different machines that had better specs to deal with their process. I have a lot to do and probably won’t be able to present anything tonight.

I bought an adorable notebook from Muji that I’ve been keeping notes in. I started writing down some information about fuse-colors, after spending some time talking with Jessie Luehrs and Tom Ballinger about ideas for it, including some PTY trickery that I now need to include in the pro/con list.

This post is going all over the place time-wise. Last night I went to a meetup about Apache Spark with Nicholas Chammas, Waldemar Salinas, and Rob Moore. It was at Bloomberg, which is an incredibly nice building. The talk was great, and I plan on pairing with Nicholas to learn more.

Write a Comment