Product Quickcode Generator
How to generate a Base36 quick code sequence using the SHA2 hash
On a 'slowish' 2GHz machine it can generate 20,000 quickcodes per minute. The spread of the resulting quickcodes is near-perfectly even, which means that substrings of the quickcode can be used to construct a hashed directory tree for holding, for example, the huge amount of product image files associated with a product catalog. Using a hashed directory tree is a quick and efficient method to host millions of separate files for quick, random access, as most file systems only perform optimally with less than 1,000 contained in a directory
This deterministic techique uses a hash of the sequential Integer Id of an item to generate a typical product quickcode for it, as found in many shopping catalogues. Example of how a quickcode is generated from its primary key integer Id:
- 1 => 8M9LFLN2
- 2 => HZ40H3K0
- 3 => 02LUJYQ2
You can download the Base36 Quickcode Generator test script, which demonstrates an implementation in Perl and MySQL.
How to Dedupe a table in MySQL
A quick and dirty way of stripping duplicate records out of a MySQL table!, if your table has no indexes or constraints:
Assuming the name of the offending table is customers:
CREATE TABLE customer_dedupe AS SELECT DISTINCT * FROM customers;
RENAME TABLE customers TO customers_dupe;
RENAME TABLE customers_dedupe TO customers;
But what if your original table had indexes?
How to open .daa Files?
Yet another bespoke file format that unsuccessfully attempts to futher the agenda of vendor lock-in: If you are running Windows, you need to purchase PowerISO from poweriso.com , if you are running X86-based Linux flavour, the same people offer a free program to read and write .daa files. Go figure...