Press "Enter" to skip to content

Month: December 2008

Joke: Computer Problem Report Form

Computer Problem Report Form 1. Describe your problem: 2. Now, describe the problem accurately: 3. Speculate wildly about the cause of the problem: 4. Problem Severity: A. Minor__ B. Minor__ C. Minor__ D. Trivial__ 5. Nature of the problem: A. Locked Up__ B. Frozen__ C. Hung__ D. Strange Smell__ 6. Is your computer plugged in? Yes__ No__ 7. Is it turned on? Yes__ No__ 8. Have you tried to fix it yourself? Yes__ No__ 9. Have you made it worse? Yes__ 10. Have you had “a friend” who “Knows all about computers” try to fix it for you? Yes__ No__ 11. Did they make it even worse? Yes__ 12. Have you read the manual? Yes__ No__ 13. Are you sure you’ve read the manual? Maybe__ No__ 14. Are you absolutely certain you’ve read the manual? No__ 15. If you read the manual, do you think you understood it? Yes__ No__ 16. If ‘Yes’ then explain why you can’t fix the problem yourself. 17. What were you doing with your computer at the time the problem occurred? l8. If you answered ‘nothing’ then explain why you were logged in? l9. Are you sure you aren’t imagining the problem? Yes__ No__ 20.…

PHP: md5 hashes, base_convert and 32 bit limitations

I’ve had cause to convert an md5 hash from the standard hexadecimal base 16 to base 36 (mainly to make it shorter for presentation purposes). However, using base_convert in PHP proved unreliable as the string wouldn’t always convert back correctly. This is on 64 bit Linux, but I’m not certain PHP has been compiled with 64 bit support (so it is probably defaulting to 32bit). However, thanks to this post on the PHP documentation, I’ve changed the code to use: /*use gmp library to convert base. gmp will convert numbers > 32bit*/ if (!function_exists(‘gmp_strval’)) {     trigger_error(‘GMP does not appear to be compiled into PHP’); } function gmp_convert($num, $base_a, $base_b) {         return gmp_strval ( gmp_init($num, $base_a), $base_b ); } To test this, here’s the code I used: function testconvert() {     $a=Array(10,23,46,239423, PHP_INT_MAX, 323927832, 174623748237, PHP_INT_MAX.PHP_INT_MAX);     foreach ($a as $key) {         $converted=gmp_convert($key,10,36);         $phpstandard=base_convert($key,10,36);         print ‘key=’.$key.’. Convert: ‘.$phpstandard.’,’.$converted;         if (!(base_convert($phpstandard,36,10)==$key)) { print ‘<strong>Standard PHP Failed</strong>’; }         if (!(gmp_convert($converted,36,10)==$key)) { print ‘<strong>GM PHP Failed</strong>’; }         print ‘<br>’;     }     foreach ($a as $skey) {         $key=md5($skey);         $converted=gmp_convert($key,16,36);         $phpstandard=base_convert($key,16,36);         print ‘key=’.$key.’. Convert: ‘.$phpstandard.’,’.$converted;         if (!(base_convert($phpstandard,36,16)==$key)) { print ‘  <strong>Standard PHP Failed</strong>’; }         if (!(gmp_convert($converted,36,16)==$key)) { print ‘  <strong>GM PHP Failed</strong>’; }         print ‘<br>’;     } }

e-Commerce: ClickCartPro making all product ids safe

Basically, in ClickCartPro product “identifers” can not have spaces, commas, full stops or brackets in them (basically only the letters A-z, numbers and underscores) and they have to be a maximum length (I’m not sure what the exact maximum is). If you are maintaining an “established” store (i.e. one with products) where a number of products are showing up on the front end, but when you try to “Add to cart” they don’t appear in the cart then this is probably the problem. To “fix” it (this is more a work around), run the following UNREVERSABLE MySQL code (i.e. make sure you have a backup before hand): create table temp_replacetest(id varchar(250),hash char(32)); INSERT INTO temp_replacetest (SELECT id,md5(id) from gbu0_prod); update gbu0_prod,temp_replacetest SET gbu0_prod.xprod=replace(gbu0_prod.xprod,,temp_replacetest.hash) where IN (gbu0_prod.xprod); drop table temp_replacetest; update gbu0_prod set id=md5(id); select id,xprod from gbu0_prod This will set all product ids to be md5 hashes which, since they only consist of 32 numbers or the letters a-f, are “safe” to use as product identifiers.

Life: Nationwide and their ATM time machine

Have a look at this snapshot of my Nationwide Building Society’s online statement: I’ve blocked out the bits which don’t matter.. See anything odd? No – well, the statement was dated “Saturday 6th of December 2008”, but it’s showing a “Branch or Cash Machine Withdrawal” for £20.00 on Monday the 8th of December 2008: two days in the future! I know I regularly withdraw £20 or £30 pounds from an ATM (Automatic Teller Machine: the proper name for cash machines/hole in the wall machines) on a Monday, but isn’t Nationwide being a bit presumptuous in thinking that I’ll do the same again this coming Monday? Or have they just invented a time machine so they can ensure that they know what the financial markets are going to be like in the future…