Skip to content

In Celebration of B-Sides

Dear Reader,

One of the most beautiful rock songs of my lifetime, “Beth” by Kiss, was originally released as the “B-Side” to “Detroit, Rick City”.

I know I’m in the minority here but I will go to my grave believing that with “Beth”, Kiss hit it’s pinnacle. Yet, the relegated it to a B-side.

The band, and their producers couldn’t see the beauty they had until much later when fans started clamoring for it to be played on the radio. It was the band’s highest charting single…ever.  (It hit #7 on Billboards Hot 100 chart.)

Tech Conference B-Side Talks

Tech conferences are sometimes like that. Some CFP programs actually ask speakers “Is this your best talk?”. They are looking for the A-Sides.

Honestly, I have no idea what my “best talk” is. I know the ones that I get a lot of comments about, but I can’t say that those are my best.

I can tell you my favorite talks. My favorite talks are not my keynote talks, my favorite talks are the ones where someone comes up afterwards and tells me that they picked up something that they can use in a project they are working on. They are my favorite talks because they actually helped someone.

I recently tweeted out a piece of speaker advice.

Speaker Pro Tip: Write a second talk. Call it your “B-Side” talk. (Kids, ask your parents what that means) Have the slides with you at any Conf or Camp you attend. So far in the past 3 months I’ve scored 2 extra speaking slots because I was prepared.

I didn’t mean to classify the talks by importance, more by “acceptability”.  There are some talks that it’s easy to get accepted at a conference because they push a hot button or they are about the “shiny”.

“B-Side” talks are talks that are important but that conference organizers don’t feel they can take a chance on.

The next time you attend a conference, look for talks that are off the beaten path. Look for those B-side talks.

Hidden in among all those great sessions is the next “ZOMG DID YOU SEE…” and you will be able to say “Yeah. I saw that one last year and it was great.” :)

Until next time,
I <3 |<
=C=

p.s. There’s nothing wrong with “Detroit Rock City” but it’s an obvious attempt to write a rock anthem. “Beth” was art for the sake of art. Thank you Peter Chriss.

Thank You for Small Acts of Kindness

Dear Reader,

Five or six years ago, my good friend – and the Don of the PHP Community- Mr. Michelangelo van Dam – was listening to me ramble  at a conference.  I was rambling on about the fact that every time I go over to Europe, I have to lug around my crappy power converter, and sometimes the converter won’t fit on the power strips provided at conferences at the podiums. I’ve actually had to present on batter and hope that the battery lasts. (it always did)

A while later, I ran into Mike in the hall and he handed me a cord. It was the cord to an Apple power adapter but with the European end on it. He told me that he had several spares and asked me to take this one. I smiled and took it and thanked him for his kindness. When I got home, I put it gently int my “cable box” (any audio geek or programmer knows what that is) and honestly, I forgot about it…that is until last week.

I am working  with a company that is Mac-centric so while my primary machine is now Windows, I am carrying my Mac with me so I can get work done. The problem is that I still have that 1 crappy power converter. While packing, I remembered Mike’s gift. I dug through my cable box and there it was just waiting for me to remember it and use it. I’m happy to say that as I sit here and type this on my Windows machine, my Mac is quietly humming away building a docker container or some such nonsense. Both machines are powered. :)

I know that any Mac user usually has 2 or more of these cables laying around from old power supplies that have crapped out but the cord is still good, so I know that it didn’t cost him much to give it to me; but that’s not the point. He saw a need, and he quietly did what he could to fill it. It doesn’t matter that I didn’t use the cable until years later, what matters is that he made the effort to solve my problem…and it eventually did.

Open source developers are like this. They give of their time to build things, things that you may not need right now. When you do need them, they are there and ready for you. Their acts of kindness – small or large – come into play exactly when you need them.

The next time you install a new open source package because it’s exactly what you need to build the project you are working on…take a moment to drop the author an email and thank them. Thank them for their act of kindness. You’d be surprised at home many of them never hear from users and are appreciative of your small act of kindness.

Until next time,
I <3 |<
=C=

 

p.s. Thanks Mike for the power cord…it is EXACTLY what I needed. :)

My 2019 in Content

Dear Reader,

Creation

In 2019 I created

Consumption

In 2019

  • I read 19 books. Not the 24 I had hoped for*, but better than the 12 in 2018.
  • Consumed entirely too much TV – TV being the generic term for movies and episodic tele-plays I consumed across multiple devices – which is why I didn’t hit my numbers on books. I’ve got to flip that.

Conclusion

I’m ok with my 2019 stats, but I think I can do better. I’ve already started writing a book that will be published early next year and I’ve already roughed out a keynote talk. I’ve also started a third podcast. (More on that later)

This post isn’t to brag, and it is not to make anyone feel that they haven’t done enough. I’ve done this much because of how I am wired. I am wired to create things. (Note: I did not say anything I created was good, just that I created it)

I firmly believe that I should create more than I consume, but that is a maxim for me, not for everybody. You do you and be proud of it.

Until next time,
I <3 |<
=C=

 

* When you count re-reads, I went well over 24. Some books I read 3 times this year.

WordPress, REST, and RegEx

Dear Reader,

I’m going to add this to “Using the WordPress REST API“, but I thought I would blog it here as well.

I have a tendency to over think things.

Today, I was working on a REST API endpoint for a client and it needed to have RegEx in it. I hate RegEx with a passion usually reserved for XML, but unlike XML, it’s a necessary evil, so I dove into it.

1
/item/(?P<itemId>\d+)

That’s an example.

For the uninitiated, when you are defining a custom WordPress REST endpoint, one of the things you can do is put in Regex into the route definition and WordPress will use that to pull out content and make it a parameter. The code above defines an endpoint for

https://example.com/wp-json/my-namespace/v1/item/4

When run, it will make a parameter named itemId whose value is the 4 from the URI. It’s incredibly handy. They are very easy to work with, especially if you are using numbers like 4, or even 294875.  Strings…well, strings get tricky.

The above example expect a number (so no alpha, just numeric) and numbers are contiguous.  You don’t have numbers with a space in them. Phrases however, have spaces. And what I needed to pull out was a phrase. So, I did what I always do, I pulled out Regex 101, and started figuring this out. This is where the overthinking part comes in.

I got it working in short order, then I started thinking. “What if…”

  • What if There’s a query string at the end
  • What if there’s more to the URI
  • What if there’s a slash at the end
  • …what if

This is where I got into trouble. I lost a good 2-3 hours designing a beautiful piece of RegEx that handled every situation I could think of. It was art, if I do say so myself. The only problem was that once I pasted it into my WordPress REST Controller, it did not work.

So I did what every developer does, I assumed the problem had to be in WordPress. I rolled up my sleeves and found out how WordPress matches routes.

What WordPress does

WordPress matches REST routes in WP_REST_Server::dispatch() (wp-includes/rest-api/class-wp-rest-server.php)

1
$match = preg_match( '@^' . $route . '$@i', $path, $matches );
$path is the URI. IN my case
https://example.com/wp-json/my-namespace/v1/item/this%20item%20name
$route was the route I defined in regex.
1
item/(?P<itemName>[w+].*)[?|/|\$]
(I’m working from memory but I think that was it.)
If – and only if – I could set some pattern modifiers I could make it work…but I couldn’t.
Then I began doing the other thing that PHP developers do a lot, I began throwing var_dump();die(); into WP_REST_Server. I thought I needed to see what was going on. Turns out, the answer was there in front of me all the time.
I was assuming that WordPress was applying my RegEx standalone from everything else. If you look at the line above though, you can see that is uses the route that I define in it’s entirety.
  • It puts a ‘@’ at the beginning of it. This tells PHP that ‘@’ is the regex delimiter, not ‘/’ like usual
  • It adds the caret ‘^’ to match the beginning of the line
  • It concatenates the route I defined
  • It adds the $ to match the end of the line
  • It puts the ‘@’ to signify that this is the end of the RegEx
  • It adds the ‘i’ pattern modifier (the things I needed to tinker with) to indicate that all matches should be case insensitive
WordPress doesn’t worry about the query string, or anything after that because it’s already stripped it off. I don’t have to overthink this thing with subgroups and special characters, WordPress has got my back.
My finished product ended up looking like this:
1
item/(?P<itemName>w+.*)
This gives me a parameter named itemNamethat includes everything past item/ to the end of the line.

Conclusion

Stop over-thinking things. Sometimes just let the framework do it’s job. :)

Did I meantion I hate Regex? :)

Until next time,
I <3 |<
=C=

p.s. the section in the book will be more coherant. I’ve spent the day with RegEx so I’m a bit scatterbrained now. :)

Why I teach

Dear reader,

I am a selfish person. I do not generally like to share my time with anyone and would rather spend it doing the things I love like video games and scuba diving. However, I owe a debt that I am honor bound to repay.

I am where I am in life because others helped me get here. Yes, I am a self-taught programmer, I mean that in the traditional way of I have no formal training in software development. But self-taught does not mean that I did it all myself. I learned from others. I read their blogs, I listened to their podcasts, I went to their conference sessions. I did the learning, but others all around me taught, mentored, and generally lifted me up to where I am.

Knowing this, I spend a portion of every day trying to help others. Some efforts are more successful than others, but as long as I am trying, I am paying back the debt I owe.

Others sacrificed so I can be where I am. It is my duty to sacrifice so that I can lift the next generation of developers up higher than I could go. To lift them up on my shoulders so that they can stand there and see further than I ever could.

Until next time,
I <3 |<
=C=