Skip to content

Thank you Derick Rethans for 15 years of XDebug

Dear Reader,

There are a handful of tools that have actually changed how many of us code PHP. XDebug is one of those tools[1]. There is no doubt of the impact that XDebug has has on PHP developers and PHP projects.

Recently, XDebug turned 15. (If you don’t know what XDebug is, start with this SitePoint article about Xdebug) This means that the man responsible for XDebug, Derick Rethans, has been supporting XDebug for 15 years, for free. XDebug is open source. Derick maintains it, answers questions about it, spoke at conference about it, and generally done everything he can to help anyone who is having an issue with it.

FIFTEEN YEARS!

Thank about that. How much code do you have that has lasted fifteen years?

So on this the (close to) anniversary of this product, many of us in the PHP community decided to do something to show Derick how much we appreciate it. Those that know him know that Derick loves a good Scotch. So we decided to buy him some. Originally, I was just going to buy him the most expensive bottle I could find and be done with it. However, my friend James Titcumb stepped in. He knew the owner of the shop that Derick buys his Scotch. He contacted the owner and we gt a quick education in Scotch. tl;dr, expensive doesn’t always mean good. He picked out a selection of bottles that he knew met Derick’s high standards.

On April 26th, 2017, James met Derick at the retailer and here is the video.

Thank you!

  • First and foremost, thank you Derick.
  • Second, thank you James Titcumb for going above and beyond on this project. Y’all really have no idea what he did to make this happen.
  • Third, I gotta say it. Thank you to the lovely and talented Kathy. It is hard to describe how difficult it is to live with someone like me who randomly sit up and shouts “I HAVE AN IDEA”. Yes, sometimes, she buries her face in her hands and weeps. Most of the time though, she supports me, she encourages me, and she helps me. This time, she worked with James to get the Scotch paid for. (Moving that amount of money across the pond is not as easy as you might think it would be.)
  • Finally, but not nearly the least important, thank you to the entire PHP community. When I setup the GoFundMe, I never expected to actually hit the $5,000. I would have been happy with hitting $1,500. As of right now we have hit $5,100! (I’m trying to figure out how to close the GoFundMe!) :)

    Part of the deal I offered companies was that if anyone donated at least $100, I would list their logo and link in this blog post. Here are the people and companies that rose to that level.

    Make sure you say thank you to these individuals and companies.[2]

All told, 151 people donated to make this happen!

So that’s it. We had some fun, we raised some money, we said thank you to someone who has given so much to all of us. Once again, thanks Derick. :)

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

p.s. I will provide a full accounting of all funds raised when I get home from traveling.

[1] The other two, IMHO, are PHPUnit and Composer.
[2] If you are on this list, you probably noticed there re no logos. This is my fault, not yours. Basically, I lost them in all my recent travels. PLEASE send to me again via email and I will update your entry.

“Uncle Cal’s Career Advice for Developers” book has been released

Dear Reader,Book cover for Uncle Cal's Career Advice for Developers

This past year at php[tek], it was my honor to be the closing keynote speaker. I wrote a talk just for tek called “Uncle Cal’s Career Advice for Developers”.  At the end of the event, since I never release my slides, I offered a free copy of the transcript to anyone in attendance. I sent that out about a month ago. Now I am finally getting around to publishing it for everyone else who may want it.

Two Options for Career Advice

I’ve packaged the book two ways.

For those of you who were at tek, I hope you enjoyed the talk. For those that weren’t there, you can still get the advice.

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

Silly WordPress Tricks, Part I: Exporting Blog Posts as HTML

Dear Reader,

I’m making some changes to my blog. Specifically, I am moving most of my Public Speaking blog posts to my mailing list. I’ve got more of those than I realized. Being a program, my thought process was of course “Why spend an hour copying and pasting all of these posts when I can spend two hours and write a script?” :) So I wrote a simple script using WP-CLI to gather the information. So I hammered out some bash to get the job done. I am proud that other than wp-cli, I did not have to resort to any additional PHP code to do the job. It was tempting at times, but I did it.

Yes, I am aware that wp-cli will export to a WXR file. I wanted something simpler.

No, this is not a complete solution. It doesn’t deal with attachments, comments, or metadata. I don’t need those for this project.

Purpose

This bash script will export all of the blog posts in a given WordPress category into individual HTML files.  There is no templating to control how they are output, it is not that smart. It takes no parameters, everything is hard coded.

Assumptions

  1. You have wp-cli installed on your machine, it is named wp, and it is in your path.
  2. You have a WordPress blog

Here is the script. Below, I will break it down line-by-line in case it’s not clear.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
HOME_DIR=~
WP_DIR=/path/to/public_html/
CATEGORY=speaking
mkdir -p $HOME_DIR/blog/$CATEGORY
cd $WP_DIR
 
for LINE in $(wp post list --category_name=$CATEGORY --fields=ID,post_name --format=csv| tail -n +2); do
        ID=$(echo $LINE | cut -f1 -d,)
        SLUG=$(echo $LINE | cut -f2 -d,)
        TITLE=$(wp post get $ID --field=post_title)
        POST_DATE=$(date -d "$(wp post get $ID --field=post_date)" +"%Y-%m-%d")
        AUTHOR=$(wp user get $(wp post get $ID --field=author) --field=display_name)
        echo "Processing $TITLE"
        echo "<h1>$TITLE</h1>" > $HOME_DIR/blog/$CATEGORY/$SLUG.blogpost.txt
        echo "<strong>Author: </strong>$AUTHOR</storng><br />"  >> $HOME_DIR/blog/$CATEGORY/$SLUG.blogpost.txt
        echo "<strong>Date Published : </strong>$POST_DATE<br />" >> $HOME_DIR/blog/$CATEGORY/$SLUG.blogpost.txt
        wp post get $ID --field=post_content >> $HOME_DIR/blog/$CATEGORY/$SLUG.blogpost.txt
done

2: This is the home directory. A directory named blog/CATEGORY will be created under this directory. It is set to the user’s home directory.

3: This is the root of your WordPress installation.

4: This is the category that you want to export.

5: Create the directory to hold the posts

8: Get a list of the post IDs for the given category. Execute lines 9-18 once for each post. The wp command in the for loop will return a csv list of ID and post names. (the slug)

9: Get the post ID from the CSV line using cut.

10: Get the slug.

11: Use wp to get the title of the post.

12: Use wp to get the post date. Use date and a format of YYYY-MM-DD to strip off the time.

13: Use wp to get the author id and feed that to wp to get the author’s display name.

14: Let the user know what we are currently processing.

15: Output the Title of the post as an H1

16: Output the By-line.

17: Output the post date

18: Use wp to gather the content of the actual post and output it.

Lather, rinse, repeat.

 

:Conclusion

This is one of those “gets the job done” scripts. It is brittle and it is fragile. There are a lot of ways to break it and there is zero error-handling in it. All that having been said, it gets the job done. More importantly, it illustrates one of the cool things about wp-cli, scriptability of WordPress. I live in the command line, wp-cli has quickly become one of my most used tools. This, however, is the first time I’ve used it as part of a larger script. I think that’s cool. :)

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

LinkedIn and Let’s Encrypt

letsencryptDear Reader,

Last night I was playing around with the LinkedIn REST API and quite by accident, I discovered something. If you have installed a Let’s Encrypt certificate on your site, LinkedIn will not read images included in your OpenGraph tags.

WTFBBG?!?

A little primer for my non-tech friends

Ok, for those of my readers who are not programmers, Open Graph is how sites like Facebook, twitter, and sometimes even LinkedIn display an image, a title, and a summary of a web page automagically when all you do is share the URL. Let’s look at an example.

If you go to my recent postcard, https://blog.calevans.com/2016/05/16/postcards-life-010/, and view the source of the page, you will eventually find a section with a bunch of meta tags. Some of them will look like this.

<meta property="og:title" content="Postcards From My Life - 010 - Postcards From My Life" />
<meta property="og:url" content="https://blog.calevans.com/2016/05/16/postcards-life-010/" />
<meta property="og:site_name" content="Postcards From My Life" />
<meta property="og:updated_time" content="2016-05-15T14:50:55-05:00" />;
<meta property="og:image" content="https://blog.calevans.com/wp-content/uploads/2016/05/palm_beach_001.jpg" />

See the “og:” there? that is your indicator that these are Open Graph tags. They give any site that pays attention vital information that otherwise, they would have to grep the HTML and attempt to infer. In the case of the tags above:

  • The page’s title
  • The page’s URL
  • The name of the site the URL comes from
  • When it was last updated
  • The image to use when displaying this URL.

That last one is important as it’s the one that LinkedIn is failing on.

Developers, start reading again

Behind the scenes, LinkedIn has a process that reads a webpage, finds the image, and hands all the open graph info back to the browser you are using via JavaScript. (What we used to call ajax) Somewhere in that chain

<pre>

Browser->LinkedIn Service->LinkedIn Image Service->Browser

</pre>

something is broken. Something doesn’t like Let’s Encrypt. How do I know, let’s run a quick test.

  1. Open LinkedIn.com in a separate tab and if you aren’t already so, log in.
  2. Click the “Share an Update” button
    Screen Shot 2016-05-18 at 10.04.38 AM
  3. Past in this link. https://blog.calevans.com/2016/05/16/postcards-life-010/
  4. Notice that you see the title and the copy, but not the image. The image is blank.
    Screen Shot 2016-05-18 at 10.04.55 AM
  5. Ok, abort this update and start a new one
  6. Paste in this URL https://voicesoftheelephpant.com/2016/05/10/interview-helen-housandi/
  7. See how the image appears? That is what is supposed to happen.
    Screen Shot 2016-05-18 at 10.05.24 AM
  8. You can abort this update now as well. (Or post it, it’s a good interview)

Voices of the ElePHPant has a different cert because Apple doesn’t like Let’s Encrypt either.

Conclusion

If posting to LinkedIn is important to you – and it is not to me – then do not use a Let’s Encrypt certificate. Get you a cheap one from ssls.com.

 

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

What do developers look for when they scan a job ad?

Dear Reader,

In my book “Culture of Respect” I have a section on writing job ads that will attract developers. I am in the process of revising that chapter, so I thought I would ask the people who actually read the job ads what they look for. The results weren’t that surprising to me. Having read a lot of job ads though, I am guessing that the results will be surprising to some managers out there.

I’ll let you read the results for yourself.

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