Three ways to integrate BuddyPress in three presentations

In the last year or so, I’ve given a number of public presentations about BuddyPress. One of my main goals in giving these presentations to WordPress groups is always to convince WP developers to give BP a try. My angle on this has been “BuddyPress compatibility”: the idea that you can take existing WordPress functionality and, with just a bit of pixie dust and elbow grease, integrate it into BP. While there are countless ways that a WP plugin could integrate with BuddyPress, the big three are: (1) displaying group-specific content in groups, (2) displaying user-specific content on user pages, and (3) registering items in the activity stream.

As of this past Saturday, I’ve now given presentations on all three of these methods:

  1. BuddyPressifying a WordPress Plugin Using the Group Extension API (BuddyCamp Miami 2013)
  2. Herding Cats with the BuddyPress Activity Component (WordCamp Europe 2013)
  3. BuddyPressifying a WordPress Plugin Using BP_Component (WPSessions, June 21, 2014)

If you’re a WP developer who’s looking for an on-ramp into BuddyPress work, I think these presentations are a good place to get started.

Heart rate monitor training for the reluctant runner

My wife loves to run. I, in contrast, find running to be boring and unpleasant. But I run all the same, because it keeps me relatively thin and makes me feel better for the 23.5 hours per days that I’m not running. Before I had a normal-ish job and a family, I was running a fair number of miles – around 35-40 miles/week. But life got in the way, and I’ve been off-and-on for a few years now. The problem with off-and-on running is that it keeps you just fit enough to get through the runs, but not fit enough to get through them in a pleasant manner. I’d find myself running five miles one week, twenty miles the next, and feeling exhausted with every step. Combined with my natural distaste for running, this unpleasantness made for an exercise regimen that was hard to stick to.

So, last summer I decided that I’d mix things up, and I bought myself a heart rate monitor. (This one.) I figured that I wasn’t enjoying my running routine, and it wasn’t much of a routine anyway, so I might as well go whole hog into a training plan that was totally foreign to me; I didn’t have much to lose. I’ve been faithfully training with the heart rate monitor for about a year now, and overall it’s been a really positive change.

The first thing I did when I got the watch was to ask my wife if she had any resources for training with a HRM. Surprise! she had several, and she grabbed one for me from her unreasonably large library of running books. I found Heart Monitory Training for the Compleat Idiot by John Parker to be a helpful resource: written specifically for runners (as opposed to, say, triathletes), a very quick read, and full of advice that I found sensible and not overbearing.

The main takeaway from the book (spoiler alert) is that most people run most of their miles far too fast. When your “easy” runs aren’t legitimately easy, you’re never rested for the hard runs, and you never build the kind of stamina that you really need for distance running. (At the risk of sounding like a running nerd, the idea is to do the majority of your miles under your lactate threshold.) The heart monitor is used as a gauge for enforcing easy runs. The magic number is 70%: on easy days, keep your heart rate below 70% of your heart rate reserve, a figure which is calculated by subtracting your resting rate from your max rate, and then using your resting rate as a floor. For me, the calculation was something like this. I did a max heart rate workout (found a steep hill on a hot day and did repeats) and got my HR up to 192. Measured my resting rate over a couple mornings and called it 58. 192-58 * 70% = 94, which when added to 58 gives me an easy run ceiling of 152 BPM.

The first thing you learn when you start staying under this target rate during easy runs is that holy crap this is slow. I was accustomed to doing easy runs around 8-8:30/mile pace. With the HRM, on a hot July day, I found myself running at 10:00+. You also learn that hills are really serious business when it comes to heart rate. To stay under the 70% threshold on hills of any size, my shuffle devolved into a near-walk. It was torture. Physically, I had no idea what to do with my body when going that slow (your form totally changes). And mentally, I was humiliated getting passed by grandmas, kids, invalids.

But, I stuck with it, and after a few months things started to click. The weather started to cool. I found techniques for modifying my form up and down hills that would let me maintain some speed while keeping my heart rate down. And most importantly, I think that I really was building the kind of aerobic fitness that’d been promised in the book. Within four or five months, most of my easy runs were back down at 8:30 pace or faster – and they were all below the 70% HR threshold.

Some cool things happen when most of your runs are easy. For one, you can really go balls out on hard runs. Because there’s no latent fatigue from the previous few days (and because I know I’ll get legitimate rest over the ensuing days) I can pretty much run myself into the ground during workouts. Another benefit is that you can immediately start adding distance, because you never, ever feel tired during easy runs. I end every run thinking, gee, I feel like I haven’t even gone out yet. For someone who was used to feeling like shit after every run, this is a huge and welcome change that makes the whole endeavor much less unpleasant. Tracking your heart rate also gives you window into your general health. You might feel fine and plan to hit the streets at your normal pace, but if you are coming off of a cold (or have one coming on), your heart rate will be elevated, and you’ll be forced to slow down.

A couple weeks ago I ran the first road race that I’d done in a number of years. Looking back through my running logs, I see that the last time I ran a 5K at that pace, I’d been running twice as many miles per week, and I was five years younger. Granted, I’m still not running very fast in any objective sense, but this is still a pretty cool side effect of running a bunch of junk miles.

If you’re a runner and feeling like you’re in a rut – or if you’re someone who’s tried to run in the past, but could never get over that initial god-how-can-anyone-endure-this-torture phase – I highly recommend getting a heart rate monitor, and learning how to use it during training. It makes running more interesting and less painful. (Though I still don’t like it like my wife does.)

Expunge non-public content from a WordPress/BuddyPress installation

It’s a common practice to create local WordPress development environments using a copy of the production database. But this can cause problems with a large production site, as the database can become very large, and it is full of non-public information that you may not want to make available to all members of the development team. This is especially problematic when running a plugin like BuddyPress, which allows users to create a great deal of content with various privacy levels.

To work around this problem for the CUNY Academic Commons, I wrote this plugin: cac-database-cleaner. It will remove all non-public data from a WP database, while still leaving an intact database image that can be used to populate a development environment.

WARNING – This is a dangerous tool, as it deletes large amounts of data. Under no circumstances should you install this plugin on a production site. To use: export your production database; import to a separate database and perform any manual changes necessary for the WordPress site to load locally (such as modification of your local hosts file); activate plugin and navigate to Dashboard > Network Admin > CAC Database Cleaner.

Again, do not use this plugin if you don’t know exactly what you’re doing.

Note that plugin support is ideosyncratic to the CUNY Academic Commons, where we run an old version of BuddyPress Docs, an old fork of BuddyPress Group Documents, a plugin called More Privacy Options, legacy bbPress forums, etc. Feel free to modify the plugin to work with whatever other data you’d like.

Yes! We have no THATCamp

I work extensively with universities, but I don’t really think of myself as of universities anymore. One of the things that has most stubbornly kept me connected to the academic world has been the yearly pilgrimage to RRCHNM for THATCamp. Since leaving grad school, it’s been one of my last remaining interfaces with academia where I don’t feel like a service provider, but like an equal participant (kinda the point of THATCamp).

This year, there’ll be no THATCamp at CHNM. Until today, it hadn’t dawned on me that not only am I missing my usual summer kick-off, but I’m also missing my annual reminder that I used to be a geek-leaning academic rather than an academic-leaning geek.

On that note, an only slightly irrelevant clip:

CSV export of WordPress data

I’m often asked by clients to export various bits of data from a WordPress site into a CSV file. For simple queries, this kind of technique is simplest. For more complex queries, I use PHP to do some of the heavy lifting. Below is some of the boilerplate I use for generating the proper headers, etc. Just swap out the filename and the query logic for your own, and visit wp-admin?bbg_export as a super admin.

Five years of BuddyPress

I started working with BuddyPress by accident. In February 2009, I responded to a tweet from my friend Matt Gold asking for help with a CSS issue on a site he was working on. That site was the still-in-beta CUNY Academic Commons, running on the still-in-beta BuddyPress. Within a few weeks, I was doing paid work for Matt’s project, working with BP (and WP, and web software in general) for the first time. And BuddyPress 1.0 came out just a few weeks after that.

Over the last five years, BuddyPress has taken over my professional life. I began by writing BP plugins. I started to contribute to BP itself through support and patches. I became a member and eventually a lead on the core team. My consultation work involves BuddyPress almost exclusively; this success (in terms of both money and impact) emboldened me to drop out of graduate school. People know me as “the BuddyPress guy”. When you type “boone gorges” into Google, it suggests “boone gorges buddypress”.

I feel very grateful to have stumbled into the project when I did. It aligns with many of my philosophical and political positions: the primacy of people over content, the importance of data ownership and free software, the fight against parasitic software vendors in public institutions. I’ve met some good friends through my association with BP. I’ve leveraged my expertise into a fun and comfortable career.

But the fact remains that it’s all been a fluke. When I realized it’s been five whole years, I couldn’t shake the thought: WTF. How strange to devote such a large part of one’s life to something that was such an accident. [Something something destiny something something forks in the road something.] I got lucky because I happened to stumble into something that was a particularly good fit for me. But I also took many leaps of faith along the way: agreeing to work on the CUNY Academic Commons when I had pretty much no idea what I was doing, submitting my first patches to BP, quitting my job, upping my rates, donating huge amounts of time to the free project instead of doing paid client work. I’m glad I had the guts to make each of these leaps.

Happy birthday to BuddyPress, and happy anniversary to me. Here’s to many more happy accidents!

Manually copy content and settings between sites in a WP network

I just had a request to copy the contents and settings from one site within a WordPress network to another within the same network. (The destination site is the “staging” version of the source.) Daniel Bachhuber’s Dictator along with the general wp-cli export/import tools are the ideal tools for this sort of thing, but due to some odd circumstances I wasn’t able to use them. So here’s a quick rundown of what I ended up doing. (This post mainly for my own records. If any step below is confusing to you, you probably should not be doing it this way. Use at your own risk!)

  • Get exports of the production db tables (as well as staging, for backup). I ended up crafting the following (614 is the ID of the production site):
    mysql -u [username] -p information_schema -B -N -e "SELECT table_name FROM tables WHERE table_name LIKE 'wp_614_%'" | xargs mysqldump -u [username] -p [database name] --add-drop-table --skip-lock-tables --quick --extended-insert --result-file=[/path/to/dumpfile.sql]
  • I downloaded that dumpfile and imported it into a local database, so that I could run it through https://github.com/interconnectit/Search-Replace-DB to do the necessary URL replacements. (Could’ve used wp-cli, but this way I didn’t need to have a functional local WP installation.)
  • Did a further search and replace to change instances of ‘wp_614_’ to ‘wp_860_’ (the staging site ID)
  • Uploaded that .sql file and imported
  • Next, I had to handle files. Normally this would take 30 seconds at the command line, but permissions were locked down on this server: my SSH user didn’t have proper permissions to modify some of the directories in blogs.dir. So I wrote a quick script that would run the necessary commands in PHP (as the webserver user), implemented as an mu-plugin: https://gist.github.com/boonebgorges/75e3ec70bd5177dab7dd

Again, use at your own risk.

Dumb

Last year I wrote about my decision to remove email apps from my mobile devices. Today I took the next logical step and got rid of my smartphone altogether.

I was giddy when I got an iPhone in 2008. Having email and the web (and later, stuff like Twitter) on a mobile device was the coolest thing ever. But it’s become clear over the last year that the benefits of this connectivity are, for me personally, clearly outweighed by the drawbacks. The smartphone keeps me connected to the internet; I work on the internet; therefore the smartphone keeps me connected to work. And when I’m not at my computer, dwelling on work-related issues is both pointless (because I can’t fix them until I’m at a computer) and annoying (because duh). Even if there were a way for me to carve out a totally-non-work-related part of my online life, I’m not sure I want to have it in my pocket, where I’m always tempted to fiddle with it.

To make the transition a bit more fun, I got myself a legitimately nice dumbphone, the Nokia 515 (which I had to order from a shady-seeming importer, because it’s not supposed to be available in the US). I’m having a good time setting it up. It’s been a few years since I had to migrate my contacts manually, so I’ve built up lots of cruft. The only people I moved over to the new device are those I really like (and might want to call) and those I really don’t like (and want to screen). The camera on the Nokia is pretty good for a dumbphone, but totally lame compared to my Moto X. Using multi-tap to type is hilariously awful, but T9 is better than I remembered. It’s retro-fun.

Using this phone is going to introduce friction into my routine. Messages will be harder to type; appointments will be trickier to look up; addresses will be impossible to locate; and so on. But when I look around a subway car or a restaurant or a playground and see dozens of people gazing vacantly into the easy gleen of their smartphone screens, I remember that friction can be good sometimes.

Any major dude with half a heart surely will be at WordCamp Connecticut on May 10

A few months ago, I had the pleasure of speaking at the WordPress Stamford Meetup, organized by Clint Warren. I musta put a bug in his ear or something, because I got a follow-up email last month letting me know he was organizing the very first WordCamp Connecticut. I’ll be giving a talk about BuddyPress.

The organizers are still looking for speakers, so if you’re a WordPress person in the CT vicinity (Stamford is an easy Metro-North ride from NYC), please consider applying to present! And if you’re just looking to nerd out for a day, add yourself to the mailing list so you’ll know when tickets are available. DO IT

Garmin Forerunner 310XT hacks

I’ve been running with a Garmin Forerunner 310XT for about eight months now. I like it pretty well (running with a HR monitor has totally changed my running for the better, but that’s a subject for another post), but there are a couple really annoying things about it, which I’ve been forced to hack workarounds for.

  • For me, the plastic that houses the transponder on the chest strap caused pretty severe chafing. I think this is something that Garmin is aware of; my wife has a previous version from the same series (the 305, I think), and the strap design does seem improved. But for me, the first month or two was pretty terrible. The chafing was awful, and running four days a week, I never had a chance to heal. I tried all different kinds of lube, tried different ways of positioning the monitor (around the center of my chest vs just under my armpits), played with different levels of tightness. What ultimately ended up working for me was this. I wear it around the narrowest part of my chest, with the strap fairly loose. When I’m running more than five or six miles, I use a bit of runner’s glide. And – this has made the biggest difference for me – I wrapped the big hunk of plastic in a couple layers of athletic tape. It still irritates me a bit, but there’s no more bleeding.

    2014-02-16 15.11.17

  • The watch has this cool feature where you put a little USB nub in your computer, and it’s supposed to auto-download your latest activity as soon as the watch comes into range. This has worked for me maybe five times, tops. Typically, the software doesn’t recognize the watch at all, and for the first few weeks I owned it, I struggled to find a workflow that’d let me store my workouts on my computer. The only way I could make it work consistently is by re-pairing the watch + computer every time I want to download. Here’s what I do when I get back from a run (I use a Mac for this):
    1. Close the Garmin ANT Agent program in the toolbar
    2. Delete the local Garmin data folder: rm -rf ~/Library/Application\ Support/Garmin
    3. Start the Garmin ANT Agent application
    4. From the Garmin toolbar menu, choose “Pair with New Devices”. Within a few minutes, it’ll start re-syncing

    Aside from the general fact that this it’s Extremely Stupid, the annoying thing about the process is that it takes progressively longer to complete the more workouts you have on your watch (because you’re deleting your local cache, it’s got to download all of them each time). So, every few weeks, I delete all activities from the watch. But before doing so – because I don’t trust Garmin’s “Garmin Connect” online service – I make sure to copy the .tcx files from my local directory to some safe location. That way, I have offline access to my running history if I want it. cp ~/Library/Application\ Support/Garmin/Devices/xxxxxxxxxxxx/History/* /some/other/location (where “xxxxxxxxxxxx” is your device ID).