This mistake has caught me before, but I always overlook it: https://github.com/lindenb/magic/issues/1#issuecomment-54685236
Author Archives: alexpreynolds
Old school GNU glue
Say we have a bunch of text files each containing a column of non-negative numerical values that we want to log-transform (base-10): for i in `ls *.txt`; do echo $i; awk ‘{system(“calc \”log(“$1″ + 1)\” | sed -e \”s/^[\t~]*//\””);}’ $i > $i.transformed; done Slow, but it seems to work in a pinch.
Platform-independent methods to get number of available cores and/or processors with C/C++
See: http://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine
Adding same-sex marriage law data to a d3-cartogram
Shawn Allen wrote a d3.js-based implementation of a 2D cartogram, which sizes US states in an area-proportional manner, where area is based on some interesting statistic, like population. There has been a great deal of progress made in the last year in defending the rights of GLBT Americans to marry and have their partnership rights […]
matrix2png -to- matrix2pdf
For scientific work, I have used matrix2png to make a nice PNG image from a text-formatted matrix of data values. PNG looks great on the web, but it doesn’t translate well to making publication-quality figures. My thought was to take matrix2png and — with the help of Haru (libharu) — turn it into matrix2pdf. Maybe I […]
OCR resources for iOS
Here are some useful resources for open source C and C++ -based OCR libraries that could run under iOS (need to check licensing): Seven Segment Optical Character Recognition (ssocr) Advice for 7-Segment Display OCR with Tesseract Tesseract OCR iOS library The end goal is to be able to use an iPhone to read LED displays, […]
Regression testing of SHA-1 signatures via command-line
I wrote a data extraction utility which uses PolarSSL to export a Base64-encoded SHA-1 digest of some internal metadata (a string of JSON-formatted data), to help validate archive integrity: $ unstarch –sha1-signature .foo 7HkOxDUBJd2rU/CQ/zigR84MPTc= So far, so good. But now I want to validate that the metadata are being digested correctly through some independent means, […]
Selecting a new gcc version installed via MacPorts
MacPorts is useful for installing a variety of command-line utilities and programs for Mac OS X. There are others, e.g. Homebrew. After using MacPorts to update a GNU gcc installation, it is useful to select the new revision. Tips were posted to this Stack Overflow thread. Basically, it boils down to two steps: sudo port […]
A bash shell one-liner to strip the file extension
Here’s a one-liner that converts jarch files to starch format, stripping the input file’s extension so that it can be replaced with a new one: $ for i in `ls *.jarch`; do echo “${i%.*}.starch”; gchr $i | starch – > “${i%.*}.starch”; done
Playing with SHA-1 hashing in PolarSSL
PolarSSL is a C-based cryptography and SSL library which has a GPL license, which makes it ideal for use with BEDOPS, where I plan to use it for quick SHA-1 hashes of metadata, so as to help validate the integrity of the archive. I’ve been testing it out in Mac OS X 10.8 and it […]