This Time Self-Hosted
dark mode light mode Search

Patching up a monster of frankeinsteinian proportions

I’ve spent the first week of the year on vacation with some friends. The second week of the year has been mixed between going on with the jobs I should have gotten working already, fighting a bad case of cold, and getting insulted by a customer of mine for actually having gotten real vacation time for once in two years. More to the point: said customer doesn’t actually pay me overtime, or actually at all for the support.

Tonight I wanted to relax and think about my own needs. Not personal needs, alas, but at least needs for my work to become easier. Since I haven’t made any progress at all regarding RT I decided to look into a different need of mine: cataloguing customers’ computers.

I originally simply kept a file listing the computers I set up for customers — then I started getting more customers, and sometimes getting a computer back after many months since last time. And I started forgetting which computer was which. Nowadays I have 79 computers on my “database” (which is just a git repository with a bunch of HTML files as well as lshw dumps), without counting those that have been dismissed.

To recognise the computers, I started printing labels with a QR Code on them, which contains the URL of the computer’s HTML file on my website (password-protected). My original method required me to feed a multi-label A4 sheet into my laser printer and print one, two or three labels out on that… but it turned out to be a waste of time and of money in sheets, given that most of the time I ended up wasting half of it, as the printer refused to print aligned more than half the time. I’ve since bought a Dymo label printer, which is why you’ll find their drivers in Portage maintained by yours truly — the nice thing about Dymo’s label printers is that their drivers are fully GPL-2, while as far as I can tell both Zebra and Brother have binary blobs, that make them unsuitable for use on amd64-based systems.

As you can tell, there are a few things that I did in Gentoo that relate to this little “database” of mine: the lshw fixes to try getting it back into SysRescueCD (it’s still not there — and I lost the password for my account on their forums), the Dymo drivers noted above, and dev-ruby/barby which is a quite interesting library that allows you to generate almost any kind of barcode. And now it’s time of MongoDB Ruby libraries as I’m trying to write an actual web application to manage the “database” and make it a real database.

Today’s achievement is big: I finally got Rails (3.1) to play nice with MongoDB. Not using MongoMapper, the author of which, as I already talked about I would prefer not having much to discuss with. But thanks to Mauro I got pointed at Mongoid which is a much more well developed alternative.

Okay sure there are quite a few things to kink out in the packaging of Mongoid – for instance the fact that the gem packages a Rakefile that relies on a (missing) Gemfile, or the fact that two out of three rspec targets in said Rakefile fail, one of which by crashing the interpeter – but at least their unit-tests work, and the code works as intended when loaded it up. Which is more I can say about MongoMapper.

Oh and it doesn’t seem to require extra code to be added just to work correctly with Passenger.

The only problem I have now is fixing up one side issue: how do I print the labels once I load this into my webserver? I could download the PDF I use to print the label and then print that.. but it’s a bit of a time-waster. Of course both the server and Yamato (where the label printer is connected) are IPv6-enabled and .. well, the IPP protocol used by CUPS is fine to be used over the internet, as it can use SSL encryption. Which yes, means that I’ll be setting up a web application … that calls home to print a label, how crazy is that?

My only issue with this is that I’d rather not install cups on the webserver (especially since there is currently no way to just build the client side of it, which would be the only part of it I would need on the server — yeah I know, it’s funky), so I can’t just call lpr mylabel.pdf… and as far as I can tell, the only way to access IPP from Ruby is one of the many CUPS library bindings available as gems, which are all 0.0 versions, and do not inspire me the least. Since IPP is based off HTTP, I would have expected more implementations of it, to be honest.

Possibly, it should be possible to extend some HTTP Ruby library to send IPP requests as well; for what I’m concerned, I’d just need the “Print-Job” method to be implemented, which would allow me to send the PDF file to be printed with the default options. I guess I’ll resolve that bit once I’m done with the rest of my application, though.

Comments 10
  1. It looks to me like you are going for a solution that is far more complicated than your needs. If all you need is a means of identifying the computers and get their respective information up on a screen, printing id numbers and entering them by hand may prove to be more cost-effective. (even if it is not nearly as fun)

  2. There is a factor of “RuleOfCool”:http://tvtropes.org/pmwiki/… being invoked here for which there is a functional reason: customers have to be wowed.So while I could just use a progressive identifier, that would look bad (too few counts), and at the same time it wouldn’t be as cool as getting my phone near the box and identifying it from there. Of course this also means they can’t phone me with an identifier (yet), but the marketing power of these labels is quite high..

  3. I’d love to see a blog post about using IPP from Ruby in case you make any progress; I’ll probably have to do something like this soon as well. 🙂

  4. While it is indeed a certain feeling behind being able to handle things with little effort from any place for any reason, that does not prevent you from taking the best from both worlds.The id number does not need to be progressive, and if progressive, does not need to correlate to a number which breaks said coolness. If you start your progressive number at a position with enough inspiration, (say 1733 or so) or make use of a non-progressive display of a progressive number (say, print the number as a short hash-sum, or as hexadecimal numbers with an offset) you could complement your current functionality with the more traditional ID numbers thus allowing a phone call to give you the needed data.So amaze people when you can, but don’t forget that a simple backup solution could have it’s value.Just some thoughts from the purely functional aspect of things, I never cared much for marketing.

  5. Actually I did implement something like that now that I’m using MongoDB: the ID number is “hashed” enough that I can print it on the label beside the QR code (it was always formatted to have the space for that) so it can be entered by hand (or given on the phone) for me to look up the computer.But the QR code is just too good for marketing — people remember me because of that, and that means more calls, more work, more money to pay the bills.I used not to care… but when the bank frowns at your account… you start to.

  6. Honestly it’s much quicker, for me, to use IPP (CUPS) over IPv6: I don’t have to initiate an SSH connection, while encryption is performed by CUPS itself.The only part that I’m not much happy about is the fact, as I said, that I have to rely on the CUPS client software on the server,w hile I should have been able to just send the document I need printed through IPP by Ruby.

  7. I understand why you don’t want to have CUPS on your server. But having CUPS is not entirely bad. You gain autonomy and failure tolerance, because your local CUPS will have it’s own spooler and can retry jobs until they succeed.

  8. Uh, no you misunderstood. I’m now using the CUPS *client software* but no way on Earth I’m going to run a CUPS *daemon* on my vserver! The fact that we don’t have a split client CUPS is bothersome already, but in general since I just need to pass a PDF to an HTTP-like server, I’m not very happy to keep around a library to do so.. CURL should work just as well!

  9. instead of having a sequential id, i found very handy have a pseudo random id (i also use qrcode label).Customers don’t know how many are, don’t try to guess serial, and i’m sure i can’t mess up with serial.I’m using uniqid() that basically encode epoch, then i’m sure that i never have the same number.You could make your epoch time starting 2012, for example.thanks for naming lshw is very handy command!Regards,M47730

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.