Opinionated Software

… we have opinions about everything!

Archive for the ‘One-liners’ Category

REGEXP Problem —

A good friend asked me how to replace the last full stop (period) in a field with another character using a regular expression e.g. a comma. When I asked “what language?” it turned out he wanted to do this using REGEXP_REPLACE in Oracle SQL. It’s a problem with a couple of solutions that I could immediately […]

fsutil one-liner —

fsutil fsinfo ntfsinfo X: where X: is the drive letter gives output like this: NTFS Volume Serial Number : 0x101051a010518e1a NTFS Version : 3.1 LFS Version : 2.0 Number Sectors : 0x0000000074498860 Total Clusters : 0x000000000e89310c Free Clusters : 0x000000000447f222 Total Reserved : 0x00000000000016e2 Bytes Per Sector : 512 Bytes Per Physical Sector : 512 […]

Opening UTF-16LE files in Perl —

Placeholder for useful code snippet: open my $fh, ‘<:raw:perlio:encoding(UTF-16LE):crlf’, $filenameopen my $fh, ‘<:raw:perlio:encoding(UTF-16LE):crlf’, $filename which will convert CR/LF combinations to LF only. Alternatively, to keep them intact: open my $fh, ‘<:raw:perlio:encoding(UTF-16LE)’, $filenameopen my $fh, ‘<:raw:perlio:encoding(UTF-16LE)’, $filename Useful for reading Windows registry export files, SQL server log export files etc.

List of Alphabetic Values in SQL Server —

I really like this use of the undocumented but widely used master.dbo.spt_values table to give a list of characters e.g. a-z or A-Z: SELECT CHAR(NUMBER) FROM master.dbo.spt_values WHERE NUMBER BETWEEN 97 AND 122 — Lowercase a-z –WHERE number between 65 and 90 — Uppercase A-ZSELECT CHAR(number) FROM master.dbo.spt_values WHERE number between 97 and 122 — […]

Some Quotes —

Anti-intellectualism has been a constant thread winding its way through our political and cultural life, nurtured by the false notion that democracy means that “my ignorance is just as good as your knowledge” – Isaac Asimov In the fields of observation chance favours only the prepared mind – Louis Pasteur The best argument against democracy is […]