Ben Lobaugh Online

I think, therefore I am. I am, therefore I sail

Category: WordCamp Page 1 of 3

WordCamp Maui: Interacting with External APIs

wc-maui-logo-final-blue-1208x540-604x270

There is a lot of talk these days about tapping into the resources available through external APIs (Twitter, Facebook, Flickr, etc). Much of the functionality needed to interact with APIs is already included in the core through the HTTP class. In this session you will learn the concepts behind pulling data from an external API, sending data to an external API, how to utilize WordPress caching to increase speed and functionality, etc.

Here are the slides from the presentation: Interacting with External APIs – wcmaui 2015

The code used in the demo is available at: https://gist.github.com/blobaugh/f60fb50838edabd49159

WordCamp Sunday Workspace

I am sitting in the contributor room on Sunday at WordCamp San Francisco.

20141026-100641.jpg

Airport Adventures in Philadelphia

I fly a lot. Navigating airports has become second nature to me however we all have our moments, or in this case a whole series of moments…

My coworkers are amazing. The company is distributed so we do not see each other in person often. Lastnight a few of us gathered together for merrimaking. I forced myself to leave a 1am.

1:20am- arrive back at the hotel and begin to pack.

2:30am- finally fall asleep.

4:30am- 2 hours later my alarm goes off… Ugh

5:10am- Griggily get out of bed and proceed to the airport.

So lets recap: cool people, staying out, 2 hours of sleep, now I have to hit the airport.

The fantastic Uber private car service dropped me right in front of the Alaska terminal door with 2 hours till my 8am flight.

At the automated flight checkin there are 2 machines. One has a JavaScript error showing and I had to pull myself away from attempting to debug it (wow, nerdy much?). The other machine spins its wheels in an excruciating effort to locate my flight details before giving up and pointing me to a human.

There are no humans.

No airport phone to call for help.

United has humans, and a long line of other humans checking in. I made my way over and was redirected to the American terminal.

Bummer, two buildings away and pouring rain.

American has one human working and checkin is deserted of passenger humans. Hmm…not looking good. The lady is helpful but says my flight is not listed. The only flight at that time is by United.

I check my email again…United.

D’oh! Back into the rain I go.

The United checkin machine does not like me either. While waiting for a human to help I start trying different combinations. Viola! One works and I happily happy snatch up the boarding pass.

It is now 6:50am but I am feeling confident. I have TSA pre-check! I am going to sail through security and have plenty of time to get breakfast.

As I approach the security line I am chuckling internally at the chumps going through normal security. There are 100+ highschool girls in line. My joy is short lived however as as soon as I turn down the pre-check lane I realize they are *all* in the pre-check lane! Zoinks!

Longest and slowest wait I have ever had in pre-check. Even so I sailed through security in in 5 minutes. Even got to keep my pants and all other articles of clothing firmly attached to my person.

Now I sit here firmly planted at my gate awaiting the flight. No sense risking additional chaos by moving around till this coffee kicks in and I wake up.

Oh wait, the coffee is scalding hot. Too hot to even hold the cup…

Addendum: boarding has been hampered by incompetence. Staff are calling out names from the counter instead of the intercom. This is causing massive waits as many are not hearing them. The intercom is only used to call out which zone on the plane is boarding. So far 20 minutes after the boarding process started only half of one group has boarded.

Second addendum: Right after I sat down on the plane I pulled out my headphones and the left earphone fell off :(. The company’s support was great though! I highly recommend Griffin Wood Tones just for that. A new pair is in the mail already.

IMG_7230

Creating a two way sync between a Github repository and Subversion

git_vs_svn

Another git <> svn post?

As many of you know I have been on a quest to get Jetpack core development moved from the WordPress.org Subversion (svn) repository to Github (git). As part of this process I setup an experimental Jetpack repository to see how synchronization works between git and svn. Lets just clear the air right now and say not well, not well at all. This is due to how git and svn each store their respective histories. But! I think I finally have it figure out.

Backfill

I wrote an article a couple months ago entitled Creating a synchronized Github fork of a WordPress.org Subversion plugin repository. This article is great (and still a recommended read) if you are only doing synchronization between the svn server and a local git repository, but fails miserably when adding in a remote git server such as Github (See note in Ch 8 of the git book). I was worried that true two way synchronization was not possible until I spoke with some helpful folks from Github and Zack Tollman (I.E. Git Master) who recommended I try a branch dedicated to the remote svn connection only instead of trying to mix it into trunk. I am happy to report that this setup has been working flawlessly for a couple months now. I have experienced zero conflicts when performing any syncs and now I want to show you how to set it up as well.

It should be noted that the sync is triggered by you on your local machine. This is not an automated process on Github’s servers, nor will any of the syncing information be available to anyone else who later clones the git repository.

Get your git

I will be utilizing the Jetpack repository I setup on Github for the examples going forward in this tutorial, so the first thing to do is setup yourself a repository on Github where this project will live and then clone it down to your local machine.

git clone git@github.com:blobaugh/jetpack.git

or for those of you not using ssh keys with Github (you really should)

git clone https://github.com/blobaugh/jetpack.git

(Sidenote: Ironically you can also checkout from Github via svn with the https address…)

You will use trunk and development branches here as normal. Feel free to do all the pushes and pulls to Github that you desire, however do not hook up trunk or any development branches to the Subversion repository!

Setup an svn tracking branch

The next step is to create a branch that will only be used to setup a remote connection to the Subversion server. You will never do any development changes directly in this branch. If you do you will most likely encounter severe issues due to the incompatible histories of both systems. Instead you will be using git’s merging features between branches.

git branch --no-track svnsync
git svn init -s http://plugins.svn.wordpress.org/jetpack
git svn fetch
git reset --hard remotes/trunk

(Sidenote: If you are syncing also author profiles you can add

--authors-file svn-authors.txt

to the fetch command. I will update this tutorial with details on the author file later)

 Do your business

You are now all setup to begin developing your amazing whatever with full confidence that changes made to the git or svn side can and will safely be reflected back to each other. But wait! Keep reading now to find out the tricks to make the sync work after you have created those amazing new additions to your project.

Merge changes back from svn into Github trunk

First all changes from svn are going to be merged locally and staged to be pushed out to the Github repository.

git checkout svnsync
git svn rebase
git checkout master
git merge svnsync
git push origin master

Merge changes from Github trunk into svn

Now going the other direction. This is a bit more complicated than pulling in from svn, but make sure you follow all the steps or you will get nasty errors with the sync. Keep in mind the –no-ff on the merge is very important to include. We also want to make sure everything is fully updated from both Github and the svn server before performing the push to svn.

git checkout master
git pull origin master
git checkout svnsync
git svn rebase
git merge --no-ff master
git commit
git svn dcommit

The order of the commit and dcommit is important here. Switch them and the histories will conflict.

Drink Scotch

This is the happy point when everything is working lovely and you get to drink Scotch to celebrate!

And if something went wrong and you are freaking out an anxiously scratching your head I also recommend Scotch 🙂

Resources

Here are a few resources that helped in writing this tutorial:

I am speaking at WordCamp Denver 2013 on Unit Testing Plugins

I have the pleasure of speaking at WordCamp Denver this year on the subject of Unit Testing Plugins in WordPress.

Your plugin is broken; do you know why? In this session, Ben will show you some simple principles to help you integrate unit testing in your plugins that will help you find and eliminate bugs before they happen.

View my slides

Here is the most bestest PHPUnit Testing with WordPress tutorial on the whole interwebs

Additional resources

https://github.com/blobaugh/wordpress-plugin-tests
http://en.wikipedia.org/wiki/Test_fixture

http://en.wikipedia.org/wiki/Acceptance_testing
http://en.wikipedia.org/wiki/Integration_testing
http://www.youtube.com/watch?v=J4dlF0kcThQ
http://wordpress.tv/2011/08/20/nikolay-bachiyski-unit-testing-will-change-your-life/
http://wordpress.tv/2013/08/05/alison-barrett-lessons-learned-in-unit-testing/
http://jenkins-php.org/
http://en.wikipedia.org/wiki/Test_fixture
http://net.tutsplus.com/tutorials/php/mockery-a-better-way/
http://phake.digitalsandwich.com/docs/html/

Page 1 of 3

Powered by WordPress & Drip City Coffee