Author: Petronald Green

How to use Wordpess built-in Functions externally (in posts, widgets etc.) 1

How to use Wordpess built-in Functions externally (in posts, widgets etc.)

For our canvas lets use the Enhanced Text Widget plugin, it will let us type Javascript, Flash and even Php directly into the text box..

After you install put this widget box on your sidebar or wherever you insert the following at the top of your code.

require( '/home/my/absolute/path/wp-load.php' );

Here is a simple example which would output something along the lines of : “Hello World Mr facade”.

IMPORTANT: Remember to change the absolute path to the one for YOUR server.

<?php
require( '/home/my/absolute/path/wp-load.php' );
echo "hello world Mr ";
$current_user = wp_get_current_user();
echo $current_user->display_name;
?>

References:

WordPress Codex (get current user) : http://codex.wordpress.org/Function_Reference/wp_get_current_user

A complete list of PayPal’s fees by country 1

A complete list of PayPal’s fees by country

Fees are calculated as ‘Fee’ + ‘Fixed’:

Country Online Purchases Personal Payments Currency Conversion
Afghanistan
Albania 3.4 3.4 free
Algeria 4.9
American Samoa  –
Andorra unknown
Angola unknown
Anguilla unknown
Antarctica  N/A
Antigua and Barbuda 4.9
Argentina 5.4
Armenia unknown
Aruba
Australia
Austria
Azerbaijan
Bahamas (more…)
How to create a ‘select all’ checkbox in javascript 0

How to create a ‘select all’ checkbox in javascript

For HTML Code:

<input type="checkbox" onClick="toggle(this)" />

<input type='checkbox' name='ss' value='one'  />
<input type='checkbox' name='ss' value='two'  />
<input type='checkbox' name='ss' value='three'  />

We use Javascript:

<script>
  function toggle(source) {
    checkboxes = document.getElementsByName('ss');
    for (var i = 0, n = checkboxes.length; i < n; i++) {
      checkboxes[i].checked = source.checked;
    }
  }
</script>

(more…)

How to get a previous date in bash (linux) 0

How to get a previous date in bash (linux)

Simply put

date -d '1 day ago' +'%Y-%m-%d'
# For multiple days
date -d '7 days ago' +'%Y-%m-%d'

If you wish to place in a shell script:

RMDATE=$(date -d '7 days ago' +'%Y_%m_%d')

will place for example ‘2013-07-01’ in the RMDATE variable which of course you can use like

echo $RMDATE

 

Linux ‘Environment Variables’ 0

Linux ‘Environment Variables’

In windows, when we want a program to run anywhere we simple add it to the PATH section of the environment Variables… Well, what about linux?

ln -s /root/myawesomescript.sh /bin/shortname

# nnow we can run with 'shortname'

 

How to find physical location of /dev/sd* drives in linux 0

How to find physical location of /dev/sd* drives in linux

I wrote a lil script to help out with this.. The syntax is as follows:

finddrive.py sda

How this works is by lighting up the corresponding drive on the front panel for about 3 seconds.

#!/bin/sh

cmd="dd if=/dev/$1 of=/dev/null"
seconds=3

echo "Check front panel for indicator light"
$cmd&

cmdpid=$!
sleep $seconds

if [ -d /proc/$cmdpid ]
then
  # echo "terminating program PID:$cmdpid"
  kill $cmdpid
fi

Credits:  Fabio’s Blog