Running Python Script from PHP as www-data

The problem Python script invoked from PHP via shell_exec and runs fine when PHP invoked from command line but fails when PHP triggered by browser access. Reason PHP, when triggered by a browser access is invoked by web server with the user www-data, while from the command line it is run as user ubuntu. Attempting …

Continue reading ‘Running Python Script from PHP as www-data’ »

Quick, fresh Ubuntu 16.04 image in VirtualBox

Download the VirtualBox image from https://www.virtualbox.org/wiki/Downloads Download the 16.04 Ubuntu image for VirtualBox from www.osboxes.org (the credential details for logging in are here: https://www.osboxes.org/faqs/) Open VirtualBox, click the New icon, Select ‘Linux’ for type, ‘Ubuntu 64-bit’ for version (assuming you downloaded the VirtualBox 64bit vdi), click next a couple of times until you reach the …

Continue reading ‘Quick, fresh Ubuntu 16.04 image in VirtualBox’ »

Selecting columns in Sublime Text turning your screen upside down?

The way to select a column in Sublime Text on Windows is by using + and then pressing the up or down arrow keys. You might get a surprise though if you try it in the form of you entire screen display flipping upside down. Some people don’t even know this is possible to do …

Continue reading ‘Selecting columns in Sublime Text turning your screen upside down?’ »

Status of specific brew service

Switching between various development environments, to save restart time, I wanted to start various services from OS/X only if they were not already running. Brew does not have a method to know whether a particular service is running (AFAIK), so the following example code parses the list of services returned by brew services list and …

Continue reading ‘Status of specific brew service’ »

PHP – switch statement vs. function dispatching

When you start having too many cases in your switch statement, it might be worth looking into using a function lookup. This is possible in all languages where functions are first class citizens… <?php $post = "hello"; $info = "3.1415"; //———————————————————– // Version 1 – using a switch statement //———————————————————– switch ($post) {     …

Continue reading ‘PHP – switch statement vs. function dispatching’ »