Code WordPress

An alternative splitting algorithm for publishiza

My friend John built plugin for writing tweet storms in WordPress. I’ve now used it to tweet storm about salary negotiations and WordPress committer stats in 2016. I like it, but I wasn’t super happy with how it split up the the post into individual tweets. It essentially just splits it up so that each tweet is whole words and doesn’t exceed 119 characters. It also adds an ellipsis at the end of every tweet. So I decided to build my own version that prioritizes whole sentences.

My tweet splitting algorithm first splits the post by sentences.  It then tries to build tweets and prioritizes keeping sentences intact.  My thinking is that this helps the tweets stand on their own a bit more.  If you want to use this, download and activate both publishiza and the gist below as plugins.


Stop macOS from asking for the ssh passcode every time

Upon the most recent update for macOS ( version 10.12.2), I was being prompted for my SSH passcode every time I would ssh into a server.  As someone who moves between servers often, this got annoying.

Thankfully, a new config option can fix this:

UseKeychain yes

Just add that to your .ssh/config and you don’t need to enter your private key passcode every time you ssh.  The old behavior will be back.  This can be enabled only for specific servers using the cascade inside.ssh/config or for all servers.

Code Uncategorized WordPress

WordPress in a next generation PHP world

HHVM has now released it’s second long term support release and PHP 7 is in the final stages of implementing changes. It’s an exciting time for PHP and to be a PHP developer which means it is also an exciting time to be a WordPress developer since it creates an opportunity for WordPress to once again embrace forwards compatibility.

While I was at PHPUK, one of the most common conversations I had was people being critical of WordPress for supporting PHP 5.2 as a minimum.  Many of those same people became less critical once they find out WordPress runs great on PHP 5.6 and that many people run it on HHVM.

For the last several weeks, WordPress has been running it’s unit tests on PHP7 nightly builds. They’ve been running on HHVM for months. Right now, the unit tests are not passing for either one and as far as I know, have never passed for either one.  This is a problem.

I’m planning on spending some time during the 4.3 development cycle focused on these next generation platforms. Rasmus has put together a php7 vagrant box and JJJ created an addon to Varying Vagrant Vagrants to enable HHVM there. WP engine also has it’s own WordPress HHVM vagrant box. I intend to use all three of these to help.

Davey Shafik has put together a great two part series on the changes coming in PHP 7.  The two changes that are most likely to cause issues for WordPress sites are the removal of all deprecated features and the deprecation of PHP4 style constructors. This is going to affect many widgets along with all sorts of other code.

It’s exciting to see PHP moving forward.  The competition between HHVM and PHP runtimes is making PHP faster and is only going to push the language forward. It’s a great time to be writing PHP.

Code Programming Uncategorized

Aggregate Multiple Log Files From Multiple Servers

The majority of the time I need to analyze logs across multiple servers, I use logstash.  Sometimes though I want to aggregate the actual files on the server and go through them myself with awk and grep.  For doing that, I use two tools.

  1. In my bash config, I have a function called access_concat that reads out regular and gzipped access logs.
        find $1 -name "acc*" -not -name "*.gz" -exec cat '{}' \;
        find $1 -name "acc*" -name "*.gz" -exec zcat '{}' \;

    I can pass a path that log files are stored in and it will search them to find the files I actually want.

  2. Dancer’s Shell (or DSH) makes it easy for me to run a command across multiple servers.

Combining these two, I can run:  dsh -M -c -g prd-wp 'access_concat /logs >> ~/oct22.logs' to concatenate all of the log files that exist on the server today. I then just need to scp down oct22.logs and I can easily run my analysis locally.

Note that to do this, you need to configure dsh so that the servers you want to access are in the prd-wp group (or better yet, the logical name for whatever you are working on).

Code Programming


If you haven’t noticed, I like punchcard graphs.  I like them so much, I have a script that to generate them.  I’ve now released this script for everyone to use. is simple to use and I hope you find it useful.  It accepts a stream of unix timestamps and creates a punchcard graph. It can very useful if you’re trying to figure out days and times of activity.

How Do I Install

The easiest way to install is with pip.  Just run

pip install

If you install it manually (by cloning the git repository and running python install), you’ll also need to install the dependency pygooglechart.

What options are available

The only option that is currently available is to change the filename. To do that, use the -f option like -f tweets.png

How do I generate a stream of timestamps

For WordPress Posts, I Butchered the WordPress importer plugin. To use this, clone that repo and run

php punchcard.php export_file_name.xml |

For Twitter, I created a similar simple script. I have the script setup for retweets, original tweets and all tweets. I just change the echo line at the end depending on which I want to output. To use this script, I run

php twitter.php archive.csv |

What should I do if I find bugs

Please create a github issue with any bugs you might find. Please make sure to include steps to reproduce including a relevant data source file.


This script is largely just an abstraction of Bash History Punchcard by Matt Behrens. Without his work, this wouldn’t exist.

Final Notes

If you use to create any interesting graphs, tweet @aaronjorbin, I’d love to see that it’s being used.

Code Uncategorized

The new homepage

Yesterday my team relaunched, consolidated our brand, and launched a bunch of cool new features. One of my favorite parts is the map on the homepage which shows real-time shares as they are happening.

The map was interesting to build. We wanted it to be fast, look good on all browsers (including mobile and tablets) and communicate the reach we have being on 14 million websites and reaching 1.3 billion (yes, with a B) users every month. To do this, I looked at options using Canvas and SVG, but ultimately decided that good old-fashioned HTML and JavaScript would do the job best. We do use SVG and Canvas for it though, just not in the traditional in browser way.

The map itself is built using Protovis which while no longer actively developed, includes multiple map projections out of the box. We then use PhantomJS to create a png from the SVG that Protovis spits out. The share icons are built in a similar manner. They are canvas circles that we build into a sprite and then use PhantomJS for the actual sprite construction. By scripting the generating of these two key images, we were able to tweak and play with colors simply and with real data. No need for our design team to fire up photoshop and send over an image. Change some CSS or JS, run the build script and everything is ready to go.

Take a look at the rest of the site. Our entire team did a killer job with these new features and styling. Will, Foo, Jeff, and Jim all wrote up other pieces of this launch. Greg also highlighted how to user the new Trending Content Tool in WordPress. Exciting times here at AddThis.

Code Programming Uncategorized

IRC Notifications from a remote machine to my mac

For IRC, I like to use Irssi on a server that I can always keep running and log into no matter what machine I am on. One of the initial challenges with doing this was getting notifications on mentions. I solved this by following the tutorial on Irssi, screen, fnotify and Growl on OSX. The only difference between his setup and mine is that my bash script to do the notifying is simpler. I’ve pasted it below for you to use.


ssh harpua "tail -f .irssi/fnotify " | while read heading message; do growlnotify -t "${heading}" -m "${message}"; done

How do you solve the problem of IRC notifications from a remote machine?

In case you are wondering, all of my machines are aliased to Phish songs, hence Harpua.

EDIT: I’ve added the -s flag to growlnotify so that the updates are sticky and thus I see them when I get back to my machine if I’ve stepped away and I don’t leave people hanging.

Code Uncategorized

Facebook shares some secrets on making MySQL scale — Cloud Computing News

When you’re storing every transaction for 800 million users and handling more than 60 million queries per second, your database environment had better be something special.

via Facebook shares some secrets on making MySQL scale — Cloud Computing News.

Facebook uses and pushes MySQL like no other. This article gives a great insight into how it uses MySQL to a level and degree like no other. Hattip Rich

Code Uncategorized WordPress

Thoughts on Post Meta Boxes in WordPress

I’m generally of the opinion that the screen for adding content should be as simple as possible in a CMS.  It’s one of the reasons I really like the new Distraction Free Writing in WordPress 3.2 (sneak peek if case you haven’t seen it).  It’s why I was a huge fan of WordPress reducing the number of default metabox in 3.1.

This is why in the recently updated AddThis WordPress plugin, the meta box to disable AddThis on a post by post basis is disabled by default.  While it was a feature that users requested, it wasn’t something that people were beating down the door to enable.  I decided that thus for the majority of users, no reason to make the display show more than they need.

It was super simple code wise. All of this code sits inside of a class that controls all of the post meta box:

// These two lines are inside a function the hooks into init. $screen equals post and page
add_meta_box(‘addthis’, ‘AddThis’, array($this, ‘post_metabox’), $screen, ‘side’, ‘default’ );
add_filter(‘default_hidden_meta_boxes’, array($this, ‘default_hidden_meta_boxes’ ) );

function default_hidden_meta_boxes($hidden)
$hidden[] = ‘addthis’;
return $hidden;

Now the addthis metabox will be hidden by default. Next time you add a post meta box to WordPress inside a plugin, ask your self if it’s one that all of your plugin users will need.

Learn more about AddThis for WordPress 2.1

Code Uncategorized

Barcamp News Innovation Philly Hackathon Project

Part of Barcamp News Innovation Philly is an open data hackathon.  I wanted to do a live visualization of something and I wanted to use canvas.  What I did is create a “Paint thrown against the wall” visualization of tweets tagged #bcniphilly.  The color of the tweet is specific for the user, the size of the circle is based on the length of the tweet and the location is based on the id (so it’s pretty random).  It will take a moment to load the most recent tweets and auto updates every five seconds.  I’ve only tested it in Chrome (so no promises that it will work in anything else)  Check it out!