Every now and again someone writes a line or two of code that really makes me smile. Such is the case with this outcome determinating and decision making class below. This code is being reproduced, with or without consent, from the PHP Developers Network’s own scottayy.
<?php
/**
* Coin flipper class helps determine outcome of situations in which an outcome
* cannot be decided by sheer manpower alone.
*
* @author Scott Martin <scottayy@devnetwork.net>
* @license None, don't even try to use this or your hair will turn yellow
*/
class coin {
/**
* The outcome determinators
*
* Each invocation of this object will require a determinator upon which the
* object relies to build a determined outcome. These are those determinators.
*
* @access private
* @var array
*/
private static $_sides = array('heads', 'tails');
/**
* The determinating method
*
* This method, when called, invokes a determination sequence and returns a
* determined value for use in decision making.
*
* @access public
* @return string Randomly selected determinator
*/
public static function flip() {
// Quick, randomize me some determinators
shuffle(self::$_sides);
// Quick, offer it back before it gets angry
return self::$_sides[mt_rand(0, 1)];
}
}
/**
* We should always test our determinating decision establisher
*
* 2,4,6,8 You know you want to determinate
*/
echo coin::flip();
?>
For those that just have to have an object to instantiate (and you know who you are), there is this lightly modified version for your obsessive/compulsive selves:
<?php
/**
* Coin flipper class helps determine outcome of situations in which an outcome
* cannot be decided by shear manpower alone.
*
* @author Scott Martin <scottayy@devnetwork.net>
* @license None, don't even try to use this or your hair will turn yellow
*/
class coin {
/**
* The outcome determinators
*
* Each invocation of this object will require a determinator upon which the
* object relies to build a determined outcome. These are those determinators.
*
* @access private
* @var array
*/
private $_sides = array('heads', 'tails');
/**
* The determinating method
*
* This method, when called, invokes a determination sequence and returns a
* determined value for use in decision making.
*
* @access public
* @return string Randomly selected determinator
*/
public function flip() {
// Quick, randomize me some determinators
shuffle($this->_sides);
// Quick, offer it back before it gets angry
return $this->_sides[mt_rand(0, 1)];
}
}
/**
* We should always test our determinating decision establisher
*/
$coin = new coin;
/**
* 2,4,6,8 You know you want to determinate
*/
echo $coin->flip();
?>
See, just looking at that code makes you want to smile doesn’t it? Geeks are great.
A recent Sitepoint article by Rachel Andrews, Director of edgeofmyseat.com, outlined some pretty Nifty Navigation Tricks Using CSS. Anyone that wants to learn to make some pretty cool tabbed, button or vertical bar navigation lists should give this article a read through. It is a pretty well written article and has a great deal of code that can be easily copied and pasted for your development pleasure.
For four pages it reads very fast. It is easy to follow and the examples are practical. I wish there were some working samples of the code, but still, it is a good teaching tool for those that have yet to dive into CSS based navigation lists (and you should get into it, as CSS is designed for such things).
For those that want a huge assortment of samples, code and really cool lessons, check out Stu Nicholls’ CSS Play. This site is an amazing reference for learning the art of cross-browser compatible CSS. There are menus, layouts and much more available to learn from and even use, in many cases without even a link back to him, though it is always a good idea to give credit where credit is due.
So if you are in need of a little CSS learning fix, hit these references up. You will enjoy them and, in the case of Stu Nicholls, may even make them part of your normal daily web development toolset.
A few weeks ago I was toying with XML. I had a few minutes to spend teaching myself so I decided that I would use that to work on something that I desperately need to work on. XML.
And what better way to learn a little XML stuff that on the Amber Alert system? So I began my journey.
Continue reading »
As much as I loved my Chocolate Ocean theme that I developed a few months ago…

… I thought it was time for a change. So I changed.
My theme that is.
Continue reading »
I was thinking today that though I carry the title of Web Developer around with me wherever I go I have not been developing for the web much the last few months. Come to think of it, I cannot say that I have developed anything for the web in about five months or so.
Don’t get me wrong. I have been coding PHP like a mad penguin with 20 hands and an incredible itch at the tip of his fingers. Its just that the code I have been writing has been either framework code that drives web apps or CLI code that will be used for integration projects from the command line or cron.
And I absolutely love what I am doing. I have been employing design patters almost as though they came straight from a book. Without even knowing I was doing that.
And it made perfect sense to do it. Little modular classes that are built of maybe two methods and a property each that totally allow for expansion later just by adding the controller and the model. You just gotta love it.
And because I have had the opportunity to do so, I have been using vi(m) quite a bit more than I have in the past. In fact, today I used nothing else. And I was totally thrilled to use it.
I felt faster and way more in control without having to touch my mouse. And I was able to code, shell out, process SVN commits, file searches, CLI stuff… everything I needed to do without ever leaving my editor and without ever touching my mouse. How awesome is that?
I think my zeal for the type of coding is that I felt like a programmer today. Not a script kiddie, not a PHP n00b, but a programmer. A guy who writes code then implements it and instantiates it at the CLI to watch (you ready for this?) absolutely nothing come to the screen - because that is how we want it to work.
Yeah, I love being a geek. And it doesn’t take much to make me happy as a geek. A sweet little editor, a freaking rad OS and a great programming language like PHP. Oh yes, color me happy. And color me geek.