Serializing and scoping Mongoid criteria

So, while working on a project, I ran into a snag. I’ve got a partial which renders a list of images, and I want that partial to be auto-updated. That partial is used in multiple controllers and actions and is passed lots of different arbitrary data sets. How do you manage auto-updating that partial, and additionally, gain the ability to access that list’s criteria in other areas? I also have a ‘grid view’ of the images – I want to be able to pass my image list along to that and have it render it, but I still want to paginate (and on the grid view, pagination is done by different amounts).

Mongoid lets us build (much as ARel lets us do in ActiveRecord) criteria up, which consist of a few things, but mostly a selector (“Which records?”) and options (“How do you want them?”). So the answer is actually pretty straightforward – we serialize these objects and then use them to build our base criteria, on which we can then do pagination. Neat, right?

So, how do we do this? Easy, actually. Continue reading Serializing and scoping Mongoid criteria

Perceptual image and audio deduplication

Okay, two months without a post, won’t happen again…

So, lately I’ve been moving out from the broadcast area and getting back into webapp development, but some of the things I’ve been working on touch quite heavily on deduplication, of images and music. This is quite an interesting topic, so let’s have a look at what we can do now.

Doing exact deduplication – stopping someone uploading the same file twice to a website – is pretty easy. You just hash the uploaded file (or de-encapsulate the data and hash that if you want to be a little more resilient) with something like SHA256 or SHA512. It’s fast, effective and easy. Lookups are as fast as your RDBMS is. This works with images, audio, videos, you name it.

What’s much harder is doing perceptual deduplication, or content deduplication. If I upload two files which are the same except one’s a PNG and one’s a JPEG, I want to be able to say “Hang on, you’ve already uploaded that!” when you upload the second file. Similarly, what if we resize an image? We want something resistant to that sort of attack. Continue reading Perceptual image and audio deduplication

IRIS – The Interchangeable Radio Ingest System

Well, wow. After nearly forgetting to actually submit it and only writing the entry a few hours before the deadline, it turns out that the system I made while at Insanity Radio 1287AM has been nominated for the Best Technical Achievement award at the Student Radio Awards. So, I figured it would be worth actually writing up a little bit about what it is and what it does. And why you can use it, too, if you’re involved with a student radio station.

IRIS was written to replace MACIS, a system I bodged up out of necessity. At Insanity, we had a computer failure weeks before we went on air at the start of the first term, and lost all the data- including the entire playout system. Lessons have been learned (I made sure we replaced that machine with a box that had RAID, for starters) since, but we had the unenviable challenge of repopulating a student radio playout system from scratch with little to no staff. Enter MACIS!

Continue reading IRIS – The Interchangeable Radio Ingest System