Programming

Checking Pwned Passwords for a Password Offline

Perusing ArsTechnica a couple of weeks back, my eye was caught by this article about a recent dump of emails and password circulating on hacking forums, referred to as Collection #1. Collection #1 is a collection of 773 million unique email addresses and 21 million unique passwords thought to be an amalgamation of several historical hacks but also containing around 140 million email addresses not previously seen in dumps like this. 

Processing a Text File in Perl

Loading a text file, processing the contents, and outputting a processed version of the file is a common task in Perl.

Sometimes it's light processing: rearrange the order of parts of each line. Sometimes it's heavier processing: collect a bunch of statistical data from the file and output a summary of the data with averages, mins, maxes, etc. In either case the following template is a handy starting point that shows the loading, some light processing, and writing the results to the output file. 

Creating aliases in the Cygwin Bash terminal

If you work in a Cygwin Bash or other Linux terminal regularly, it's handy to have short hand for certain commands you execute a lot. E.g. you can navigate to the path "C:/cygwin64/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads/Text"  by typing cd followed by that entire path. But what if you need to do that 100 times a day, or just keep forgetting the full path? Wouldn't a shorthand for that be great? 

Pixel Format Conversions

I recently found myself having to do a few interesting conversions in C++ to pass images between different formats and/ or libraries, including OpenCV, MATLAB, and some unusual custom formats. I'm going to post some code snippets here that do some of these conversions as I suspect they may be useful for others.

 

Keep in mind that, generally, image data is always stored in one long array, and you have a pointer to the beginning of that array. So, the question is, as you increment your way through the array contents, in what order are you traversing the image's data? E.g. are the first three elements the RGB values of the first pixel in the top left corner of the image? Or are they the R components of the first three pixels moving right along the top row of the image? Or something else entirely?