Skip to main content

Posts

Showing posts from February, 2021

Debug php helper - __fatalHandler

https://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-e-error-error register_shutdown_function('__fatalHandler'); function __fatalHandler() {     $error = error_get_last();     if($error) {         echo '<pre>';         print_r($error);         die;     } } function debug($arr,$file='',$line=''){     if(empty($file) && empty($line) ){         $bt = debug_backtrace();          $caller = array_shift($bt);         $file = $caller['file'];         $line = $caller['line'];     }     echo  "\n <b>debug file ".$file." line ".$line." </b>" ;     echo "<pre>";     if(is_array($arr) || is_object($arr)){         print_r($arr);     }     elseif(is_string($arr) || is_numeric($arr)){ ...

Note on Shopify and Car DB design 20-Jan-2021

TODO bash crawl shopify variants / products data.  https://stackoverflow.com/questions/18132144/handle-race-condition-between-2-cron-tasks-what-is-the-best-approach https://dba.stackexchange.com/questions/235242/database-design-for-cars The automotive industry has plenty of exceptions, complicating such a project. For example, the Ford Escort ZX2 was marketed as a trimline of the Escort for the first couple of years, then stood alone as just "Ford ZX2" (with bumper emboss to match) starting in MY1999. So was it a submodel, or a standalone model, which happened to be named in reference to another model? Did it go from one to the other in 1998? CREATE TABLE Manufacturers ( ManufacturerID  SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY, ParentManufacturerID    SMALLINT REFERENCES Manufacturers (ManufacturerID), ManufacturerName    VARCHAR(100) NOT NULL UNIQUE ); CREATE TABLE Models ( ModelID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ModelName   VARCHAR(...

Some coding convention rules, working effectively with Legacy code

 https://softwareengineering.stackexchange.com/questions/133404/what-is-the-ideal-length-of-a-method-for-you Method length should be 15 (soft limit). We can do “testing to detect change.” In traditional terms, this is called regression testing. We periodically run tests that check for known good behavior to find out whether our software still works the way that it did in the past. Let’s do a little thought experiment. We are stepping into a large function that contains a large amount of complicated logic. We analyze, we think, we talk to people who know more about that piece of code than we do, and then we make a change. We want to make sure that the change hasn’t broken anything, but how can we do it? Luckily, we have a quality group that has a set of regression tests that it can run overnight. We call and ask them to schedule a run, and they say that, yes, they can run the tests overnight, but it is a good thing that we called early. Other groups usually try to schedule regressio...