Monday, September 21, 2020

Determining where a CD or DVD was manufactured

On factory-pressed CDs (and some DVDs), on the shiny side of the disc near the center spindle ring there is usually text, known as the matrix string. Old vinyl records usually had writings in the same area. You can sometimes determine where a disc was mastered or pressed by the text contained in this area. For example a music CD with the text "EMI JAX" was manufactured at EMI's manufacturing plant, located in Jacksonville, Illinois, just west of Springfield. Additionally there are sometimes text stamped or etched into the plastic mould such as "MADE IN USA BY PMDC" (indicating the disc was made by PolyGram Manufacturing And Distribution Centers in Grover, North Carolina). A search for the text on Discogs will usually yield useful information.

There was no standard to how any of that text was formatted and often it was not obvious where the disc was made. Beginning in 1994, Philips and the International Federation of the Phonographic Industry created a system of markings called a SID code (Source Identification). The goal of this was to be able to trace a disc back to its origins to fight piracy/counterfeiting. The SID code always begins with the letters "IFPI" followed by a 4- or 5-digit code. There are two types of SID codes. The matrix SID code (present in the matrix area of the disc) identifies where the glass master of the disc was cut. The Mould SID code (in the plastic area) identifies where the disc was pressed/stamped.

The most thorough list of SID codes I have found is on the Musik-Sammler wiki though again a search of Discogs often also provides clues.

Because of consolidation, a decline in CD sales and an increase in DVD sales, the disc pressing plants changed ownership quite often during the 90s and early 2000s. By identifying the codes or matrix text on your disc, it can help you narrow down when it was actually manufactured and whether it is an original release or a repress/reissue from later years. Sometimes the artwork and copyright dates are identical and the only difference the original pressing and a later reissue is on the matrix/SID codes.

There are pressing plants in Russia and China and other places that do not conform to this standard, so the lack of SID code does not automatically mean the disc is from before 1994. But the presence of one means it is surely no older than 1994.

SQL: TRY_CAST alternative for old versions of SQL Server

In modern versions of Microsoft SQL Server there is a TRY_CAST function which returns NULL if the type cast fails, and returns the converted value if it succeeds. This is helpful if you're trying to format numbers from non-sanitized input and somebody put malformed data into a field.

At my job, I'm still dealing with SQL Server 2005 which does not provide this function. An alternative that I found online was to use XML to accomplish the same result:


1
CAST('' AS XML).value('sql:column("ItemHeight") cast as xs:decimal ?', 'decimal(28,10)')

SQL: Replace repeated spaces with a single space

In SQL dialects that provide a REPLACE function you can replace instances of repeated spaces with a single space (you may replace CHAR(7) with another character that you know won't appear in your dataset):
1
SELECT REPLACE(REPLACE(REPLACE('some   string    with         many     spaces', '  ', ' ' + CHAR(7)), CHAR(7) + ' ', ''), ' ' + CHAR(7), ' ');

Rosetta Code

Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another.

For example, to calculate the Fibonacci sequence in ArnoldC:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
IT'S SHOWTIME
 
HEY CHRISTMAS TREE f1
YOU SET US UP @I LIED
TALK TO THE HAND f1
 
HEY CHRISTMAS TREE f2
YOU SET US UP @NO PROBLEMO
 
HEY CHRISTMAS TREE f3
YOU SET US UP @I LIED
 
STICK AROUND @NO PROBLEMO
 
GET TO THE CHOPPER f3
HERE IS MY INVITATION f1
GET UP f2
ENOUGH TALK
TALK TO THE HAND f3
 
GET TO THE CHOPPER f1
HERE IS MY INVITATION f2
ENOUGH TALK
 
GET TO THE CHOPPER f2
HERE IS MY INVITATION f3
ENOUGH TALK
 
CHILL
 
YOU HAVE BEEN TERMINATED

Bit-Twiddling Hacks

Sean Eron Anderson has collected a great bunch of bit-twiddling hacks at his website. Even if you may never have a need for operating at this level, it's a good mental exercise to to solve these kinds of puzzles.

For example, a C macro to swap two values without use of a third variable and by only using addition and subtraction:

1
2
#define SWAP(a, b) ((&(a) == &(b)) || \
                    (((a) -= (b)), ((b) += (a)), ((a) = (b) - (a))))

If you really want to jump head-first into the deep end, check out the book Hacker's Delight by Henry S. Warren.