The More Loving One

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.

Do Not Go Gentle Into That Goodnight

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.

Being thankful on Thanksgiving

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.

Negative number PHP array indexes, var_export and WTF

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?

Bidding farewell to 2012

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

Why flawed CA Prop 37 should not be passed

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)

Why I love working for SugarCRM

SugarCRM Chrome Bottle Opener It’s not everyday that a man finds work that he loves. Hell, in today’s economy, a lot of men can’t find work at all, let alone rewarding work that he enjoys. I’m one of the fortunate few who has been very blessed in my career path as it relates to doing work that I enjoy doing, being good at what I do and being able to provide for my family. But I have to say that I have never been quite as happy with my job as I have been since January of this year.

Backstory
In mid-December 2011 I was approached by a recruiter through email. Why I remember this is pretty simple: he didn’t sugar coat his email with a bunch of recruiter mumbo jumbo and buzzwords, nor did he include a job description or any of that. He straight up said he was a headhunter and was looking for a Senior Software Engineer for a well funded, private company in the bay area. After a couple of emails, we setup a time to talk on the phone. That in and of itself is a rare occurrence because I don’t talk to too many recruiters since most bomb out during the email phase. But what made this an especially odd thing was that as we talked, he engaged me very quickly about what I like to do, what I am good at and what I wanted to do with my career. We talked for about a half hour and he asked me if I’d be open to interviewing with his client if he could get me in for an interview. I told him I would be for a couple of reasons, the most prominent being that A) I was looking for work as I wrapped up a short term contract project, and B) the company he was talking about – SugarCRM – was a company I had known about and was interested in for quite some time. This call took place on a Friday. On Saturday he called me to tell me that he had scheduled an interview for me on Monday, December 19 at 2:00 in Cupertino. And from here on begins the real story of why I love working for SugarCRM.

In the beginning
The Monday that I was supposed to interview came around and I hadn’t heard from the recruiter. I thought it was kinda odd but figured that maybe something needed to be hashed out on his end so I went about my business that day. Then, at about 12:30, I got an email from him with the address for SugarCRM and a message saying they were expecting me at 2:00 pm. Since I was still out with the kids I had to hustle home and get myself somewhat presentable for an interview at 2:00 in Cupertino. I did my best, and managed to get some jeans and a golf shirt on before heading out the door. I got to Sugar just before 2:00.

I was given some papers to fill out while I waited for the person that was going to interview me to come get me. Turned out, there were several people that were going to interview me and the first fellow came out pretty quick. As we walked through the halls toward the interview room I began to get a little nervous. But once we sat down and started talking, I had the pleasure of experiencing the funnest interview I had ever been on. I actually interviewed with three different Engineers, all of whom asked me questions that were both challenging but practical. And all of them had a coding exercise that we worked on together to solve. I got a really good vibe from the first three guys but when the fourth person walked in, things changed a little bit. You see, the fourth person was a VP and there really weren’t any technical questions at that point. From there it became more a matter of when I could start and some of the other logistical questions that you might find in the late stages of an interview. And when I left there, just before 5:00, I had an odd sense that it might have gone pretty well. I didn’t know how well until, about 20 minutes later, I got a call from my recruiter telling me they had drafted an offer letter for me.

I started working for SugarCRM on January 9, 2012. My first day at the office was the first day of the 2012 Sales Kickoff week. It was also the first day of an Engineering Sprint featuring a good number of engineers, including all HQ engineers and remote engineers from just about everywhere. It was chaotic to say the least, and the pace in the office that day was absolutely frenetic. In all honesty, I was a little taken aback by it all because I had never been involved in such a large scale engineering effort nor had I ever been part of a large engineering team before. But after spending my first day getting my development environment set up, I was off and running with my first assigned tasks. Looking back on those first few days at work now feels like a big blur because of how fast things went, how much I learned and how many people I met. It was a crazy, fast, amazing week and without a doubt, it was the best first week I’ve ever had at a new gig ever.

Can it really be this good?
Fast forward to today. I’ve been with Sugar for six months now. I’ve learned a lot about our product, our codebase, our engineers, our company and our future plans. I’ve survived the on-boarding process, made it through a couple of team transitions and have made some pretty decent contributions to the application. I’ve made some friends, helped some folks and have essentially become part of the team. But of all the things that the last six months have brought to my life, what stands out to me the most is how much I enjoy going to work everyday.

It might sound strange to hear someone talk about how much they love their job. I know there are a lot of people that are either out of work right now or are working at a job that is killing them slowly. I’m not trying to make anyone jealous, but I am happier in my work now than I have ever been before. And anyone that knows me knows that this is not only a truth but one that I’ve not been able to say for a long, long time.

So what is it about my job that makes it this good? Well, I’ve been thinking about that as I drive to and from work from time to time (one of the many things I love about my job is the ability to work remotely). So I decided that I’d share the love a little bit. I mean, you never know, you might just be an engineer looking for a new place to call home, right? :) So here are just some of the reasons why I absolutely love working for SugarCRM, in no particular order and not necessarily inclusive of all of the reasons I love this place.

  1. What we’re working on
    I’m not sure if everyone knows yet just what CRM is. I know I didn’t until my last job, and even then, it wasn’t nearly as clear to me as it is now. Customer Relationship Management… it sounds like an industry buzzword used by someone trying to sell you something when you read it like that. But when you listen to our founder – Clint Oram – describe his vision of CRM, and what gave him the idea to develop a CRM application to begin with, you’ll see that what we are working on at Sugar is so much more than an application or a buzzword. We are working toward the success of every organization that chooses our software and services. We are working on the notion that if we can help others become successful we in turn can become successful. And the vision that our company has to ensure the continued success of our users floods our entire engineering organization. There’s just something exciting about working toward a goal that is bigger than you.

  2. How we’re working
    If, as an engineer, you’ve never been involved in agile development you are missing out. I had never been involved in true agile development, although I had employed some of the methodologies in previous jobs, so that was a bit of a shock to my system at first. But it happened that I learned to love it pretty early on and have been able to embrace the speed and iterative nature of it. There is also something to be said about accountability, which agile also necessarily involves, and the freedom to engineer in the way that works best for you while taking full credit for your successes and standing behind your mistakes. Yes, I said mistakes. They happen, even (if not especially) in agile environments. And the best part about that is, when things break, no one flies off the handle or starts panicing. You simply engineer your way through it and let your brilliance flow.

  3. Who’s doing the work
    There’s something to be said for working with absolutely brilliant people, especially when those people are really cool and really friendly while being brilliant. I have the pleasure of going to work everyday with some of the smartest, most intelligent, sharpest minds that a company could put together. These folks are from all over the world as well as right here in the United States (some are even in Cupertino ;) ). The engineers that I get to work with are never short of ideas, never slow to offer help, are always thinking of new and challenging ideas, and simply do not even consider that something can’t be done. And it seems that there isn’t a single person in Engineering and Development that doesn’t always have some sort of idea, some knowledge that you never even knew existed or some way of doing something that is totally fresh and new.

    Something else that totally amazes me everyday are some of the names within the PHP community that I get to work with. I know that distilling things down to PHP seems a little concrete in nature, but anyone that knows me knows that I am a PHP fanboi to the core. It’s the language I learned on and the language that has led to the career that I enjoy. So for me, getting to mix it up with some of the more well known names in the PHP world on a daily basis is kind of amazing. I won’t spill the beans on these people are out of respect for their privacy, but if you are as in love with the PHP language as I am, then you’d love working here.

  4. What we’re working with
    As much a fanboi as I am of PHP, I am more a fan of doing things the right way and the best way possible. To that end, PHP is NOT the end all, be all of technologies even if it is the core technology of the product we ship. And that right there is another thing I love about Sugar. We use tools from a mixed bag of technologies. We use Ruby applications, Python applications, Java applications… we use different databases, different environments and different platforms. There isn’t anything that is really off limits when it comes to making our jobs more efficient and more effective. And this appeals to me greatly because that means that whatever is the best tool for the job, that’s the tool we get to use, even if we don’t know it that well or it isn’t the same platform as our product is.

  5. Freedom to be creative
    I’m pretty sure that of all the cool qualities of working at Sugar this one right here is the one that speaks the loudest to me. Never before have I been a part of an organization that literally puts you in the driver’s seat. When you’re given a task, you own it. What you build, you stand behind. It’s yours. And whatever it takes to allow you to be able to produce something worthy of putting your name on it, you’re allowed. Need snacks, coffee, red bull or chips? Done. Need beer? Done. Need leather couches to kick back on while you code? Done. Need to take a break and school an intern on what ping pong is really about? Done. Or perhaps you’re feeling like working in the office isn’t the best way to get things done for the day. Perhaps you want to work at a local coffee shop or even work at home. Well, guess what? You can do that to. You are literally put in command of your own destiny and given whatever tools you need to be a successful engineer.

    I don’t think I’ve ever been as productive in my work, and in as enjoyable a fashion, as I have been while at Sugar. For me, there hasn’t really been a way to not be productive because whatever makes me the best programmer I can be for that day is offered to me.

  6. The learning never ends
    Not a week goes by that I don’t learn something new from someone. The experience that our engineers have, the curiosity that we all have, the development we are all doing leads us down a path of continued learning that can only make us better as we progress toward our goals. I mean, just in the last four weeks alone, I’ve learned more about Javascript than I think I had ever known before, I’ve learned about PHPUnit data providers place in the call stack and I’ve learned about Git submodules. In the weeks and months prior I’ve learned about some oddities in the way that Google manipulates email headers when being sent through their SMTP gateway when using credentials that don’t match the sender information, I’ve learned about licensing variations and I’ve learned how to automate some common development tasks by creating macros in my IDE. I am always learning, and at the same time, I am teaching. Which allows our entire team of engineers to continue to sharpen our skills while helping other engineers sharpen theirs.

Wrapping it up
I know it sounds a lot like I’m doting on my company. The truth is, I am. I am quite literally happier in my work now than I have ever been before. I feel a sense of purpose, a sense of determination and a sense of pride in doing what I do. I feel like there is a much bigger effort at play and that, while my contribution to that effort might be small, it is still significant. And even though I’ve laid down probably 2,500 words to describe why I feel this way, those words still fail to capture the essence of why every software engineer should have the experience of working at SugarCRM.

To that end, let me say that I am so not ashamed to plug the employment opportunities at Sugar right now. We are growing so fast right now that, even though we are bringing new engineers in regularly, we are still looking for top level talent. So if you’re looking for a change in your career, and you are stellar software engineer, you really should give us a look. Making that choice has been one of the best things I’ve ever done in my life.

FULL DISCLOSURE NOTICE: The links to the open positions at SugarCRM that I’ve added to this post contains information that will associate your click through and subsequent interest in SugarCRM jobs to me. It is yet another perk of the job, getting bonuses for bringing new talent on board. If this troubles you feel free to hit the SugarCRM careers page directly. Just know that if you do that, Cthulhu will invade your sleep and eat all the kittens that you dream about nightly. Ok, that probably won’t happen, but if it does, you can’t say I didn’t warn you.

Pair programming with a child

While driving home today my daughter Alaynah asked me a little bit about what I do. After explaining to her that I am a software engineer and that I write programs, and telling her that my programs run on the internet, she asked me how Google makes that little box “that you type in to look stuff up”. I told her when we got home I’d show her since it was pretty easy to do.

When we got home we got to work. And a coupe of minutes later we had a very simple web “program” that took some text in a text box and wrote it out to the screen a certain number of times, each time making the text bigger. Not a lot of action going on there, but still something she could see that involved a text box and some programming logic. And as uneventful as this little application might have been, what it led to was amazing to say the least.

As we started to look at the words “Awesome Alaynah” explode onto my monitor in ever growing size, Alaynah began to look at the lines and count them to make sure there were as many lines of repeating text as she had selected. So we decided that it would be easier if there were numbers next to each line so we could see just how many lines were on the screen. Then, after she saw that, she asked me “is there a way to make it so if you click on a line, that all of the lines after it just disappear, including the line that you clicked on?”. I told her that I was sure there was, but that we needed a different kind of programming for that (since our original program was all PHP and click events, while potentially served by the server, are better handled on the client). So I went and got us jQuery, included it and wrote the code that made the lines disappear from the line you clicked on.

As she sat in amazement watching the lines disappear when clicked you could see that there was something troubling her. It was almost as if, when the lines were disappearing, that they were gone forever and ever. So I wrote a little bit of code that would bring the lines back if you wanted them back. She loved that. Except for the text to bring the lines back was “Bring them all back”, which works in all cases except if you disappeared the last line, because there aren’t any “all” lines, only “the” line. So she told me that we needed to change it so that if you removed the last line that to bring it back, the program should say “Bring it back” instead. So we fixed that, and after only a few minutes of conceptualizing, programming, testing, using and refactoring, Alaynah and I had put together a little program that we were both pretty proud of. You can view the source of this little program here.

Now aside from the obvious goodness that is my eight year old daughter (who happens to be turning nine tomorrow) taking an interest in the work I do, I have to say that having time to spend with my daughter – just her and me time – was a blessing. I don’t get a whole lot of one on one time with any of my kids. And even though this was only a few minutes, it was a cool few minutes that let me show my daughter what I do, let her do it with me and let us both enjoy some quality time together. I’m certain I would have loved it just as much if we had been talking about dolls, mud, cartoons or our favorite foods, but the fact is, we were talking about programming, my work, her ideas and our time together. There is a lesson in this for any parent. If your child shows any kind of interest in what you do, take the time to show him/her what it is you do. Don’t explain it with words and leave it at that. If you can take the time to allow your kids to connect with you while learning you, take that time. No excuses, no fussing, just do it.

She and I had an awesome time with this, even if it was only a few minutes. It was a great time and I am glad I didn’t pass it up because I was tired, wasn’t interested or was just unavailable.

View the source of our little program
Our original code was a little more rough around the edges than this one. After we got it working the way we wanted it I went through and cleaned things up a bit, added some comments, pulled out duplicated javascript code segments, etc. So the final product is a cleaned up rendition of our original stuff, which we hacked together very quickly in an effort to make it just work.

<?php
// Iterations max limit
$max = 30;
 
// Iterations min limit
$min = 5;
 
// User supplied iterations count
$limit = null;
 
// Handle posted values
if (!empty($_POST['limit'])) {
	$limit = intval($_POST['limit']);
	if ($limit > $max) {
		$limit = $max;
	}
 
	if ($limit < $min) {
		$limit = $min;
	}
}
 
$words = empty($_POST['words']) ? null : $_POST['words'];
?>
<html>
<head>
	<title>Alaynah's program</title>
	<style type="text/css">
		#putitback {
			color: #008;
			cursor: pointer;
			text-decoration: underline;
			margin-top: 20px;
		}
 
		.index {
			display: inline-block; 
			width: 50px;
		}
	</style>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script type="text/javascript">
		$(function() {
			// Set the row prefix
			var rowprefix = 'row-';
 
			// The id of the clicked row to make hide from
			var rowid;
 
			// Row toggler, makes rows appear and disappear
			function toggleRows() {
				for (var i = rowid; i <= <?php echo $limit; ?>; i++) {
					$("#" + rowprefix + i).toggle();
				}
			}
 
			$('.row').click(function() {
				// Get the row id that was just clicked
				rowid = $(this).attr('id').replace(rowprefix, '');
 
				// Handle visibility toggling
				toggleRows();
 
				// Set our message for restoring rows
				var message = 'Put them all back.'
				if (rowid == <?php echo $limit; ?>) {
					// Alaynah was smart enough to see that if you only plucked
					// the last row the message should be singular
					message = 'Put it back';
				}
 
				$('#putitback').text(message);
			});
 
			// Handle restoring "removed" rows
			$('#putitback').click(function() {
				// Handle visibility toggling
				toggleRows();
 
				// Clear out the restore link since everything is back to normal
				$(this).text('');
			});
		});
	</script>
</head>
 
<body>
<h1>Alaynah&apos;s program</h1>
<form action="" method="post">
	<p>What do you want to write? <input type="text" name="words" value="<?php echo $words ?>" /></p>
	<p>How many times do you want to see it? 
		<select name="limit">
			<?php for ($i = $min; $i <= $max; $i++): ?>
			<option value="<?php echo $i ?>"<?php if ($i == $limit) echo ' selected="selected"'; ?>><?php echo $i; ?></option>
			<?php endfor; ?>
		</select>
	</p>
	<p><input type="submit" value="Hit it!" /></p>
</form>
<?php if ($limit && $words): ?>
<hr />
<?php /* Loop $limit times and make the displayed text grow each iteration */ ?>
<?php for ($i = 0; $i < $limit; $i++): $c = $i + 1; ?>
	<div class="row" id="row-<?php echo $c ?>" style="font-size: <?php echo (14 + $i); ?>px;">
		<span class="index"><?php echo $c; ?></span>
		<span><?php echo $words; ?></span>
	</div>
<?php endfor; ?>
<div id="putitback"></div>
<?php endif; ?>
</body>
</html>

Storing singleton objects in PHP sessions

A friend of mine, who is working on a sick little diet and exercise tracking application, asked me today if PHP allowed singleton objects to be stored in a session. My first reaction was absolutely they can be so long as you follow the normal rules of unserializing objects in PHP… namely, making sure the class is in scope before attempting to create an object from it OR having an autoloader that does that for you. But as I thought about it more I began to think that maybe this might not work as expected since singletons generally have no public access to their constructors. However, when an object is unserialized, it is instantiated, for lack of a better term, and populated with the data that was exposed from the serialization process.

Note: for those of you that are unfamiliar with the way PHP handles session data or are just wondering why I am using serialization so much in my examples, the basics are you start a session and PHP assigns a random MD5 hash to it as an id. You write data to the session via the $_SESSION superglobal array and when the script terminates or you call session_write_close(), PHP serializes the $_SESSION array and writes that serialized string to the file system for retrieval on subsequent requests so long as the session time limit has not expired. I really did not want to run this entire session process and inspect what was being written to my file system so I decided to mock that interaction myself by creating an arbitrary array, serializing it, grabbing the serialized string and unserializing it.

As I began to dig into this I started playing with PHP’s magic __sleep() and __wakeup() methods. Those seemed to do what I wanted them to do except in the case of protected and private properties of my class. As soon as I added those in my serialization took a crap all over itself, even when I cloned the singleton object and got the public properties exposed through get_object_vars(). So, thanks to the PHP manual – the most awesome tool in any PHP developer’s arsenal – I discovered the PHP Serializable interface.

This interface defines two methods: serialize() and unserialize(). These methods override the default behavior of __destruct() and __construct() so if you are using these you should keep that in mind and either put your __destruct() and __construct() code into these methods or allow for calls to __destruct() and __construct() from within these methods. Your homework is to decide which is the better implementation. :)

Now, back to the lesson at hand… the following object – let’s say it is saved to a file named dummy.php – is a super simple implementation of a basic singleton pattern. It includes both a serialize() and unserialize() method to allow it to be serialized for storage.

<?php
class DummySingleton implements Serializable {
    /**
     * Test properties of various visibility
     * @var string
     */
    public $dProp;
    public $dPropX = 'Nothing to see here folks';
    private $_prop = 'y u try see dis?';
 
    /**
     * Instance holder for this singleton
     * 
     * @var DummySingleton
     */
    private static $_instance = null;
 
    /**
     * Private singleton constructor, simply sets a property
     */
    final private function __construct() {
        $this->dProp = 'I was finally built';
    }
 
    /**
     * Singleton instance getter
     * 
     * @return DummySingleton
     */
    public static function getInstance() {
        if (self::$_instance === null) {
            self::$_instance = new DummySingleton();
        }
 
        return self::$_instance;
    }
 
    /**
     * Implementation of the Serializable interface, called automatically just 
     * before this object is serialized. This will override any calls to a
     * __destruct method, so if you have a destructor you should call it from
     * here.
     * 
     * @return string
     */
    public function serialize() {
        return serialize(get_object_vars($this));
    }
 
    /**
     * When this object is created from an unserialization this method is called. 
     * It implements the Serializable interface and uses the data from the 
     * serialize() method herein. Since this method overrides the __construct
     * method you should make any accomodations for constructing your object
     * in this method.
     */
    public function unserialize($data) {
        // "Instantiate" our singleton
        self::getInstance();
 
        // Set our values
        if (is_array($data)) {
            foreach ($data as $k => $v) {
                $this->$k = $v;
            }
        }
    }
}
?>

If you build up this object then serialize it, then rebuild it from the serialization, you can see that it remains in tact. Let’s test this by simulating the session array, first creating an array then adding the DummySingleton object to that array, then serializing it:

<?php
// Grab the class
include 'dummy.php';
 
// Get our instance
$o = DummySingleton::getInstance();
 
// Set something into it for testing
$o->setFromOutside = 'What the hell is this madness?';
 
// Make an array of stuff
$a = array();
$a['name'] = 'Robert';
$a['id'] = 23;
 
// Add the singleton
$a['dummy'] = $o;
 
// Serialize it
$s = serialize($a);
?>

The serialized output from this yields:

a:3:{s:4:"name";s:6:"Robert";s:2:"id";i:23;s:5:"dummy";C:14:"DummySingleton":187:{a:4:{s:5:"dProp";s:19:"I was finally built";s:6:"dPropX";s:25:"Nothing to see here folks";s:5:"_prop";s:16:"y u try see dis?";s:14:"setFromOutside";s:30:"What the hell is this madness?";}}}

If you take that string and subsequently load it and unserialize it then inspect it, you’ll see that the singleton object has been restored along with all private properties of it:

<?php
// $s is our serialized string from above
$o = unserialize($s);
var_dump($o);
?>

Output:

array(3) {
  ["name"]=>
  string(6) "Robert"
  ["id"]=>
  int(23)
  ["dummy"]=>
  object(DummySingleton)#1 (3) {
    ["dProp"]=>
    NULL
    ["dPropX"]=>
    string(25) "Nothing to see here folks"
    ["_prop":"DummySingleton":private]=>
    string(16) "y u try see dis?"
  }
}

Since this is, in essence, the process that PHP follows for its default session management it’s safe to say that you can, indeed, store singleton objects in a PHP session. Now onto to bigger and better questions, like…

Why would you ever want to store a singleton object instance in a PHP session?

Javascript, WebKit and ‘closed’

The other day I was playing around with a simple letter scrambler script that I had written to assist my daughter with a birthday party game. The concept is simple enough… enter a phrase, hit a button and the phrase gets “cryptoquoted”, a process where each letter in the phrase is substituted with another letter. One of the things I designed this program to do was hide the input box so that, if you were viewing it on the web, the solution would not be visible to anyone looking at the puzzle. But I also programmed it so that if you click a link, the input box would be revealed. This toggling of the visibility of the input box is simple enough to do. Just add a little jQuery and BAM!, you have a simple revealer.

And this is exactly how this performed until the last time I tried it a couple of days ago. My toggler suddenly stopped working right, but only in Chrome and Safari. All of the javascript was firing in the proper order, and the function I had written was being called but my slider was not sliding. After digging into this a little bit, and doing a bit of debugging, I found out that a variable name I was using the monitor the state of the visibility of the input box was being clobbered in Chrome and Safari. Firefox worked just fine as it always has. The variable name I was using was closed.

// Set the closed flag
var closed = true;
 
/**
 * Toggles visibility of the input box
 */
function toggleSolution() {
	if (closed) {
		closed = false;
		$('#puzzle-key').slideDown();
		$(this).text('Hide solution');
	} else {
		closed = true;
		$('#puzzle-key').slideUp();
		$(this).text('Show solution');
	}
}

When inspecting this code in Chrome Developer Tools, regardless of any actions, events or any other browser interaction, the closed variable always was valued as false. I still don’t know why this is happening, but I do know this is a WebKit issue. And I also know that changing the variable name from closed to _closed solved the issue I was having. Also, as a simple test, without declaring the variable anywhere in my code, I opened up the console on a page without any javascipt at all and, sure enough, the variable was set to the value false.

So if you writing javascript and run across an issue where you are using a variable named closed in your code that always seems to be valued at false, be aware this might be an issue with your browser and simply changing the name of your variable in your code might make things all better for you.