PHP

Format in Engineering Notation

If you have a value and SI unit – for example 2000W – and you want to display this in engineering notation – 2kW – then this may help. /** * Format a float in engineering notation * @value float floating point number * @units string like W for Watt * @return array */ function Eng ($value, $units) { // Exceptions if (is_null($value)) { return array( ‘value’ => NULL, ‘units’ => $units, ‘decimals’ => 0,…

Continue reading

Humor

600 Million Dollars

I almost missed this opportunity for $600,000,000 …. Google’s spam engines got it. But I found it. Dear Sir With all sincerity and humility it is with deep pains i write you this message of wishful assistance to my predicament. I am Raymond Taylor the only son of last wife to the former president of Liberia who was asked by unanimous decision by the international community to step down from the corridors of power .…

Continue reading

Video

Speed up Vimeo

To speed up the playback of a Vimeo video on their website, open the javascript console and run this code directly. var v = document.querySelector(‘video’); var t = prompt(‘Set the playback rate’); v.playbackRate = parseFloat(t) A popup will appear to choose the speed of the playback. A value of 2 is double speed.

Continue reading

Bash

chown to current cPanel user by path

Use this script file to chown into the cPanel user defined by the path. #!/bin/bash THISUSER=`pwd | cut -d’/’ -f 3` echo echo CHOWN all files to $THISUSER; echo find -exec chown $THISUSER:$THISUSER {} \; chown :nobody /home/$THISUSER/public_html For example, if the path is /home/username/this/file path, this will chown username. Notice that the /home/username/public_html folder actually belongs to the nobody group or you will get errors. We have to use find instead of chown directly…

Continue reading

Tao

Boiling Frogs

I found this little snippet…. The pace of disruptive change is increasing, from the rise of cloud technology, social business, the Internet of Things and others. We feel it as much as other government departments and so we offer this internal research paper publicly, not to present policy or guidelines, but to stimulate debate. So why the title “Boiling Frogs?” The story goes that if a frog is placed in a saucepan of cold water,…

Continue reading

Bash

su to current cPanel user by path

Use this script file to su into the cpanel user defined by the path. #!/bin/bash THISUSER=`pwd | cut -d’/’ -f 3` echo echo now running as $THISUSER; echo su $THISUSER -s /bin/bash This is a easy option if you need to work on files as the correct owner. For example, if the path is /home/username/this/file path, you will su as username. Installation cat > ~/suthis.sh

Continue reading