Cron Job for Every Three Days

All posts by Robert

Oct 31

  • Created: Oct 31, 2013 2:00 PM

PHP Sessions and Objects

PHP Sessions and Objects

For the majority of my PHP career I didn’t store objects in a session. Not that it’s a difficult thing, I simply didn’t have a need to in the past. Now that I do, I have discovered a peculiar (in my opinion) aspect of it.

This came about because the session data on a certain area of the site in question would sometimes grow too large for the database field I was storing it in. PHP serializes the objects (to represent them as a string) before storing them in the session but when it isn’t able to store the entire string (which was happening for me), you end up with corrupted data which PHP can not unserialize back to object form. Once I zeroed in on this being the source of my problems, I needed a good solution. Read more

Posted in: php, Programming
Jul 3

  • Created: Jul 3, 2013 2:10 PM

Dirty Dishes – Avoiding Human Error

Dirty Dishes - Avoiding Human Error

As a programmer, much of my job is eliminating the chance for human error by automating as much as is sensible. I don’t live with the mindset of “keep those filthy humans away” but I do know the value of keeping those humans (myself included) away from any process they don’t need to be involved in. It isn’t just the complicated things, but simple things as well. For example:

Are they clean or dirty? That has been the question in millions of households all around the world since the proliferation of the dishwasher appliance. When I was young, a simple yet clever solution was available in the form of a magnet. It was a little sign that said “clean” on one end and “dirty” was written upside down opposite that. The idea is that you have it read “clean” when they’re clean, then “dirty” after rotating the sign when you take out the clean dishes and start filling it with the soiled ones.

These little signs are still available, still useful, and still completely unreliable. If you’ve ever had one in your house, you probably already know the problem: the sign rarely gets changed at the right time. If the sign says “clean” you can’t believe it. If it says “dirty” you better ask someone before you add your grimy fork to the basket. Read more

Posted in: Nexcess
May 9

  • Created: May 9, 2013 2:00 PM

Cron Job For the Last Day of the Month

Cron Job For the Last Day of the Month

I think cron is a wonderful creation. It is simple in what it does while being extremely useful. Allow me to present a short introduction to it for those unfamiliar, then I will show you a handy trick you may need someday.

Brief Introduction to Cron

You can set any command to run at any time (or repeatedly at a set interval) by using cron. The name comes from “chronos” – the Greek word for time. If you have Linux, you’re going to have cron. Run the command “crontab” to edit or create the jobs for your user.

The syntax seems a little cryptic at first, but it is very straightforward. You enter a series of numbers and symbols followed by the command you wish to run. The numbers and symbols state the desired time and day to run the command. They are separated by a space as follows: Read more

Posted in: Linux, Nexcess
Feb 27

  • Created: Feb 27, 2013 2:00 PM

Watch Your Users

The Microwave Minute

After my previous post, involving the microwave interface, I asked a few people in my family how they enter one minute on a microwave. I was surprised that none of them had ever thought to enter 6 – 0 for sixty seconds to get one minute. In fact, they questioned “Would that even work?”

When I say I was surprised, I mean really surprised! They didn’t know if it would work? What did they think would happen? Their response: “It would just do nothing.” Well, I would hope not. Knowing these people, if this machine “just did nothing” when it doesn’t like the input, we’d all be hearing about it. I’m sure they would want some kind of error message (but since microwaves have never given an error message, they aren’t expecting to see one). Read more

Posted in: Nexcess
Nov 27

  • Created: Nov 27, 2012 2:20 PM

The Microwave Minute

The Microwave Minute

How do you set your microwave to one minute? For some (like the one I used to have at home) you could just press the number 1 and it would start running at one minute. I like that because I’m lazy it’s effecient.

Do you press 6 – 0 or 1 – 0 – 0 to run it for one minute? Either should work, right? 6 – 0 would mean sixty seconds which is one minute. 1 – 0 – 0 would mean one minute and zero seconds. But, wait, how do you enter one hundred seconds? And should 1 – 2 – 0 mean one hundred twenty seconds (two minutes) or one minute and twenty seconds? If you were designing a microwave, what would you do?
Read more

Posted in: Programming
Aug 10

  • Created: Aug 10, 2012 3:03 PM

Mouse Gestures Everywhere

I like to use keyboard shortcuts for just about anything I can. It confuses my wife a little when she watches me on the computer (she says I’m Computer ADHD) but for me it gets the job done quicker and with less effort. What else would you expect from a programmer?

There are times, though, when my hands aren’t on the keyboard. If I’m scrolling through a document, for example, I’m probably using the mouse wheel. For such occasions, performing a keyboard shortcut would actually be more work since I would first have to move to the keyboard. If only I had a mouse shortcut! That would certainly be the lazy – I mean efficient – way to go. Well, there are mouse shortcuts and now I can use them for any program or window I have open.

I became acquainted with mouse gestures through the Opera browser which introduced them in version 5.10 (April 2001). I think I used mouse gestures more than keyboard shortcuts back then. They were a big part of what kept me using Opera. Today, other browsers have extensions which give you the same functionality but why restrict these wonderful time savers to just web browsers? I want to use them in my editor, email, audio player, everything!
Read more

Posted in: Nexcess
Jun 20

  • Created: Jun 20, 2012 11:54 AM

Reflection and Late Static Binding in PHP

Reflection and Late Static Binding in PHP

Late static binding (LSB) is new to PHP 5.3 (released 30 June 2009) but until recently there was a bug in how it worked with reflection. See the manual page for LSB with some examples and definition. For our example, you need to know that with class inheritance, LSB allows a static method call to be “bound to” the class from which the call originated as opposed to where the method is defined.

Consider the following:

class theFirstSelf {<br />
  const THE_CONST = 'self 1st';</p>
<p>  static public function myConst() {<br />
    return self::THE_CONST;<br />
  }<br />
<p>class theSecondSelf extends theFirstSelf {<br />
  const THE_CONST = 'self 2nd';<br />

Read more

Posted in: php
Apr 27

  • Created: Apr 27, 2012 3:07 PM

mkdir(): Too Many Links – What It Is and How to Fix

mkdir(): Too Many Links - What It Is and How to Fix
Recently, I was notified of an “out of disk space” error message which showed up in one of our applications while trying to send an email. I knew right away the source of the problem and while the short term solution was easy (I renamed the problem directory and created a new one – these files were only for logging) we definitely needed a long term solution.

All I found in the logs were a bunch of “Too many links” error messages and didn’t know exactly what it could mean. Hey, I’m a programer, not a systems admin; this was a new one for me. I could see we hadn’t run out of disk space but I knew “links” had to do with the filesystem.
Read more

Posted in: Linux
Feb 3

  • Created: Feb 3, 2012 4:23 PM

Good-bye Ubuntu. Sort of.

Good-bye Ubuntu. Sort of.
I started using Ubuntu in 2009. By the following year I had dropped the dual boot with Windows XP and was completely Ubuntu. When I hit a glitch during an update in 2011, I figured I would re-install with the latest version – 11.10 at that time. Unfortunately, I didn’t know about the major change they had done to the desktop environment by the name of Unity. Sorry Ubuntu, you lost me.

There are a number of “Unity hate” posts out there and that’s not the point of this one. I’d like to share with you what I eventually did as an alternative to Unity in the hopes that it may be a good choice for you too if you’re looking for one. Read more

Posted in: Nexcess