Groovy

Reusing threads and objects via ThreadLocal

Threads in Java are expensive – they require allocation of large blocks of memory, are tracked via descriptors which have to be created and maintained by the JVM, and require numerous system calls to register the thread with the underlying operating system. Thread pool executors help solve this problem by enabling developers to create and maintain thread pools which re-use threads as the executor responds to queued work. This thread re-use enables quicker turn around on submitted jobs to the executor without resource overuse by the system.
Read more

A concurrent, Groovy thread ripper

This was a fun bit; using Apache Tika to detect MIME types of files on your machine with little code and effort. The script takes a location, the root location from which to recurse, and generates a set of absolute paths to scrutinize. It then establishes a latch equal to the size of the set to block reporting until the analysis is complete. The script then iterates through the absolute paths, submitting jobs to the executor for processing, which each hold a reference to a thread safe map and counter object use for tallying.
Read more

Face identification with AWS Rekognition

Cloud AI/ML as a Service (AI/MLaaS) has been all the rage the last few years as we’ve seen major advancements and areas of expertise develop around services offered by Google, Amazon, and Microsoft. This commoditization of AI/ML-centric services has allowed businesses and integrators to take advantage of these services with very little investment. They allow users to: classify images extract subject(s) and topic(s) from bodies of text translate speech to text while identifying multiple parties track people in videos …and more with just an account, credit card, basic know how and the will to do so.
Read more

Home Network Monitoring

Every once and a while my Comcast-based cable service gets into a little bit of a wonky state. It works, but then, it does, but then it does, but then it doesn’t… I’m sure it’s probably a unique experience. Anyway, when it does, I’ve found that I have nearly no leg to stand on when citing ICMP response times, download rates, and cable modem stats and events over time. All I can give the “support staff” is what’s happening now.
Read more

Groovy Snippets: Face detection with OpenIMAJ

Building on the previous post, this snippet leverages concurrent execution and OpenIMAJ for facial detection and analysis. OpenIMAJ implements types a variety of facial detection algorithms in its library. For this exercise, we use the: HaarCascadeDetector Frontal Keypoint Enhanced, which wraps the HaarCascadeDetector The results of the script were used to narrow the possible matches within the dataset prior to execution, leveraging cloud infrastructures. #!/usr/bin/env groovy @GrabResolver(name='OpenIMAJ Maven Repo', root='http://maven.
Read more

Groovy Snippets: Content detection w/ tika

A few months back I had to process a few million, a few terrabytes of assets that were missing content extensions. I needed to filter the assets so that I could stream assets that were images to 3rd party provider’s API for further analysis. Rough estimates for the number of images in the few million assets came out to no more than about an 1⁄8. Fortunately I had access to the data on a particular machine and used Tika to quickly zip through the assets and identify those that met my required content types.
Read more