Get current user name in a bash script

Using /usr/bin/whoami command

echo "$(whoami)"

Using /usr/bin/id command

echo "$(id -u -n)"

Using USER environment variable

echo "$USER"

Image to Data URI with PHP

I often find myself converting images to data URIs in an attempt to reduce network requests. This script is based on the same concept as David Walsh’s article Image Data URIs with PHP but rather than using the depreciated mime_content_type, my script makes use of FileInfo, which “provides the same functionality in a cleaner way” as quoted from the PHP docs.

echo '<img src="'.getDataURI('path_to/your_image.png').'">';
function getDataURI($image,$mime='') {
	$finfo = new finfo(FILEINFO_MIME_TYPE);
	$mime = $finfo->buffer(file_get_contents($image));
	return 'data:'.$mime.';base64,'.base64_encode(file_get_contents($image));

Please keep in mind if you plan on using data URIs, they are not supported by ie7 and lower.

Enable WordPress Featured Image

If your wondering how to enable WordPress featured images, your in the right place. First paste the following code in your functions.php file.


Now in your theme where you’d like the featured image to appear paste the following code.

<?php if (has_post_thumbnail()) : ?>
   <figure class="post-image">
      <?php the_post_thumbnail();?>
<?php endif; ?>

Different Types of Clients

One of my favorite websites that I find myself on daily is I was “Googling” tips and tricks on dealing with certain types of clients when I came across an article that talked about the different breeds of clients. The author went on to talk about how there are 12 different types of clients. read more