• Print PHP Stack Trace

    I was having a bit of trouble tracking down exactly where a method was getting called from today.

    Usually a search in my project directory will turn up the result very quickly, but I wasn’t having luck with PHPStorm for some reason.

    So, the next best thing was to get a stack trace so that I could get the last few functions that had been run. I don’t do stack traces much in PHP, so I had to track down the code to use.

    Of the few options to use, this seemed to be the easiest to use and remember.

    $e = new Exception;
    
    // Output the stack trace to the browser
    echo $e->getTraceAsString();
    
    // Send stack trace to error log
    error_log( $e->getTraceAsString() );

    And if you’re wanting more verbose output, including the arguments that were passed to each function, try this.

    $e = new \Exception;
    
    // Recursively print the stack trace
    print_r( $e->getTrace() );
    
    // Log the stack trace object
    error_log( print_r( $e->getTrace(), true ) );
  • Photo 101: Bliss

    Today’s Photo 101 assignment was bliss.

    While one of the first things that came to mind was cuddling with my son in the early morning — about the only time that I can get him to cuddle — I decided I would do something that dealt with programming.

    Some of my favorite moments programming involve late nights, sweet tea, and the eventual solving of a problem that I have been working on for several hours.

    Coding is Bliss

  • Database Test Study Session

    I had the camera stashed away in my backpack today, so I managed to get a couple of portraits during a study session for our database test tomorrow.

  • Guy Fawkes Day

    On the way home from class today, I was able to get this picture of Guy Fawkes demonstrators at Kemp and Callfield/Midwestern in Wichita Falls, Tx.

    Guy Fawkes Day 2014

  • Photo 101: Street

    Day 2 of the Photo 101 challenge took me to downtown Wichita Falls, Tx to get some pictures with a “street” theme.

    I used my Nikon D3200 with 50mm prime lens. Due to my inexperience, I didn’t take a tripod with me. Lesson learned.

    I got a few shots, but here is my favorite.

    Here is a gallery of some other images from tonight.

  • Blog for Yourself

    Blogging for me has always been a very cyclical thing. The cycle looks something like this:

    • Find something interesting that motivates me to write.
    • After writing that first post, I’ll usually follow up with a few more over the next few weeks.
    • Blog again looks like a ghost town about 2-3 weeks later.

    Some of the reasons for this are that I feel like my site has no purpose and that my thoughts don’t matter in the context of the entire Internet. I have found myself thinking that surely there is someone smarter and more eloquent than I am that can, and is, describing any topic that I write about…

    This cycle I go through is what interested me in Mike Johnston’s flash talk at the 2014 Grand Meetup in Utah.

    I don’t like blogging

    Mike’s presentation had to do largely with his recent dislike of personal blogging, which hit home with me because I find that I tend to blog in patterns.

    I was currently going through a dislike of blogging myself, which I found odd because I work at Automattic (company behind WordPress.com).

    At the grand meetup I brought this subject up to James Huff who gave me a few words of wisdom which he’s used to build his blog to 3,000+ followers. The most impactful thing that James told me was that I should change the way I look at my blog — I should start looking at my blog as something meant for me, such as a way to look back at my life.

    This really changed things for me as I could then blog without worrying about whether the message fit into some overall strategy or purpose. From now on, I could simply post things that I thought were interesting, helpful, funny, etc.

    The Result

    The overall result so far has been a very noticeable increase in how much I post to my blog. You can see this for yourself by comparing the 16 posts I wrote in October to the single post I wrote in June.

    In the past month or so, I have blogged about a greater variety of things, including: photos, development tutorials, the death of my daughter, and my work at Automattic.

    Photo Credit: Kristina B

  • Photo 101: Home

    Hero with Hands Up

    I’m doing the Photo a Day challenge from WordPress.com. Todays assignment was “Home”. I decided to go with an abstract idea of home and take a picture of my son, Hero.

    This picture was at Taco Bueno this morning as he was eating a couple of breakfast burritos.

  • Dogfood Your Products

    Of all of the greatness at the Automattic grand meetup this year in Utah, one of the most impactful moments was Andrew Spittle’s call to do a better job of dogfooding our apps.

    For those who don’t know, dogfooding is the practice of using your own products. This goes a bit beyond simply testing products. Instead, the idea is that a company uses its own product to be able to more fully evaluate it.

    At Automattic we do this by using our own software such as WordPress.com, Jetpack, and CloudUp as well as testing internal only builds of the WordPress mobile apps before they’re released to the public.

    Lost Opportunities

    Andrew’s talk presented the fact that Automatticians used social networks such as Facebook and Twitter much more than they did WordPress when using a certain hashtag — #a8cgm if I recall correctly.

    After Andrew pointed out the disparity in how Automatticians share their experiences, he mentioned that he wondered how many bug reports and UX suggestions we missed out on by not using our own software.

    Wow… That was such a way to put it.

    Making Dogfooding a Priority

    Up until this point I thought I had been dogfooding Automattic’s products. But, the reality was that while I moved my site over to WordPress.com, I wasn’t using much of the functionality on WordPress.com or the WordPress iOS and Android apps that I had installed. :facepalm:

    Starting right away, I began to use all things Automattic much more often. My website is on WordPress.com. I have the beta versions of both the iOS and Android apps installed on my devices. I use Simplenote periodically for taking notes.

    Since making more of an effort to use Automattic products, I have been surprised at how many bugs I have found and reported.

    The beauty is that all it took was to start using our products more, which is the true power of dogfooding. Each bug we find ourselves is an opportunity to give our users a better experience.

    As a developer, it’s very easy to test things how they should work, which is why we often miss bugs. When an entire company dogfoods its prodcuts, you’re getting experience and feedback from all sorts of people which will help find those edge cases and unexpected usage patterns.

    Photo Credit: laffy4k

  • Creating JavaScript Keyboard Shortcuts with jQuery

    I recently added a keyboard shortcut to a project I was working on.

    And while I have used the jQuery Hotkeys plugin for adding keyboard shortcuts recently, I didn’t use a plugin for this project since I only needed a single keyboard shortcut.

    Taking a large bit of inspiration from Krasimir Tsonev, who also documented his solution, I came up with this:

    [javascript]
    (function( $ ) {
    var $doc = $( document );
    $doc.ready( function(){
    $doc.on( ‘keydown’, function( e ){
    if ( ! $( e.target ).is( ‘:input’ ) ) {

    // props rauchg for pointing out e.shiftKey
    if ( 87 == e.which && e.shiftKey ) {
    // `shift` and `w` are pressed. Do something.
    }
    }
    });
    });

    })( jQuery );
    [/javascript]

    Explanation

    First, I create an anonymous function wrapper and invoke it while passing jQuery as a parameter. This allows me to use the $ syntax for jQuery without worrying about collisions with other libraries.

    Then, after the DOM has loaded, I attach a keydown event handler to the document. Before I run any logic though, I check to make sure that we are currently not within any input type. This is important as I don’t want to trigger keyboard shortcuts when a user is typing.

    After the code ensures that we are not in an input, I check to see if both the shift key and w have been pressed. If so, do some magic!

  • We Proudly Have Your Back: EFF Awards WordPress.com 5 Stars For Protecting User Speech

    Very proud to work at a company that was just awarded 5 out of 5 stars by the Electronic Frontier Foundation for having our user’s backs.

    But, possibly better, is the fact that WordPress.com maintains a Hall of Shame for those that try to abuse copyright and trademark powers.

  • Do Yourself a Favor, Turn On Chrome's Warn Before Quitting

    As a developer, keyboard shortcuts are a necessary part of life. And as a web developer, I use several shortcuts within Chrome as well:

    • ? + t: new tab
    • ? + ^ + i: open developer tools
    • ? + shift + {: shift one tab to the left
    • ? + shift + }: shift one tab to the right
    • ? + w: close current tab
    • ? + q: quit Chrome

    And if you’ve used the above shortcuts for any period of time, you’ve likely accidentally quit Chrome when you meant to close the current tab. :facepalm:

    This used to happen for me at least once a week… until I found Chrome’s Warn Before Quitting option.

    Chrome warn before quitting

    This obscure gem can be found under the Chrome menu. When enabled, you will need to hold ? + q to quit Chrome.

  • Blogging U.'s Photo 101 Course: Post a Photo a Day

    Excited that WordPress.com is hosting a photo a day course for the month of November. Sounds like the push I need to dust off the SLR that we bought and rarely ever use!

  • WordPress School Pictures

    Sara knew that I would think Hero having a WordPress shirt on for his school picture was cute.

    IMG_1411.JPG

  • Deploying to WordPress.com for the First Time

    This past Thursday began like many other days at Automattic. I woke up a bit late in the morning and reached over to grab my phone so I could catch up on the company chatter.

    Beau posted a few messages to let me know that he was pushing version 1 of some experimental code we were testing for a small group of Automatticians. We had tested the patch the night before, so I was pretty confident.

    I hopped out of bed and went to the bathroom so I could get ready for the day. Within minutes, chatter started picking up…

    It’s Broken in wp-admin

    Turns out that for all of the testing I had done the previous day, I never thought to see what the experimental feature looked like in wp-admin. :facepalm:

    On the plus side, I had written all of the code for this feature, so when I heard what was wrong, I had a really good idea of what caused it and how to fix it. I was able to fix the issue and test that it worked across several sites within 10 minutes. But, this was only the beginning…

    Today was also the day that I would finally get commit access to WordPress.com. This meant that along with fixing the patch that was just committed, I would also have to figure out how to commit to WordPress.com without breaking all the things. I was a bit nervous…

    That First Patch

    Beau gave me a quick rundown of the process for committing and deploying to WordPress.com and then let me get to work with a final, “let me know if you run into any issues.”

    To say I was nervous at this point would be an understatement. I’ve pushed to repositories before that were owned by a small team, but knowing that what I committed pretty shortly would be affecting millions of people was a bit surreal.

    After triple checking that the latest patch worked correctly, and running svn up multiple times, I finally committed the code, but not being familiar with vim, I accidentally posted without a message.

    Thoughts

    I was able to learn more about the deploy process as well as successfully commit a patch. After everything was said and done, I didn’t break WordPress.com and I learned, so I’ll call it a success.

  • Marry Me at Taco Bell

    It was interesting seeing these sauce packets at Taco Bell since this is a topic that Sara and I have talked about often.

    IMG_1419-0.JPG

  • Copy to Clipboard in Google Chrome Console

    When developing for the web, sometimes I want to JSONify an object to throw into Sublime Text for an easier look or maybe to compare two separate objects.

    While it’s easy to log an object in Google Chrome, the issue I have is easily getting that from the console to Sublime Text.

    After doing a bit of searching, I found that Google Chrome has a copy function that will copy any text to the clipboard.

    Here are a couple of ways that you could use this function:

    To copy any string, simply use

    [javascript]
    copy( "some string here" );
    [/javascript]

    To copy a JSONified object, you could use something like:

    [code lang=javascript]
    copy( JSON.stringify( object ) );
    [/code]

  • Stop Desktops Automatically Switching Places in Mac OS

    For the longest time, I have very quietly been irritated by my desktops (spaces) being rearranged automatically.

    My workflow usually involves using at least 3 desktops, one each for:
    – Chrome and Terminal
    – IDE of choice ( PhpStorm for now )
    – Spotify

    When these desktops periodically reordered themselves it was quite annoying since I would then be guessing which order the desktops were in, which complicates using keyboard shortcuts to switch between desktops.

    Turns out that there’s an easy fix.

    If you go to System Preferences > Mission Control, you can uncheck the box that says
    “Automatically rearrange Spaces based on most recent use.”

    Here’s a screenshot:

    Automatically rearrange spaces

R.I.P. ERIC