twenty

Twenty.

I’m sitting in bed typing this and Lily is reading a Chinese newspaper she picked up after dim sum with The Girl this morning. She wants to keep those language skills alive. Tomorrow morning I’ll read this one last time and then press “Publish”.

It will be July 16th, 2014 and I’ll have been married for twenty years. I’ve been with her for more than half of my life. Memory works by association and I remember all of those years from when I first met her.

It’s easy for me to remember. A smell, a word, a sound and I can associate it with something involving her.

I can do the same thing from before we met but those memories are strange.

I remember my family. I remember school. I remember summers upstate for weeks running around in just shorts and nothing else. Shoes at home will always be optional for me because of that.

She’s there in those memories but she’s not. It’s like she’s off stage and just hasn’t stepped into the scene.

I’m learning how to swim in a lake and she’s just out of sight at the shore. I’m coming back from the grocery store for my mother carrying 2 big brown bags full of food and she’s just around the corner. I am speaking with my grandmother and she’s there listening to every word. I’m learning that I have some of my other grandmother’s gift with animals and she’s nearby but she doesn’t like dogs. I’m climbing a tree and she’s waiting for me to come down. I’m in high school and my grandmother is gone. She’s reaching out to me waiting to hug me.

She’s there and I can’t explain it. It feels like I’ve known her, wept with her, lived with her and loved it all my whole life.

We’re meeting for the first time. I’m nervous and I don’t know what to do or say. My friend introduced us. I don’t know how I have the confidence to speak with her and I’m speaking too much. I’m meeting her family for the first time and working hard to impress them. I’m holding her hand. She’s meeting my family. We’re starting our own family. We’re doing things together, big things. It’s all so easy saving, planning, doing it all with her.

She’s reading this. She’s here. She’s with me.

putty-vi

Excerpts and not full content, but only sometimes

WordPress filters and actions remains one of my favorite features. There is so much that you can easily manipulate without modifying a theme’s files.

For example: on my front page I like the latest published post to show the whole content with a featured image if there is one. For the rest of the articles I want to display the excerpt and no featured image. This is the same on the front page and subsequent pages.

One way to do this is to create a child theme and modify the PHP to get the effect you like. There’s a few reasons why I don’t like that option.

  1. Child themes are fun and I always recommend users create them. But I’m bad at maintaining them when the parent theme is updated.
  2. My CSS is just awful and I’m pretty sure I’d break the responsiveness of my site.
  3. Filters are cool! I can use this code in a plugin.

Filter the_content

I took a shot at making my own filter but a quick search found that Justin Tadlock had written a really good post on the topic already in 2008. I use that code in my function but added a few lines.

// Get the ID of the last published post
$mh_last_id = wp_get_recent_posts( array( 'numberposts' => '1' ,
     'post_status' => 'publish' ) )['0']['ID'];

// Get the post format. If the post is a standard format then the value will be false
$mh_post_type = get_post_format();

I do not want to show an excerpt for the latest post  and only want to modify standard post formats. Anything else I want to skip. The reason I only want to play with standard format posts is that other post types break horribly when I force the excerpt this way.

Except for adding to the conditional statement, the whole function is copied from Justin’s post. He writes great code and explains it much better than I do.

// If is the home page, an archive, or search results and not the last post and is a standard format
if((is_front_page() || is_archive() || is_search()) and $mh_last_id != get_the_ID() and !$mh_post_type )

That’s a little ugly to look at but it does the job.

What about the featured image?

In the past when I wanted to hide the featured image in a child theme I would use CSS like so.

.ryu-featured-thumbnail, .attachment-ryu-featured-thumbnail, .wp-post-image {
     display: none;
}

Which works but is a little heavy handed. My WordPress installation still sends the HTML for the featured image and the browser still pulls that image. The end user just doesn’t see it because it’s not being displayed.

I don’t want to remove featured image support from the theme and I don’t want to send that HTML either. Thanks to the post_thumbnail_html filter I don’t have to.

add_filter( 'post_thumbnail_html', 'mh_post_image_html', 10, 3 );

function mh_post_image_html( $html, $post_id, $post_image_id ) {

// Get the ID of the last published post
$mh_last_id = wp_get_recent_posts( array( 'numberposts' => '1' ,
     'post_status' => 'publish' ) )['0']['ID'];

if ( (is_front_page() || is_archive() || is_search()) and $mh_last_id != get_the_ID() ) {
     $html = '<!-- Featured image not displayed in excerpt -->';
     }
return $html;
}

This code checks if we’re the first post and replaces the post_thumbnail_html with a simple HTML comment.

Child theme or plugin?

This code works either way. At the moment I am using this in a plugin but the whole thing can be implemented in my child theme’s function.php file.

It belongs in the child theme because I’m playing with the presentation and that is theme territory. Editing a copy of content.php in the child theme directory would be more theme’ish but I like filters. Filters are cool.

I’m not good at keeping my child theme changes in sync with the parent theme so using a filter lets me just play with the results and not mess with theme files. In a plugin or the child theme’s functions.php file the filters still work the same.

There is no anonymity on the Internet

Well, at least in the U.S. there really isn’t. This morning around 2 AM EDT a troll followed me from a topic on the WordPress forums from Denver, Colorado.

He’d poked around for about 30 minutes with his Android tablet using Firefox (likely from his parents basement) and left a racist contact form submission about my wife and how I “struck out with pretty white girls and ended up in the bottom of the social barrel”.

There’s something really sad and pathetic about someone posting that from their parent’s basement after midnight their local time.

None of that bothers me; trolls on the Internet have been around forever. I’ve heard that in the work place (though that was 20 years ago) and hey, it’s the Internet.

Had he left anything remotely threatening then instead of a blog post I’d be preserving log data for law enforcement and making some calls this morning.

What irks me is when a plugin developer follows me home to continue an argument or leave a “<EXPLETIVE DELETED> YOU!” message. When that happens I don’t get angry but I do get disappointed. It doesn’t happen often as most WordPress developers are cool.

Troll are bad. WordPress developers losing their mind? More sad than anything else. I expect people who contribute to the community to be better than that. ;)

Really? Congratulations!

I get odd solicitation calls but occasionally people dial it up to eleven to try and sell things.

Yesterday Lily got a call at the store from someone looking for me. It happens and I’m pretty sure that Googling my name might lead you to the store’s WordPress site.

What was odd was that they’d pronounced my name perfectly and seem to have a Polish accent.

Lily got the phone and had this conversation.

Sales Monkey: Can I speak with Jan Dembowski?

Lily: He’s not here. Who is this and why are you calling?

Sales Monkey: Do you know when he’ll be back?

Note to Sales Monkeys everywhere? When my wife asks you a direct question just get to the point. Do not make her repeat herself. She can track down your boss, call him if she wants to and hurt you in “ways”.

Lily: Why are you calling?

Sales Monkey: Does he speak Polish and have life insurance?

Ah ha! Yep, Sales Monkey. This is the same person who called me at the house looking to speak to and sell life insurance to my late Dad. That was a fun conversation.

In short order Lily explained that we’ve got that covered and stop tracking me down. I don’t speak Polish and these are not the marks you are looking for.

Sales Monkey: (Incredulously) He does not speak Polish? He is not from Poland?

Lily: He doesn’t and he was born here in the United States.

Sales Monkey: Oh. Congratulations!

I had no idea I was special for that reason. I alway thought it was my carefully honed sense of humor.

plane-went-that-far

Just mind the wind

My son is a fan of all things remote controlled and his latest thing is R/C airplanes. After indulging him with R/C cars Lily and I told him that he could get one under 2 conditions: he had to earn it and he had to pay for it out of his own pocket.

Note to aspiring parents: watch out for setting well defined conditions. After weeks for trying to behave well and saving up we went to the hobby store and picked up a HobbyZone Duet. He paid cash and got a receipt.

This is a starter plane and like most of them is built using light weight foam. Last week it took a nose dive and I had to use white glue and clear tape to put the nose back on. He did everything right but it took a dive onto some pavement and neatly broke the nose off.

Yesterday we went to his school and he gave it a good run but within 2 minutes he wanted to stop.

“Dad? I’m going to land it now.

Me: You could but why not keep it in the air for a while? Notice how there’s nothing you can crash into up there?”

That convinced him and he built up his confidence and nearly ran the battery down. He landed perfectly in the grass (we took the landing wheels off).

The second run was more fun. The plane weighs next to nothing and a light wind pushed it slowly across the school fields. Slowly as in we didn’t notice how far it really was until we saw the tree line. Fortunately he landed it without crashing and we had a great time.

It’s a fun hobby but this plane really needs a calm day to fly.

Praise The Monkey!

Some work stories you can share. Years ago I had a production change and I didn’t quite implement it correctly. It was fixed quickly but the user wanted what happened.

User: “In the least technical language possible can you explain what happened?”

We were on speaker phone in the support center. My pal thought for a second, looked at me and with all the seriousness he could muster replied like so.

Pal: “The Monkey pushed the wrong button!”

He emphasized “The Monkey” and “wrong button”. Fortunately she had a great sense of humor and we all laughed. Most people do enjoy a little levity in the work place.

4999436984_aca3f6862d_b_controlled-implosion

The replacement VPS didn’t go BOOM!

Yesterday I moved my WordPress network from one VPS in Chicago to Atlanta (different VPS hosting company). I like using a VPS because it maintains my illusion of being in control of my server.

*Drinks more coffee*

Surprisingly it went well. Except for missing a couple of PHP modules I had no problems and the site has been stable overnight.

If you plan to do this then give this Codex article a read. Of course I didn’t read it myself, it’s much more fun for me just winging it.

Create and configure my new VPS

I installed an image of Ubuntu 13.04 and made sure SMTP was configured to work. Apache2, PHP, mysql and mod_ssl were added and activated as well.

That was a surprise for me. The default image installs a ton of stuff that I don’t think I’ll ever need or want. I would have preferred to use a 14.04 LTS image (not available, too new) but that one is still maintained so it’s all good.

Creating the new empty database was straight forward. I used the same database name and user from the original VPS setup. Configuring the vhosts was just a matter of copying the old config files and making sure the certs and directories are all preserved.

Set DNS TTL on stun

My default DNS TTL (time-to-live) is 1800 seconds. I wasn’t sure if this would go well or not so I made the TTL 300 seconds (5 minutes). I didn’t change any IP addresses but if I broke something and couldn’t fix it then I was looking at only 5 minutes for it to come back to life.

Copy the files and database

My WordPress network has around 1.4 GB of file data from the last 7 years or so and the mysqldump was about 70MB . The file copy was just scp -r and the mysqldump command was just for that one network database.

Importing the database was just

zcat dumpfile.sql.gz | mysql -u name -p databasename

Once that was all done I updated my DNS IP and waited.

And I waited. And waited some more.

I could see in my access log that my new site was getting hits but I was still hitting my old web server (I was tailing the old logs in another windows) well after 5 minutes.

What the heck? It’s DNS. Setting the TTL just works. Except when it doesn’t.

I was using Google Chrome and that has it’s own application level DNS cache. It has a DNS cache that apparently doesn’t honor the TTL on the record.

Once I cleared that cache then I could see myself hitting the new IP address.

Nothing broke! Fantastic.

Next steps

Once I’ve confirmed that I have moved everything off the old VPS and onto the new then I’ll rebuild the old one and might re-do this whole exercise in the other direction. I’m sure the unstable nature of the old one is due to some dumb thing I did code I installed that’s running amok.

In the meanwhile I’m going to enjoy some nice stability and uptime for my site.

Note: The CC image above was a result of my typing “controlled implosion” into the WP Inject WordPress plugin. It’s a very cool plugin for finding CC images and I plan on leaving a review on WordPress.org sometime.

Featured image photo by Savannah River Site