• Engineering Customer Service at WordPress.com

    I’ve previously written articles about becoming a code wrangler and my experience of working at Automattic.

    If you happened across my article but were more interested in what it meant to be a happiness engineer at Automattic, Olark recently wrote an article about customer service at WordPress.com.

    My favorite part of the article was this paragraph where Andrew Spittle talked about a memorable encounter that he had with a customer.

    Then the other experience for me personally that stands out is talking with a customer, and ultimately, the issue they were running into was not something we could fix. They were going to have to go contact their domain registrar. When we broke this news to them, they said, “Oh. I don’t want to go contact my domain registrar, because they don’t have Happiness Engineers. They have Gestapos of Grief.”

    Source: Olark Live Chat – Engineering Customer Service at WordPress.com

  • The Need for Speed: Optimistic Web Interfaces

    Shortly after starting at Automattic, I became interested in optimistic interfaces after Beau critiqued some work I had done on O2.

    One of the best videos I found to introduce and demonstrate optimistic web interfaces was this one of Guillermo Rauch, who happens to be a coworker at Automattic, speaking at dotJS 2013.

  • There’s nothing like…

    I don’t know where it started, but Hero has a new habit of commenting “There’s nothing like {insert some object or activity here}”.

    We went to get fried chicken for dinner the other day, and as is customary, we had rolls with honey. Hero commented, “there’s nothing like bread and honey.” 

    bread and honey 

    This past Sunday, we all went to Hastings to have some coffee and do a bit of (school)?work.

    Hero has twisted his ankle earlier in the day while running. So, when we got to Hastings, we asked for a small bag of ice to put on his ankle.

    Hero commented, “there’s nothing like putting my foot on the table with ice.”

      

  • Visualizing Sorts

    It’s one thing to know which sort to use given a situation, but it’s much more interesting to see a sort in action.

    Here are a couple of videos that will show sorts at work.

  • Wichita Falls Intersections Now and Then

    I came across this video that shows pictures of intersections in Wichita Falls from today and about 40 years ago.

    It was interesting to be able to look at my city 40 years ago.

  • Donut Dirt

    Today was a rough morning for Hero.

    Sara and I decided that we would go to church for the first time in years, so we aimed to get up at 9am today.

    As I woke up Hero, he said to me, “but Dad, it’s holiday. You can’t wake me up!”

    Throughout the morning, Hero cried several times for little things such as us not finding his undershirt and not being able to wear his Bumblebee belt.

    But the best part of the morning happened as we were getting out of the car. As Sara opened the door, Hero said, “I’ve got donut dirt on my pants.”

  • Spaghetti Dinner Fundraiser 2015

    Tonight we went to the annual spaghetti fundraiser at Hero’s school. For $8, I got a plate full of spaghetti, a plate full of salad, and a couple of breadsticks as well as a cookie and drink.

    Turned out to be quite a good deal.

      

      

      

     

  • Our Director of Engineering on the New WIRED.com

    I loved reading about WIRED’s recent work on their site.

    Specifically, it was great reading about how WIRED merged 17 active WordPress installs into one and created a custom plugin for curating content:

    The redesign gives us the third incarnation of our Curator application, which started years ago as a separate Groovy on Grails application maintained by a single Java developer. Curator once consumed articles from 35 different blogs for curation on our homepage. When we migrated our 17 active WordPress blogs into one WordPress install, we also rewrote Curator…

    Our new and improved Curator is now a custom WordPress plugin—and it’s artificially intelligent! This allows our homepage and section landing pages to be both automated and curated at the same time.

    Read the rest of the article on WIRED.com

  • React.js Conf Round-up 2015

    React logoThe React.js conference was held last month, but tickets were not easy to come by.

    Never fear though, because the React.js team recently came out with a Round-up post of some of the best content from the React.js conference.

    Being new to React.js myself, I’m looking forward to taking away a few nuggets that I can apply to WordPress.com.

    React.js Conf Round-up 2015 | React.

  • Burrito Friday 2-20

    Chipotle burrito

    I think today might have been my very first burrito Friday. It’s an Automattic thing.

    So, to properly celebrate, I decided to go to Chipotle, which just recently opened. The burrito was so big that they couldn’t completely wrap it with the foil.

  • Mouse: A Language for Microcomputers

    The only class that I’ve ever truly worried about passing was my compiler design class with Mr. Richard Simpson at Midwestern State University.

    While the material was interesting at times, it was almost always several levels over my head and I had a hard time keeping up.

    Even though I constantly worried about passing that class, I did have quite a bit of fun with at least one project in that class — Converting the C based interpreter for Mouse into any language of our choice. You can probably guess that I decided to go with PHP 🙂

    I’m not sure why I was fond of that language. It was esoteric, hard as hell to understand, and there was almost no chance that I would ever use it for any practical situation.

    After all, looking at this sample program below, do you have any idea what’s going on?

    [code]
    "Enter a positive number that you would like fibonacci numbers up to."

    A0=
    B1=
    C1=

    D?="You entered: "D.!"!"
    "Fibonacci Sequence: "

    (D.C.-^ A.!" "AB.=BC.= CA.B.+=)

    A.!" "B.!

    "!"

    $$
    [/code]

    But something about it was enjoyable. Which is why I geeked out so hard the other day when I came across an old copy of the Mouse: A Language for Microcomputers.

    Now that I’ve got the book, I’m considering creating a JavaScript based interpreter for Mouse.

    Until then, here’s a link to the PHP based interpreter of Mouse that I came up with about a year ago.

    https://github.com/ebinnion/Mouse-Playground/blob/master/translations/mouse79.php

    At this point, the interpreter doesn’t include macros, but should run all of the sample programs in my Mouse repository.

  • How to Squash Commits with Git

    Part of my Git workflow at Automattic includes getting a pull request going as soon as possible.

    I find this workflow useful as I am learning the code base for the latest version of WordPress.com, which is completely different from any codebase I have touched before. Because of this, I try to commit often so that I can get feedback and collaborate with my coworkers.

    And while committing often is great to get feedback in a pull request, I tend to like to squash all of the commits into one before I merge my pull request into master.

    How I Squash Commits with Git

    The first few times I squashed commits with Git were very nerve wracking as I was worried about nuking my changeset. But, as I have worked more with Git in a team setting, I have become very comfortable with these following steps:

    1. Get merge base git merge-base my-branch-name master
    2. Rebase git rebase --interactive {hash from merge base}
    3. Change pick to squash for all but first commit

    Although I have grown comfortable with the above commands, I find that I sometimes still refer to this awesome article from edX about rebasing pull requests.

    If you find you need a bit more explanation for how to squash commits with Git, I’d recommend giving that article a read.

  • Pancake Festival 2015

    Today was an early day for us since we decided to go to the pancake festival at 7 am!

    We had a great time and had plenty to eat.

    Also, notice that Sara brought her own jar of peanut butter :p

    Chris and Matthew at Pancake Festival

    Hero and Sara at Pancake Festival
    Mom and Chris at Pancake Festival

    Pancak Festival Grill

  • Easily Crowdsource Photos of your Wedding

    When my mom remarried a couple of years ago, she did something that I thought was really cool.

    At the wedding ceremony, visitors were given disposable cameras so that they could take an active role in the wedding by helping to take pictures.

    I thought this was a great idea for a couple of reasons:

    1. It was a cheap
    2. It would provide a greater amount of photos.

    But, as I recall, not many people ended up using the cameras.

    What Went Wrong?

    I think the main issue is that disposable cameras are a big pain in the ass. Disposable cameras have to be manually wound for each shot, the button has to be pushed to charge the flash, and the packaging is a pain to open.

    While the disposable cameras were a great idea, in hindsight, it makes sense that it didn’t turn out as well as we had hoped.

    The Solution

    Compare the process of taking pictures with disposable cameras to taking a picture with my iPhone where once I am in the camera app I can just keep tapping to take more pictures.

    What if there were was a way to get pictures that your friends and family took without having to track them all down?

    Well, there is such a thing. IFTT has a tool/recipe that will allow you to automagically save any images that your friends take at your wedding into a Dropbox folder!

    IFTT: Instagram to Dropbox

    Check the recipe out here: https://ifttt.com/recipes/188138-save-your-wedding-s-instagram-hashtag-photos-to-dropbox

    Photo Credit: TarviRa | cc

    Disclaimer

    I believe that crowdsourcing images for a wedding is a great idea, and can result in great candid shots.

    That being said, I wouldn’t consider having a wedding without a professional photographer — And I would recommend that you hire a photographer as well.

  • Grand Meetup Flash Talk 2014

    Part of working at Automattic includes getting every employee at the company in one place at the same time — We call these grand meetups.

    Grand meetups are a great time to bond with co-workers, learn, get some interesting projects done, and do flash talks.

    Flash talks have a maximum length of 4 minutes (at least from what I remember) and can be given over any topic. Since Hero is hard of hearing, I decided that I would give a crash course over how parents could communicate through sign with their babies.

    [wpvideo LZteY68s]

    A big thanks to all a12s for participating and making me feel welcome 🙂 :hugs:

  • Working with React joinClasses

    Note: joinClasses is now deprecated and you should use classnames. There is an explanation of how to use classnames at the end of the article.

    React has slowly been coming together for me over the past few weeks as I have slowly moved from “how do I get this thing to work?” to “how can I factor this out?” mindset.

    As I’ve slowly ventured into composition with React, one of the pain points that I’ve had was elegantly concatenating classes.

    After a tip from Beau and some searching, my first try at concatenating classes in React was done using the classSet utility. And while I was able to use classSet to concatenate classes in a React component, I didn’t find it to be a very elegant or easily readable solution.

    A bit more searching led me to a utility named joinClasses.

    Using React joinClasses to Concatenate Class Names

    Here is an example of how I am using joinClasses to concatenate CSS classes in a React component.

    [javascript]
    var React = require( ‘react’ ),
    joinClasses = require( ‘react/lib/joinClasses’ );

    module.exports = React.createClass( {

    render: function() {
    var selected = ( this.props.selected === this.props.className ? ‘selected’ : ” );

    return (
    <li className={ joinClasses( this.props.className, selected ) } >
    <a href={ this.props.href }> { this.props.label }</a>
    </li>
    );
    }
    } );
    [/javascript]

    this.props.selected above is a string that represents which sidebar link should be selected and this.props.className is the class of the current sidebar link.

    If the two match, then we want to add a class of selected to the sidebar item along with any classes that were passed in this.props.className.

    If there were more classes to be conditionally added based on props that were passed in, I would look into combining the classSet utility along with the joinClasses utility.

    Using classnames instead of joinClasses

    React has deprecated joinClasses and has suggested that developers use the classnames node module instead.

    So, first things first, you’ll want to install classnames. You can usually do this in the root of your project, and you’ll use this command: npm install classnames. Note, you might want to use npm install --save-dev classnames in order to update your package.json file.

    Once you have installed classnames, you will then need to require it in your JSX file.

    [javascript]
    var classNames = require( ‘classnames’ );
    [/javascript]

    Once we have required classnames, we should be able to simply swap out joinClasses with classNames. Here’s an updated example:

    [javascript]
    var React = require( ‘react’ ),
    classNames = require( ‘classnames’ );

    module.exports = React.createClass( {

    render: function() {
    var selected = ( this.props.selected === this.props.className ? ‘selected’ : ” );

    return (
    <li className={ classNames( this.props.className, selected ) } >
    <a href={ this.props.href }> { this.props.label }</a>
    </li>
    );
    }
    } );
    [/javascript]

    Also, because classnames is so robust and will allow us to send an object to it, we can simplify the code a bit:

    [javascript]
    var React = require( ‘react’ ),
    classNames = require( ‘classnames’ );

    module.exports = React.createClass( {

    render: function() {
    var classes = classNames( this.props.classNames, {
    ‘selected’: this.props.selected === this.props.className
    } );

    return (
    <li className={ classNames( this.props.className, selected ) } >
    <a href={ this.props.href }> { this.props.label }</a>
    </li>
    );
    }
    } );
    [/javascript]

  • Dynamically Add Classes with React classSet

    Note: React.addons.classSet is now deprecated and you should use classnames. There is an explanation of how to use classnames at the end of the article.

    Earlier today, I needed to add some classes to a link. One class was passed in through a prop, but the other class would be added based on a boolean condition.

    It’s simple to access props within a React component, so my first crack at setting the classes looked something like this:

    [code]
    <li className={ this.props.className }>
    <a
    href={ this.props.href }
    onClick={ this.setLayoutFocus }
    className={ this.props.selected === this.props.className ? ‘selected ‘ + this.props.className : this.props.className } >
    <span className="menu-link-text">{ this.props.label }</span>
    </a>
    </li>
    [/code]

    Eww… check out that nasty looking ternary.

    Good thing for pull requests, because that one was denied pretty quickly. In the pull request feedback, Beau Lebens mentioned that there was a CSS utility included with React called classSet.

    He mentioned that the React classSet utility would be helpful because I’d be able to build my classes string without having to have a bunch of conditional statements and string concatenation. #winning

    So, I went Googling and figured out how to use the React classSet utility. Here’s the relevant documentation for using React’s classSet for class name manipulation.

    Here’s an example of how the React classSet utility works from the documentation linked above.

    [javascript]
    render: function() {
    var cx = React.addons.classSet;
    var classes = cx({
    ‘message’: true,
    ‘message-important’: this.props.isImportant,
    ‘message-read’: this.props.isRead
    });
    // same final string, but much cleaner
    return <div className={classes}>Great, I’ll be there.</div>;
    }

    [/javascript]

    This is a simple example, but what about the case where the class is passed in via a prop as opposed to just being switched on or off by a boolean?

    Second Try with React classSet

    This try at adding classes via the React classSet utility allows us to add a class that is passed in via a prop.

    [javascript]
    render: function() {
    var classes = React.addons.classSet({
    ‘selected’: ( this.props.selected === this.props.className )
    });

    /*
    * Since the className changes from sidebar item to item,
    * we dynamically add this sidebar item’s class as a key.
    */
    classes[ this.props.className ] = true;

    return (
    <li className={ classes }>
    <a href={ this.props.href } onClick={ this.setLayoutFocus } >
    <span className="menu-link-text">{ this.props.label }</span>
    </a>
    </li>
    );
    }
    [/javascript]

    Note that in this second try that we are dynamically appending our class that was passed in via the className prop to the classes object.

    Then, when we call className={ classes } our string of classes is created.

    Using classnames instead of classSet

    React has deprecated React.addons.classSet and has suggested that developers use the classnames node module instead.

    So, first things first, you’ll want to install classnames. You can usually do this in the root of your project, and you’ll use this command: npm install classnames.

    Once you have installed classnames, you will then need to require it in your JSX file.

    [javascript]
    var classNames = require( ‘classnames’ );
    [/javascript]

    Once we have required classnames, we should be able to simply swap out React.addons.classSet with classNames. Even better though, since classnames is so robust, we can just pass in this.props.className as an argument.

    [javascript]
    render: function() {
    var classes = classNames( this.props.className, {
    ‘selected’: ( this.props.selected === this.props.className )
    } );

    return (
    <li className={ classes }>
    <a href={ this.props.href } onClick={ this.setLayoutFocus } >
    <span className="menu-link-text">{ this.props.label }</span>
    </a>
    </li>
    );
    }
    [/javascript]

  • How to Add Dismissible WordPress Admin Notices

    Note: As of WordPress 4.2, dismissible WordPress admin notices should be a part of WordPress core. More information can be found here.

    I find that in my blogging workflow, I tend to save drafts often so that I don’t lose my work.

    While this may add a second or two here and there, the peace of mind that I get from knowing that I won’t lose all of my work is definitely worth it.

    But, there is one little thing that bothers me about saving drafts, and that is the pesky WordPress admin notices that stay at the top of the view.

    So, today I set out to find a way to hide or remove the WordPress admin notices.

    Initially, I tried a solution that automatically hid the “Post Draft Updated” WordPress admin notice after 5 seconds, but I wasn’t very fond of the UX.

    After a bit of thought, I decided that the user should be able to actually dismiss these notices and decided upon this:

    The Magic Behind Dismissible WordPress Admin Notices

    <?php
    /*
    Plugin Name: Dismissible WordPress Admin Notices
    Plugin URI: https://eric.blog
    Description: Adds the ability to dismiss WordPress admin notices.
    Author: ebinnion
    Version: 0.1
    Author URI: https://eric.blog
    */
    class Dismissable_Admin_Messages {
        
        public function __construct() {
            add_action('current_screen', array(
                $this,
                'admin_init'
            ));
        }
        
        public function admin_init() {
            $screen = get_current_screen();
            $showOn = array(
                'post',
                'page'
            );
            
            if (in_array($screen->id, $showOn)) {
                if (isset($_GET['message'])) {
                    add_action('admin_head', array(
                        $this,
                        'admin_head'
                    ));
                    add_action('admin_footer', array(
                        $this,
                        'admin_footer'
                    ));
                }
            }
        }
        
        public function admin_head() {
            ?>
            <style>
            #message {
            position: relative;
            }
    
            #message .dashicons-no {
            cursor: pointer;
            margin-top: -.5em;
            position: absolute;
            right: 10px;
            top: 50%;
            }
            </style>
            <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->
            <?php
        }
        
        public function admin_footer() {
            ?>
            <script>
            (function( $ ) {
            var message = $( '.wrap > #message' );
            message.append( 'dashicons-no">' );
            message.find( '.dashicons-no' ).on( 'click', function() {
            message.slideUp();
            } );
            })( jQuery );
            </script>
            <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"--
            <?php
        }
    }
    
    new Dismissable_Admin_Messages();

    How to Install

    As of now, this plugin isn’t on the official WordPress repository. But, if you would like to use this functionality, you can save the code above into a file and put it in either:

    • wp-content/plugins
    • wp-content/mu-plugins

    If you have any questions, please don’t hesitate to ask.