Posts

Showing posts from 2020

Why Apple No Longer Understands Steve Jobs

Image
No one who understands technology and product design would ever dispute that Steve Jobs changed the way the world works. We've already looked at all the ways the iPhone is now inferior to its competitors despite having been the pioneer in the field of smartphones. But it's also possible to prove empirically, and with some simple logic, that Apple today no longer understands the design philosophy of its visionary founder. When Jobs decided to remove the disk drive from the MacBook Pro to create the MacBook Air , it removed some very important functionality. But the result of that loss, was a huge gain in the portability and overall usability of the product. The new Air was nearly half the weight of its predecessor, and nearly half as thin. So just ask yourself this — what have the current generation of MacBooks gained from having all useful ports replaced by the USB-C ports? These new Macs have suffered a tremendous loss in usability — now requiring ungainly

Batch Convert PNG to JPG from Mac Terminal - SIPS

  mkdir jpegs sips -s format jpeg *.* --out jpegs  

Export single table MySQL

Using OUTFILE will output a table to CSV but gives an access denied error for non root users. SELECT * FROM orders WHERE foo = 'bar' INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ;   A quicker way than granting access etc is to simply dump the table from ssh into an sql file, and convert the data oneself using vi and regex.  mysqldump db_name table_name > table_name . sql

Running Background Tasks From SSH

Most online sources will tell you that you need a tool such as Screen to be able to run background tasks from an SSH session. But the simplest way is to simply configure an a Cron job. The process will continue to run even after the SSH session is disconnected. The process can also be monitored later with PS (pipe through grep to find it), and even terminated with Kill if necessary.

PHP Custom timeout for file_get_contents

$CustStreamContext = stream_context_create (     array     (         'http'=> array         (                     'timeout' => 0.5,  //0.5 seconds             )     ) );         $Cont = @file_get_contents("https://www", false, $CustStreamContext);

Drupal Node Revisions Cleanup

<? $nodes = db_select('node', 'n')     ->fields('n', array('nid','vid'))     ->execute(); foreach ($nodes as $node) {     $revisions = db_select('node_revision', 'n')         ->fields('n', array('vid'))         ->condition('n.nid',$node->nid)         ->condition('n.vid',$node->vid, '<')         ->execute();     $count = 0;     foreach ($revisions as $rev)     {         // Uncomment below line to actually delete         // node_revision_delete($rev->vid);           $count++;     } if ($count>0)     echo '<a target="_blank" href="/node/'.$node->nid.'">node '.$node->nid.'</a><br>count '.$count.'<br>'; } ?>

Drupal unpublish node programmatically

<? $nids = explode(',','62013,61859,61863,61865,61867,61871,61886,63158,62026,62030,186894,62065,62066,62075,62077,147834,62944,62107,62109,62110,62113,62114,62117,62593,62595,147333,62625,62725,62730,62731,62737,62738,147694,62744,62746,62747,62749,62752,62882,62931,62936,62939,63142,63329,63330,179870,147716,63537,63545,63990,63779,63778,64096,64097,64098,147160,64105,147159,138323,142181,146031,210600,235951,141272,142298,186895,146032,146997,147529,145236,145813,274097,281698,296945,299231'); foreach ($nids as $nid) { $node = node_load($nid); if (isset($node->status)) { $node->status = 0; node_save($node); } } ?>