Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Linux Linux

OCR on a large PDF using tesseract and pdftk This turned out to be harder than I thought. I found a large (50MB) PDF with about 50 pages, and none of the tesseract GUI's seemed to be able to handle it without crashing. The solution is to convert the PDF to TIFF so that command-line tesseract could handle it directly, but now ImageMagick couldn't handle that conversion as it was running out of memory (even with the limit settings). So the only option was to reduce the load on all the moving parts by splitting the PDF into pages.

Even after splitting the PDF and running each page through the PDF->TIFF->Tesseract->PDF chain I was still having issues:
Error in pixReadFromTiffStream: spp not in set {1,3,4}
Huh? So it turns out that sometimes you may wind up with an alpha channel in your TIFF and tesseract can't handle this. There is a solution, fortunately. So finally, I put all of these steps together into a script: Continue reading "OCR on a large PDF using tesseract and pdftk"

DevOps Java Java Linux Linux

Running Jenkins Swarm client as a service via Upstart»
This turned out to be fairly simple, with only one gotcha: do not follow the how-to's out there that tell you to use expect fork . The process doesn't technically fork. When I had that setting enabled, upstart commands would hang under very specific but repeatable conditions (if the process was killed externally). So, here is my upstart conf file:

DevOps Linux Linux

Docker: Automatically remove containers that have been running too long»
Why Because my Jenkins setup sometimes starts containers and forgets about them. Either it thinks it failed to start one, or the container itself has trouble starting. Either way, I'm left with containers that are running, trying to connect to Jenkins in vain, forever. The proper way to fix this is probably to have the containers timeout at some point, but that mechanism is broken . ...

Automotive Automotive Hardware Hacks Hardware Hacks

Odometer Reprogramming - Nissan Sentra»
Disclaimer : It is perfectly legal to program an odometer to represent the correct mileage for the car. Problem: The car is a 2006 Nissan Sentra 1.8S . The instrument cluster is probably at fault for the intermittent overdrive flipping (on and off) that I've been experiencing. I ruled out the rest (switch, TCM). Thus, the cheapest option is to swap in another one , but that ...

DevOps Linux Linux

Jenkins command line ssh: Host key verification failed despite ssh-agent»
After hours of "Why does it work locally but not in Jenkins", this error boils down to StrictHostKeyChecking... In other words, since the job runs as a user on a random slave, and this user most likely doesn't have a known hosts file with an entry for the target system, this fails rather cryptically. You think that the user's keys don't work, but that's not the problem. The whole ...

Low Tech Hacks Low Tech Hacks

Replacing batteries in a Philips Norelco T980 Turbo Vacuum Trimmer»
I bought this trimmer in 2008 and the NiCd batteries finally died in 2016 - not bad. Still, no reason to trash a working trimmer and contribute to the landfill problem. As it turns out, it's fairly easy to disassemble, and even easier to reassemble. So here are the steps, which probably apply to many similar models.

Low Tech Hacks Low Tech Hacks

Replacing batteries in a Sonicare Elite toothbrush»
I've had this toothbrush for over a decade, and the batteries finally died. I suppose that's a long time for NiCd cells to last. For the last year or so the toothbrush would not complete the 2 minute cycle but would instead stop sometime earlier. The batteries are clearly still alive but simply don't have enough capacity. The toothbrush is not designed to be opened (it is ...

Linux Linux

Ubuntu 15.10: Handling Dell Latitude laptop dock events to reconfigure displays»
Couldn't find any good solutions out there. I have a Dell Latitutde E6410 running Ubuntu 15.10 with XFCE (no Gnome or KDE). I use a physical docking station that allows me to use two external monitors. Ubuntu doesn't seem to understand that if these external monitors vanish, it should switch to the monitor that remains (built-in LCD), and vice versa, so I have to automate it myself. ...

Code and Hacks Code and Hacks DevOps

Marking Jenkins build UNSTABLE from environment inject groovy script»
The way we use the Jenkins "Prepare an environment for the run" feature of the Environment Inject Plugin is this: we use the "Evaluated Groovy Script" to retrieve some info from a successful run of some other job (svn revisions, environment vars, whatever) in order to make it available to the environment of the current build. But what if that other job hasn't run successfully (yet)? I'd ...

DevOps Linux Linux

Migrating Maven Jenkins jobs to FreeStyleJobs due to JDK 1.6 incompatibility»
Soon after Jenkins 1.609.1 support for JDK 1.6 was dropped altogether. This means that you can run jobs with whatever JDK you want as long as you are not using the Maven job type . Maven jobs require JDK 1.7 or higher (actually they run on whatever version the master is using, ignoring the JDK setting in the job configuration). This is a big deal for a shop that does extensive ...

DevOps Java Java Linux Linux

Jenkins: Bulk editing jobs to remove a trigger»
I have about 200 jobs that have the HudsonStartupTrigger (this is a plugin) turned on. This makes all of them run every time the master is restarted, causing the build queue to go crazy. I don't know why people turned this on in so many jobs (probably blindly copying jobs) over the years, but I'd like it gone. I don't want to restart the master or uninstall the plugin. Here is a ...

DevOps Linux Linux

Suse11 cannot mount NFS share»
This is a recent issue on Suse 11.3. I have hundreds of machines mounting the same share fine - Centos, RedHat, even AIX. mount -v /mountpoint mount.nfs: timeout set for Wed Dec 9 11:09:27 2015 mount.nfs: trying text-based options ...

DevOps

Puppet: recursively delete a Windows Registry key»
Puppet forge has a registry provider that allows one to manage a key or value. What it cannot do is delete a whole tree starting at a particular key. So, hacks to the rescue:   # deletes the whole tree if it exists   define registry_wipe_tree ( $key = $title ) {     exec { "Purge registry $key" :       ...