Thoughts, rants and commentary of a simple man

Goodbye 2014

Posted on December 31st, 2014 in Personal Messages | No Comments »

As I’ve done many times in the past, I’ve decided to give 2014 a quick once over and reflect on some of the events that took place this past year that stood out to me. While this list is in no way exhaustive nor is it a complete recap of 2014, all of the things that caught my eye significantly impacted me in some way.

  • I became the parent of an adult child – Sarah turned 18 this year. I still contend that this is not even a remote possibility since she was just born like three years ago. Regardless, I was in no way ready to admit that I was old enough to be the parent of an adult child. I still believe that I am not that old. But I suppose you can’t argue with time.
  • My second kid tested out of school early – Rebekah decided she was done with school and took the CHSPE. By passing the exam she was able to forgo the second half of her senior year and will instead be enrolling in junior college come January 2015. To say that this kid is driven is to not even come close to describing her.
  • I established new friendships and strengthened old ones – In both my personal and my professional life I’ve been able to establish new relationships. Professionally, this year saw a number of my closest working relationships change because of job changes. That doesn’t necessarily mean it has been a negative thing. In fact, I am very happy for my former coworkers since they are now fulfilled in their careers. Personally, I’ve had the fortune to become much closer to some of my friends that, before this year, I was not as close to. Situations have changed, priorities have shifted and the stars aligned to allow me to develop some very close friendships this year. For that I will be forever grateful.
  • Dr. Seuss overtook my family – All five of my children were involved in Stage 1 Youth Theater’s summer production of Seussical. Sarah was the audition and rehearsal pianist, Rebekah was the stage manager (first time managing the stage!!!), Adriannah was the Cat in the Hat, Alaynah was Mrs. Mayor and Aaron was Mr. Mayor. This presentation single handedly took over my summer but it was so worth it to see all of my kids participate in a show together.
  • I became president of a baseball league – Aaron has played baseball the last two years as part of Centerville National Little League. This past year I was elected as President of the Board of Directors for the league. Not sure what I was thinking exactly by taking this position on, but for now it is a blast since I have an excellent supporting cast of amazing board members.
  • AJ became a football player, I became a coach – AJ decided he wanted to play football this year so we signed him up for Fremont Football. If that wasn’t enough of a committment, I decided to assist the team this year by coaching as well and by the beginning of the season I was the offensive coordinator. To say that I was overextended would be an understatement, but I enjoyed every minute of it and I believe Aaron did, too. He was the smallest player in our division (he was minimum league age for the division… by 32 days) so this year was more of a learning year for him. But by the end of the season I can honestly say that he developed his own player character and is setting himself up for some amazing things in future seasons. And if nothing else he will forever have this chip on his shoulder that should do well in protecting him for the rest of his life.
  • Racial tension became a nationally prominent thing again – The Michael Brown case happened this year. The Eric Garner case happened this year. The media happened this year and things got wildly out of control, to the point that people were protesting around the country, closing freeways, staging die-ins and ultimately targeting and murdering police officers. In my opinion the actions of the protestors were ridiculous and completely counterproductive to bringing positive attention to their cause. Regardless, many people jumped on the #HandsUpDontShoot and #ICantBreath bandwagons and still many others jumped on the loud protest bandwagon. The racial divide in this country was already pretty bad, but at the end of 2014 they are much worse, in my opinion.

So that’s a brief look back on 2014 for me. Like I said, there were A LOT of other things that came to pass this past year. Some that, when I look back on them, I cannot help but smile and others that, when I look back on them, I can’t help but feel sadness. Either way, what happened, happened, and I pray that I am a better man because of it. Likewise, I pray that your 2014 wasn’t something to be bitter over but was instead something to want to be better in spite of. And I also pray that your 2015 is bountiful, fruitful, abundant and positive.

I tip my glass you. Here’s to an amazing 2015.

Back to top

Creating a custom XML logger for SugarCRM 7

Posted on October 8th, 2014 in Programming,Web Development,Work | No Comments »

I recently ran across a question on StackOverflow in which the original poster asked about creating a custom XML logger for SugarCRM. He was wondering where to put his custom class and some of the particulars surrounding this so I thought I’d pitch in and help out.

I created my own custom XML logger class – SugarXMLLogger – and saved it at custom/include/SugarLogger/SugarXMLLogger.php. I then applied it to the Ping API for testing both as a replacement for fatal level logging and as a replacement for the default logger. Since the functionality of the logger is intended to be simple, I didn’t feel the need to extend SugarLogger. However, I did feel it at least appropriate to implement LoggerTemplate so that the integrity of the logger among the stack of loggers was kept in tact. If you want the fullness of SugarLogger in your custom loggers then you should extend SugarLogger. However, for a simple XML logger that wasn’t absolutely necessary.

As far as the log is concerned, I kept all the same information as is normally in sugarcrm.log with the only change being how it is stored. Since XML is structured it made sense to structure the logged information accordingly. So, without further ado, here is the code for the SugarXMLLogger…

The SugarXMLLogger Class

<?php
/** 
 * Save to custom/include/SugarLogger/SugarXMLLogger.php
 * 
 * Usage: 
 * To make one particular log level write to the XML log do this:
 * ```php
 * <?php
 * LoggerManager::setLogger('fatal', 'SugarXMLLogger');
 * $GLOBALS['log']->fatal('Testing out the XML logger');
 * ```
 * 
 * To make all levels log to the XML log, do this
 * ```php
 * <?php
 * LoggerManager::setLogger('default', 'SugarXMLLogger');
 * $GLOBALS['log']->warn('Testing out the XML logger');
 * ```
 */
 
/**
 * Get the interface that this logger should implement
 */
require_once 'include/SugarLogger/LoggerTemplate.php';
 
/**
 * SugarXMLLogger - A very simple logger that will save log entries into an XML
 * log file
 */
class SugarXMLLogger implements LoggerTemplate
{
    /**
     * The name of the log file
     * 
     * @var string
     */
    protected $logfile = 'sugarcrm.log.xml';
 
    /**
     * The format for the timestamp entry of the log
     * 
     * @var string
     */
    protected $dateFormat = '%c';
 
    /**
     * The current SimpleXMLElement logger resource
     * 
     * @var SimpleXMLElement
     */
    protected $currentData;
 
    /**
     * Logs an entry to the XML log
     * 
     * @param string $level The log level being logged
     * @param array $message The message to log
     * @return boolean True if the log was saved
     */
    public function log($level, $message)
    {
        // Get the current log XML
        $this->setCurrentLog();
 
        // Append to it
        $this->appendToLog($level, $message);
 
        // Save it
        return $this->saveLog();
    }
 
    /**
     * Saves the log file
     * 
     * @return boolean True if the save was successful
     */
    protected function saveLog()
    {
        $write = $this->currentData->asXML();
        return sugar_file_put_contents_atomic($this->logfile, $write);
    }
 
    /**
     * Sets the SimpleXMLElement log object
     * 
     * If there is an existing log, it will consume it. Otherwise it will create
     * a SimpleXMLElement object from a default construct.
     */
    protected function setCurrentLog()
    {
        if (file_exists($this->logfile)) {
            $this->currentData = simplexml_load_file($this->logfile);
        } else {
            sugar_touch($this->logfile);
            $this->currentData = simplexml_load_string("<?xml version='1.0' standalone='yes'?><entries></entries>");
        }
    }
 
    /**
     * Adds an entry of level $level to the log, with message $message
     * 
     * @param string $level The log level being logged
     * @param array $message The message to log
     */
    protected function appendToLog($level, $message)
    {
        // Set some basics needed for every entry, starting with the current
        // user id
        $userID = $this->getUserID();
 
        // Get the process id
        $pid = getmypid();
 
        // Get the message to log
        $message = $this->getMessage($message);
 
        // Set the timestamp
        $timestamp = strftime($this->dateFormat);
 
        // Add it to the data now
        $newEntry = $this->currentData->addChild('entry');
        $newEntry->addChild('timestamp', $timestamp);
        $newEntry->addChild('pid', $pid);
        $newEntry->addChild('userid', $userID);
        $newEntry->addChild('level', $level);
        $newEntry->addChild('message', $message);
    }
 
    /**
     * Gets the user id for the current user, or '-none-' if the current user ID
     * is not attainable
     * 
     * @return string The ID of the current user
     */
    protected function getUserID()
    {
        if (!empty($GLOBALS['current_user']->id)) {
            return $GLOBALS['current_user']->id;
        } 
 
        return '-none-';
    }
 
    /**
     * Gets the message in a loggable format
     * 
     * @param mixed $message The message to log, as a string or an array
     * @return string The message to log, as a string
     */
    protected function getMessage($message)
    {
        if (is_array($message) && count($message) == 1) {
            $message = array_shift($message);
        }
 
        // change to a human-readable array output if it's any other array
        if (is_array($message)) {
            $message = print_r($message,true);
        }
 
        return $message;
    }
}

The structure of the log

<?xml version="1.0" standalone="yes"?>
<entries>
    <entry>
        <timestamp>Wed Oct  8 11:56:04 2014</timestamp>
        <pid>89160</pid>
        <userid>1</userid>
        <level>fatal</level>
        <message>Testing out the XML logger</message>
    </entry>
</entries>

How to log only fatal logs to the XML log

<?php
LoggerManager::setLogger('fatal', 'SugarXMLLogger');
$GLOBALS['log']->fatal('Testing out the XML logger');
?>

How to log all logs to the XML log

<?php
LoggerManager::setLogger('default', 'SugarXMLLogger');
$GLOBALS['log']->warn('Testing out the XML logger');
Back to top

Speak well of your ex for your kids’ sake

Posted on June 29th, 2014 in For the ladies,For the men,On Relationships | No Comments »

Speak well of your ex... your kids need that from you.I saw this image posted on Facebook a few weeks ago and in the last few days I was reminded of it. In recent months I have encountered a few situations in which an ex, or soon-to-be-ex, was talking either to their children or around their children about the child’s other parent. In most cases when this happens the parent is respectful and mature enough to not bad mouth their ex or, short of that, they are at least somewhat strategic in the words they use or how they deliver their thoughts. I think this is important because defaming your kids’ other parent is both vicious and damaging, and will ultimately end up harming the kid’s relationship with their other parent.

While I think it’s important to treat everyone with respect, I think it is especially important to treat the parent(s) of your kids with respect, even if you have to struggle through doing it. And along with treating your ex with respect, I personally think it is equally imperative that you speak respectfully of your ex in the presence of your kids. I know you might not have any ounce of respect for your ex. And I know that your ex may have hurt you beyond imagination and because of that you can’t muster even the slightest positive thing to say about him/her. But that doesn’t give you license to harm your kid’s relationship with your ex.

If your kids are within earshot please have the courtesy to speak well of your ex or, at the very least, not speak of your ex at that time. If something happens to come on in a TV show or a movie that reminds you of your ex’s shenanigans, keep that to yourself for a bit. And if your kids have the unction to ask you about why you and your ex are no longer together, it’s ok to be vague to a degree. Saying things like “your mom liked other men more than she liked me” or “your dad is emotionally abusive and detached” might make you feel vindicated in the moment but can cause all sorts of confusion in your kid. There is nothing wrong with saying something like “we just couldn’t make it work and to make things as good as we could for you, we decided to split”. There can be a deeper discussion about that later, or even at that moment, without going into specifics. But at that moment the best thing you could do is protect your children and their relationship with your ex.

Now please understand that I am not saying that you need to lie to your kids, or that you need to keep them in the dark forever. But when they are still kids, or are not yet capable of completely digesting your anger toward, or hatred of, your ex, I personally believe it is best to shield them from potential harm to their relationship with your co-parent. It pains me when I hear people talking smack about their ex without even considering the words coming out of their mouths.

Back to top

A boy insulting another boy is not the end of the world

Posted on June 4th, 2014 in For the ladies,For the men,On Fatherhood,On Manhood,On Parenting,Personal Messages | No Comments »

tl;dr Boys are way different than girls and aren’t little meanies because they call another boy a name

Raising a son is hard. And I have to say that raising a son as a single mom or a mom with no help from dad is probably the hardest thing that can be done as a parent today because there are so many societal “norms” that are being applied to young boys that sometimes letting a boy’s natural character out means that he’s in some way a problem child. I am not complaining about raising a son in any way, shape or form. Instead I am saying that raising a son can be challenging, particularly when the natural character of a boy is at odds with what a parent, or society in general, deems appropriate.

The reason I say this is because of an incident I learned about today involving my son. He has had his share of scraps and run-ins this school year, and has been spoken to quite a bit for behavior and behavior related issues. To me, this is to be expected for an eight year old boy. Hell, when I was his age I was doing much of the same stuff he’s doing today. Pretty much every boy in my school was. I think that’s because, in general, boys have a way about them that is unique to boys. We are loud, aggressive, forward, vocal, sometimes condescending, sometimes domineering, sometimes mean and sometimes rude. I am not saying these are all good qualities. I’m just saying, put a group of boys (or men) in a room and in a short amount of time you will see all of these qualities manifest in some capacity among the males in the room.

As boys, we know this. We live this. We expect this from other boys. And because of that, we, as boys, challenge the norms that we are faced with (that is another quality of boys). When we see a boy that might be bigger, stronger, smarter, faster… our inclination is to establish dominance over that boy. We do that in various ways, from hurling insults to competing in sports to physically dominating another boy. And sometimes, as a stronger, smarter, faster boy, we are challenged by another boy trying to establish dominance of his own. Again, this is not only understood among boys, it’s expected. And how we as boys handle these situations begins to identify us among our sphere of influence. This process begins at a very young age and continues for most, if not all, of a man’s life. To understand this concept, observe a group of guys enjoying drinks and talking. How long does it take before one of the guys insults one of his friends, calls him a name or challenges his manhood? How long does it take for a man to establish his own amazingness by telling stories of his work, or how he handled a situation with a coworker, or how he handled something with his kids? It is the way we are with each other.

The incident that my son was involved in went like this… he was playing a game of Mercy with another boy. When the other kid lost, the kid began to whine about it to which my son replied “Stop being a little girl”. Now to those that don’t understand boys, this might come across as rude, condescending or even bullying. To those of us who grew up on the playground, we know this is a way of establishing presence and dominance among our peers. While I am not excusing the conduct of my son, I think it needs to be stated that among boys, games of strength and bravado always come at a cost in that there will inherently be a winner and a loser. In both the winning and the losing, there is a way to conduct yourself that is honorable among other boys. There are also ways to conduct yourself that are less than honorable among boys. So when a boy behaves in a way that is “dishonorable” among the group, it is natural for another boy to call him on that. This happens quite often in regular daily activities of a lot of men (and women, too, but probably not in as pronounced a way as with the guys). Again, I am not saying it is right or wrong, I am merely saying that this is to be expected, particularly among boys.

In the case of my son and his behavior, it is easy to look at him and say he was being mean or bullying the other boy. Personally, I think that’s a load of crap. Bullying, to me, would be something like my son seeing another boy, that he isn’t close with, wearing a pink shirt or sporting long hair and, out of nowhere, approaching him with a “What are you, a girl?”. To me, that is not only bullying but completely unacceptable behavior. It is unwarranted, unmerited and totally inappropriate. But in the case of two boys playing a game of strength and one boy losing then whining about it, to be derided for it in some way, to me, is not bullying. It is playground politics. It’s the same playground politics that say if we’re playing dodgeball and I know you can’t catch, you’re the target I’m throwing at. It’s the same playground politics that say if we’re playing tag and you’re the slow kid, you’re getting tagged first. And it is also the same politics that say if you’ve handled being the slow kid, getting tagged and not being able to get out of it while still being cool about it, you’re probably gonna end up being tight with a couple of dudes that will make sure you are never tagged.

Now moms, this is for you: boys and girls are different in many, many ways. How we feel things is different. How we respond is different. But trying to make your boy understand things from a girl’s perspective – or even YOUR perspective – will more than likely not work most of the time. While your boy may nod at you and say “yes momma, I understand”, the chances of it sticking with him are pretty slim. This is because you can never really take the character out of the boy. You can punish it, discipline it… even make him feel bad for it. But ultimately his character will continue to shine through – good or bad – and he will do what he will naturally do. If you are a single mom raising a son, or if your son’s dad isn’t as involved as he should be, please know that your best bet as his parent is to lead, coach and teach your son how to manage his boyness. Don’t condemn him for being what he naturally is. Don’t try to stifle his character or shut it down, but instead find creative ways to let that character of his flourish. No, that isn’t easy, but it is much less frustrating and much less likely to cause resentment from him later on life.

Back to top

The More Loving One

Posted on December 3rd, 2013 in Personal Messages,Poetry | No Comments »

From my earliest infatuation with poetry, the works of Wyston Hugh Auden have been my very favorite. While he was known for many great and artistic pieces of poetic literature, a select few of his poems have stood out to me immediately upon reading. I’ve said it before, if a piece of art makes me feel, makes me think, it will more than likely end up on my list of favorite things.

The poem The More Loving One is one of those works of art. It is a short, poignant poem about love or the lack of love returned, perhaps even an altogether indifferent response to a love declared. I won’t go into much more than that. But I will leave it here for you to enjoy.

Looking up at the stars, I know quite well
That, for all they care, I can go to hell,
But on earth indifference is the least
We have to dread from man or beast.

How should we like it were stars to burn
With a passion for us we could not return?
If equal affection cannot be,
Let the more loving one be me.

Admirer as I think I am
Of stars that do not give a damn,
I cannot, now I see them, say
I missed one terribly all day.

Were all stars to disappear or die,
I should learn to look at an empty sky
And feel its total dark sublime,
Though this might take me a little time.

Back to top

Do Not Go Gentle Into That Goodnight

Posted on November 29th, 2013 in Poetry | No Comments »

People that know me from way back when (like, high school kinda way back when) know that I’ve kinda always had a thing for poetry. I love reading it, I love writing it, I love analyzing it and interpreting it. I love when writers can capture a thought, a feeling or an emotion with the written word and convey it in a way that may seem to be one thing when in fact it is many, many things.

I also love poetry that stirs up thought and emotion within me. I have a few favorites that have always sparked me, like Sunday Morning by Wallace Stevens, Musee des Beaux Arts BY W.H. Auden and The Love Song of J. Alfred Profrock by T.S. Eliot. But there has always been one poem that has a different effect on me, one that leaves me throwing shadow punches and chanting “LET’S DO THIS THING!” to myself when I read it. That poem is Do Not Go Gentle Into That Good Night by Dylan Thomas.

This poem was written for his dying father and is in an uncommon format known as a villanelle. It screams of the final admonition of a son that will be losing his father shortly, an admonition in which he charges his father to not just accept the fate that is before him. It is a coming to grips with the inevitable, a catharsis if you will, in the life of a son that knows what is just around the corner for his father yet wants his father to fight on nonetheless.

I’m certain that when you read this you will understand what he is experiencing. And perhaps after you read it you’ll understand what it is that gets me so fired up when I read it.

Do Not Go Gentle Into That Good Night

Do not go gentle into that good night,
Old age should burn and rave at close of day;
Rage, rage against the dying of the light.

Though wise men at their end know dark is right,
Because their words had forked no lightning they
Do not go gentle into that good night.

Good men, the last wave by, crying how bright
Their frail deeds might have danced in a green bay,
Rage, rage against the dying of the light.

Wild men who caught and sang the sun in flight,
And learn, too late, they grieved it on its way,
Do not go gentle into that good night.

Grave men, near death, who see with blinding sight
Blind eyes could blaze like meteors and be gay,
Rage, rage against the dying of the light.

And you, my father, there on the sad height,
Curse, bless, me now with your fierce tears, I pray.
Do not go gentle into that good night.
Rage, rage against the dying of the light.

Back to top

Being thankful on Thanksgiving

Posted on November 28th, 2013 in Personal Messages | No Comments »

After a very quiet few years on this blog I’ve felt compelled to write again. I go through times where writing isn’t even a faint blip on the radar of my life. I also go through times where writing is my escape, my way of looking beyond where I am into a place where perhaps I’d rather be. And then I go through time where I want to write but can’t muster up the words I need to convey the reason behind my desire to write. Regardless, today is one of those days where I feel the desire to write so I shall let the words flow.

Thanksgiving is one of those holidays that, to me, really shouldn’t be a single day in the year as much as it should be a lifestyle. In any given day I have an abundance of reasons to be thankful, as most everyone is, yet I don’t bring attention to either the reason or the thanks that I have for it. What makes a single day so special that suddenly all of the things that I have been thankful for all year long are now all of a sudden worthy of finally receiving those thanks? Seems to me that there is something wrong with that. Of course I am talking about myself here, so please don’t take these words to be some form of judgment cast upon you or any of that. I’m just trying to resolve some of the thoughts I have had the past weeks leading up to today. Thoughts like “If the people in your life you loved the most were gone tomorrow, would they know today how thankful you are for them?”. Or thoughts like “When you are called to do a task, as much as you don’t want to do the task, are you thankful that you are breathing, have strength, can walk and move freely, and are well able to perform the task?”

While some of us are thankful for the tangible “things” in our lives – iPods and cars and large TVs and big, comfy houses – I believe there are others that are thankful for the much smaller, and to many, more insignificant, of things. Things like a warm jacket on a cold night or a bite to eat that fills a painfully empty stomach or a visit from a child that hasn’t been seen for months. As I look on the abundance that I take for granted every day I feel like I am kinda missing the mark on Thanksgiving, like perhaps my focus is off or I am simply looking at the wrong things. While I am thankful that I have an awesome job I get to go to everyday, driving my newer model car to the office listening to the music on my iPhone along the way, there are people that are thankful today that they have shoes. Just shoes. Maybe not even newer shoes. Just shoes.

So on this day of giving thanks I hope that I can maintain perspective. Don’t get me wrong, please. I do NOT apologize for doing well for myself or my family. I am thankful that I have been blessed with a provider mentality and that I CAN provide nicely for my loved ones. No, the perspective I am hoping for stems beyond that, to the core of my family and, more importantly, to the core of my life. When I sit around the dinner table tonight I will definitely be thankful for the abundant supply of food and drink before me. But my greater thanks will be for the family that sits before me.

I will be thankful for my daughters and my son, who daily show me many reasons for being thankful. I will be thankful to their mother, who has shown me so much more than I could have ever expected about relationship, parenting, love, patience and diligence. And I will likewise be thankful to her family for opening their home to my family and for always being so welcoming and inviting.

I will also be thankful for my parents – God rest their souls – for raising me to be the man that I am today while I was still yet young. And I will be thankful for my brother and sister who, when my father and then later my mother went to be with God, took up the reigns without needing to be asked to see to it that I would one day become the man that I was destined to be.

I will be thankful for my many long standing friends that have shown me recently what true friendship is all about over the long haul. And I will be thankful for my new friends that have so filled my life with love and warmth in recent years.

I will be thankful for memories of Thanksgivings past, of times spent roughhousing with my cousins at nine o’clock in the evening in a muddy front yard and of times spent trying to get the kids ready to go to two different houses in four hours on a cold afternoon.

I will be thankful for the years to come, the days to come, in which more memories will be made, more time will be spent and more love will be shown. I will be thankful for the future as well as the present, and for the past that it may ever move me forward to better things.

Today, and every day, I will remember the reasons to give thanks and I will give thanks for them. Not because it is Thanksgiving. No, I will give thanks simply because I am thankful.

Back to top

Negative number PHP array indexes, var_export and WTF

Posted on January 17th, 2013 in LAMP,PHP,Programming | No Comments »

Those folks that know me in the programming, web development or technology context know that I am a PHP fanboi to the nth degree. I eat, sleep, breath and live PHP. It is my very favorite programming language and it is the language that I learned how to program in. I stand behind it and have defended it – often – against the attacks of many a strict-type-language zealot from the world of .NET or Java or even Ruby. Seriously, I love PHP with all of $my <3;

However, these same people that know my insane and indescribable love for "my" language also know that I am usually very fast to point out some of it's major stupidities and illogical implementations. Which comes first, the $haystack or the $needle? Is it a str_* function or a str* function? Are the array function args passed by reference or am I expected to handle a return? There are so many of these little issues with PHP that sometimes I, myself, have no choice but to ask... WTF?

Today is one of those days. I am working on a bug for work in which the number -99 is somehow magically being transformed into -9223372036854775808 and is causing significant problems for our application. In doing some trouble shooting, I discovered that, as part of our process of caching some information, we use the var_export() function to write out an array to a file and somewhere between the passing of the data to var_export and the file that the exported data is written to, the -99, when used as an array index, suddenly became 18446744073709551517. This did not happen when -99 was the value of a scalar variable nor when it was a value assigned to an object property.

Looking a little closer I found that this particular server was running PHP 5.2.17 on CentOS, so I decided to dig even deeper and try this on other versions of PHP. On my 5.3.6 version of PHP on my Mac I could not reproduce the issue. But I was able to reproduce it on 5.2.17 on my Mac. My colleague was likewise able to reproduce it on 5.2.10 on his Ubuntu installation. And I was able to reproduce it on several PHP versions using 3v4l.org.

I'm not exactly sure what is going on under the hood, but my suspicion is that because PHP does not support unsigned integers it needs to convert the signed int -99 to an unsigned value in order to store it in the symbol table. I suspect when var_export is called, this unsigned value is being returned rather than the signed value. At the very least, this is an issue that will more than likely never be corrected since PHP 5.2 is now out of date and this problem, as far as I can tell, does not expose itself in 5.3 save for 5.3.3.

Regardless, if you want to see this for yourself and you have a 5.2 build laying around somewhere (or a 5.3.3 build), give this little snippet a shot and see what you get:

<?php
for ($i = 10; $i > -101; $i--) {
    echo "$i...\n";
    $q = array($i => 'this');
    var_export($q);
    echo "\n";
}

Or, if you just want to see it without a bunch of output, try this:

<?php
$a[-99] = 'bilk';
var_export($a);

As an added bonus, take the broken translated value and use that as an array index, then var_export that. You might pleasantly surprised by what you see I'd bet.

All of this is to say, if you are still using PHP 5.2 - and let's be honest, who is really using PHP 5.2 any more aside from those that have it on a test server - and you are using var_export on an array with signed int indexes, you are probably not going to get what you expect out of it. You have been warned.

Also? WTF PHP?

Back to top

Bidding farewell to 2012

Posted on December 31st, 2012 in Personal Messages | 1 Comment »

It seems to be a common thing for me, at New Years, to write a post about the year that is being put to rest and/or about the year that is about to be birthed by the changing of the clock at midnight. I’ve recently read posts I’ve written from the end of 2005, the beginning of 2008, the end of 2008, the end of 2009, the beginning of 2011 and the beginning of 2012 and I have to say it is fascinating to look back on the last few years and see where the year end had brought me.

Tonight I am looking back over 2012 as I sit in my family room listening to my daughter Sarah play the piano. The rest of my family is in the living room watching TV, playing on their iPhones or fiddling with a 3DS. It is a relatively quiet night in the Gonzalez house, and it is a perfect night to reminisce.

There were some things that happened in our family in 2012. They weren’t necessarily earth shattering events, but they have had a definite impact on the landscape of the Gonzalez house and the Gonzalez family in general. Of course, there were many events that took place in 2012 that I could be talking about, but the following seemed to be the most prominent in my mind as I write

  • I got a new job – Starting in the second week of January I went to work for SugarCRM as a software engineer. This could very well be the single most significant job change I have ever made in my life simply because of how much I love the company I work for, the work that I do and the people that I do it with. I have never been so happy in my work as I have been the last year being a “Suga” and I am so looking forward to what 2013 has in store for me personally as well as for my company.
  • We added a new member to our family – In June of this year we brought home Molly, our little shitmaker/noisemaker/smilemaker of a dog. She has been a wonderful addition to our family – as much as I might not like to admit it – simply by the energy and love she brings to our household. She is an amazing playmate for Rico, she is a great little watchdog and she is full of excitement and adoration for everyone in the house. Our home is definitely warmer because of her.
  • We added some boys to our family – Yes, my oldest daughters were officially given the go ahead to call their close male friends “boyfriends”. Both Sarah and Rebekah developed very strong relationships with their significant others and both of these boys have found a place in our family. They are very respectful (and only slightly fearful of me – but it’s a healthy fear) and very courteous to both Sandi and I. They are fun to have around and, most importantly, know how to treat my daughters.
  • We took a trip to Oz – My three youngest kids each starred in two separate performances of The Wizard of Oz over the summer. This is the second summer they have performed in a kids theater production and this year they decided to participate in TWO productions that ran back to back weekends. In one production, AJ stole the show as the Cowardly Lion and in the other show, Adriannah did. All three kids performed their hearts out and had fun doing it, and in turn, I enjoyed working my tail off to make sure they had the summer of their lives in theater.
  • iGot bit by iPhones – Well, the kids did anyway. Adriannah earned enough money for her birthday this year to be able to buy herself her own iPhone, and with the upgrades available, Bekah got her upgraded iPhone as well. In all, we now have four iPhones in our household and as you can imagine, with the propensity for theatrics that this family possesses, it didn’t take long for videos and pictures to start creeping up highlighting just how creative the kids are, even with something as tiny as an iPhone camera. Sarah started her own YouTube channel and Adriannah began recording these amazing videos using an app called Video Star. You will be seeing some of those in the coming months I assure you.
  • I got a new car – I had to. It was time. My Vibe died on me for the last time and, although I did not want to do it, I bit the bullet and decided to pony up for a new ride. So in August I purchased a brand new Mazda3 Touring sedan and I gotta say, I kinda love that car. The gas mileage is insane, the look and feel is very nice and the kids fit in it when I take them to school. As much as I did not want to buy a new car, I am very happy with my car and with Tony Roberts and Dublin Mazda for making that deal one of the best transactions I’ve ever had, let alone for buying a car. If you are in the East Bay Area and are in need of a car and are looking for a smooth transaction, go talk to Tony Roberts at Ken Harvey’s Dublin Mazda. My experience was so good, I actually Yelped them. :)
  • Obama won the presidential election – Much like 2008 when Obama won the presidency, there was much talk of politics, policy and government in my house for a number of months leading up to Super Tuesday. As just as I was devastated in 2008 by his victory, so again was I disappointed in the choice our country made for president. However, what’s done is done and though there is still much talk about politics and governments – and just as much snark and whining from both of the major political parties and their followers – I am happy that the election once again brought about discussion within my family. Regardless of your political bent, when parents and children can come together to talk politics and, in some cases even debate politics, it is a good thing. I learned stuff about my kids I didn’t know. I learned some of their political viewpoints are divergent from mine (which I am totally fine with) and in some cases, they are more extreme in their views than I am. I learned that regardless of political viewpoint, friendships must necessarily extend beyond these viewpoints. And I learned that Facebook is a treasure trove of extremists from all walks of life that love to spew their political venom far and wide. Still, if there is nothing else that I will take away from this election, I can say that my kids were once again very informed, very involved and very interested in the election process and the election results.
  • Violence took it’s toll on the United States – While the most prominent incident of the year in the United Stated was the massacre at Sandy Hook Elementary School, there were undoubtedly many more killings in the United States. But one thing that the Sandy Hook incident seemed to do above anything else was bring attention to guns. My heart goes out to the kids and teachers that were senselessly gunned down by a disturbed idiot that was hellbent on killing innocent people. Equally, my heart goes out to the thousands of other victims of violence – both gun related and not gun related – because their story should be heard as well. As saddened as I am by the violence in our country, I am now ever vigilant of the safety of my household and my family. Being aware is the first step toward actively protecting a family in my opinion and with that, the knowledge that guns – even assault weapons – do not somehow spontaneously sprout an evil conscience and decide to start killing people. I’ve been appalled at the apparent lack of regard for the second amendment by many highly visible members of our state and federal governments and hope that, like the discussions that took place in our household after Sandy Hook, there will be a long, open discourse on the proper actions to take to curb violence in our country. And I pray to God it doesn’t involve rewriting our constitution to further the police state in which we live. Regardless, my family was brought together by the tragedies that unfolded over the course of the year, and many talks were had to discuss just what is at the root of all of this. So even in the midst of tragedy and evil, my family came together and was strengthened.

There were many other notable events of 2012, including a Mayan Apocalypse that never came to pass, the San Francisco 49ers almost making it to the Super Bowl while I was there to witness it and the San Francisco Giants winning the World Series for the second time in three years. There was a retirement of a space shuttle. There was Felix Baumgartner sky diving from outer space. There was the Grumpy Cat. There was the massive response to FunnyJunk’s and Charles Carreon’s lawsuit against Matthew Inman from the Oatmeal. There was just so much stuff in 2012.

Alas, it is time that I wrap it up, lest I go on and on about all that 2012 brought to the table. But as I leave you with this, my final post for 2012, I would like to reach back to 2009, when Sarah penned this little New Years poem and I’d like to offer up this simple blessing to you and yours: May your 2013 be orders of magnitude more amazing than your 2012 and may you be showered with favor, fortune, blessing and abundance. Happy New Year.

On the day of New Year’s Eve
The world is sitting, waiting
For the day we all believe
Has cause for celebrating.

Staying up till late at night
Watching on TV
Down pole to drop a ball of light
And then we scream, “Yippee!”

Another year is o’er and done
And we are satisfied
Recalling days of mirth and fun
And fear, and hope, and pride.

Another year has started up
A new age will begin
We drink from a newer cup
And cast the old to the wind.

– Sarah Gonzalez, 13

Back to top

Why flawed CA Prop 37 should not be passed

Posted on October 15th, 2012 in On Politics,Personal Messages | No Comments »

There has been much talk in the past few months of the upcoming election. And while most talk has centered around who should win our vote for president, there is a growing discussion in my home state of California surrounding a number of proposed measures. Of these, Proposition 37 is one of the more widely debated ballot measures.

At the core of it, the measure appears to seek approval of the people of California to enact a law that will require “labeling on raw or processed food offered for sale to consumers if made from plants or animals with genetic material changed in specified ways” and will also prohibit “labeling or advertising such food, or other processed food, as ‘natural’”. On the surface, this seems like an absolutely wonderful ballot measure, as it will mean that the people of California will finally be able to know which foods they are considering buying or eating that might be genetically modified (GMO) or genetically engineered (GE) while at the same time putting the onus of labeling these foods on the manufacturers and producers of these foods. But as I read the text of the measure, it has become clear to me that the responsibility for labeling seems to lay much closer to the consumer while putting no real accountability at the source of large food manufacturing and the most prominent sources of food distribution.

Prop 37 will put the bulk of the responsibility of the labeling of foods on the retailer of those foods:

Retailers (such as grocery stores) would be primarily responsible for complying with the measure by ensuring that their food products are correctly labeled. Products that are labeled as GE would be in compliance. For each product that is not labeled as GE, a retailer generally must be able to document why that product is exempt from labeling.

Other entities throughout the food supply chain (such as farmers and food manufacturers) may also be responsible for maintaining these records.

Prop 37 will likewise open the door to unsubstantiated lawsuits surrounding the labeling of foods such that someone can in fact bring a suit against the retailer that sells the product in addition to the wholesaler that moves it regardless of whether there was any damage done because of the labeling violation:

Litigation to Enforce the Measure. Violations of the measure could be prosecuted by state, local, or private parties. It allows the court to award these parties all reasonable costs incurred in investigating and prosecuting the action. In addition, the measure specifies that consumers could sue for violations of the measure’s requirements under the state Consumer Legal Remedies Act, which allows consumers to sue without needing to demonstrate that any specific damage occurred as a result of the alleged violation.

Additionally, there are several glaring exemptions allowed in this measure that are troublesome, if not down right confounding:

The measure also excludes certain food products from the above labeling requirements. For example, alcoholic beverages, organic foods, and restaurant food and other prepared foods intended to be eaten immediately would not have to be labeled. Animal products— such as beef or chicken—that were not directly produced through genetic engineering would also be exempted, regardless of whether the animal had been fed GE crops.

This means that beer, wine, spirits and other alcohol drinks will not have to abide by this law. Likewise, restaurants that sell GMO/GE food – restaurants like McDonald’s, Taco Bell, Outback Steakhouse, Chili’s, etc – can still sell GMO/GE food without you ever knowing about it. Additionally, and this is a big one in my opinion, animal products – chicken, beef, pork, eggs, milk, etc – that are not directly GMO/GE but that were fed GMO/GE feed will not have to be labeled as GMO/GE.

I’m of the opinion that, in the end, if this measure passes, all that will end up happening is grocers will up their prices to offset the cost of verifying proper labeling, small producers and farmers will suffer tremendous cost increases in production to either comply with the law or find ways to exploit loopholes and larger producers will have already discovered ways of circumventing this law by way of the many loopholes and exemptions in it. Meanwhile, large prepared food providers will continue to sell GMO/GE food for immediate consumption, the Monsantos of the world will continue to rake in huge profits from their GE foods and food products and will assist the larger food producers in bucking the system while the small farmer is left trying to figure out how they will stay in business.

As bad as I want proper labeling of foods, I just don’t think Prop 37 is the right path to it. It leaves entirely too many ways for the bad guys to win at the expense of the good guys while burdening the grocers that we frequent and not really providing much coverage for the end consumer. It might sound controversial, but there is just no way I can vote for this measure as it is worded. If the exemptions weren’t in place, I’d vote a big fat YES for it. But until that happens, my vote is in favor of keeping the playing field level for small food producers, local farmers and grocers.

References:
Prop 37: Read the Text | Propositions | Elections 2012 | KCET
California Proposition 37, Mandatory Labeling of Genetically Engineered Food (2012) – Ballotpedia
California Secretary of State, Prop 37 (PDF)

Back to top