PHP session_start() failed no space left on device (Plesk plesk-php-cleanuper)

I kept receiving intermissive PHP warnings saying some thing like E_WARNING: session_start(): open(/var/lib/php/session/sess_ji9k4chqke3pde98a5n5m1vca5, O_RDWR) failed: No space left on device (28). Usually this would indicate that the disk where the sessions were being stored is full. The best place to start is to check if the disk where those session files are being stored is in fact NOT full.

// to check disk space usage
df -h

// should display something like this
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  883M  3.2G  22% /
/dev/mapper/vg00-usr  4.0G  1.8G  2.0G  49% /usr
/dev/mapper/vg00-var  890G  231G  614G  28% /var
none                  5.9G  116K  5.9G   1% /tmp

In my case the disk where the sessions were being stored had plenty of space - 600GB free!

Continue reading →

Authenticate Only Certain HTTP Verbs (POST, PUT, DELETE) in Laravel 4

In working on the API for an upcoming project, I needed a way to allow all reads (GET) to be allowed without authentication but any requests (POST, PUT, or DELETE) changing the data to require authentication.

Continue reading →

New Business Cards

After server iterations, here are the new business cards to match the updated site.

Continue reading →

PHP Class to Move Database Files (like MYD, MYI, and frm)

A client needed a quick way to transfer their MySQL database files (specifically MYD, MYI, and frm) from their Windows server over to the webserver running CentOS. Below is a quick class that we used to run every 4 hours via cron to do the job.

Please leave a comment below if you have any questions or improvements.

Download Class View on Github

Continue reading →

Site Update: RSS feed and social links

One of my summer last tasks to do with the site redesign was to implement an RSS feed for the posts/articles. The feed can now be found at the bottom of each page along with links to my github and Facebook page.

subscribe to rss
Continue reading →

Project: CSS Button Collection

I just released my latest project the CSS Button Collection. It is a collection of CSS only buttons of various designs - from large push downs to trendy flat. My goal is to keep updating the collection as soon as I can, but please feel free to hop over to the github page and submit some of your own.

View Demo Project on github
Continue reading →

Rotate Images using jQuery

To add extra functionality to an image upload form, you're likely going to want to include the ability to rotate an image. Most of the time it will simply be from portrait to landscape or vise-versa. Below is a quick demonstration of the frontend - the part the user will choose an image and rotate it.

Continue reading →

Display the Difference Between Two Dates in PHP

Here's a quick function to display the difference between two dates using PHP. The function will return the correct plurized wording and hide any with zero. For example if the date is less than 1 year, it would hide "0 year" from displaying.

/**
 * Display the difference between two dates
 * (30 years, 9 months, 25 days, 21 hours, 33 minutes, 3 seconds)
 *
 * @param  string $start starting date
 * @param  string $end=false ending date
 * @return string formatted date difference
 */
function dateDiff($start,$end=false)
{
   $return = array();
   
   try {
      $start = new DateTime($start);
      $end = new DateTime($end);
      $form = $start->diff($end);
   } catch (Exception $e){
      return $e->getMessage();
   }
   
   $display = array('y'=>'year',
               'm'=>'month',
               'd'=>'day',
               'h'=>'hour',
               'i'=>'minute',
               's'=>'second');
   foreach($display as $key => $value){
      if($form->$key > 0){
         $return[] = $form->$key.' '.($form->$key > 1 ? $value.'s' : $value);
      }
   }
   
   return implode($return, ', ');
}

// examples
echo dateDiff('1982-10-14'); // 30 years, 9 months, 25 days, 21 hours, 33 minutes, 3 seconds
echo dateDiff('2001-09-05 08:15:05','2002-02-15 04:10:02'); // 5 months, 9 days, 19 hours, 54 minutes, 57 seconds

Continue reading →

jQuery AJAX Loading – Display Images or Text Until Script is Finished

This is a simple way to display an image or text while an AJAX request is loading.

View Demo

What we’re basically doing is forcing a div to have a starting image and then replacing it with the data return from the AJAX request.

Continue reading →

Sync Files Between Servers using rsync

This is a follow up post to Copy/Transfer Files Between Two Servers Using Linux SCP. Transferring via scp copies all the files which is what you want sometimes, but I find rsync to be a much better solution in most instances.

I'll provide a handful of ways I tend to use rsync but check out the full Linux man page for the a complete description of rsync and all the available options.


Synchronize from Local Server to Remote

rsync -avuz /var/www/example.com/ root@108.175.12.239:/var/www/example.com/

// only one file
rsync -avuz /var/www/example.com/index.html root@108.175.12.239:/var/www/example.com/
Continue reading →