Mostly Harmless

Mostly about my amusement

Archives (page 9 of 97)

Cross platform browser bookmarks?

Chrome on my laptop drains the battery dry so I’ve installed the current Firefox and went through some quick installations and all is right in the world. I installed the following:

  1. Firefox – Duh.
  2. 1Password4 extension
  3. Greasemonkey

It struck me that my favorite tools have cross platform equivalents.

  1. Chrome
  2. 1Password4 extension
  3. Tampermonkey

But what I am lacking is a tool to easily sync my browser bookmarks. Yes, I can easily export and import them but I’m lazy and would prefer a tool that works across all browsers.

I may need to give Xmarks another look. I forgot why but there was something about it years ago that turned me off.

I prefer using apps that work the same between platforms. I use Postbox for that reason (it’s also a cool mail app) even though it doesn’t have any data sync exactly. I’m using the same mailbox in both so the experience is the same even when I accidentally send a private email to a mail distribution list. I make the same mistakes on both versions.

The same goes with the 1Password application and I was thrilled when the Windows version was updated. The 1Password app is a great example of cross platform utility. The experience between Windows and Mac just works and it works consistently.

I’ll need to do some digging for a bookmark solution that I like.

Featured image Photo by Titanas

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 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.

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.

Yes, of course I bought it

wolfenstein

I just completed Crysis 3 (a $5 purchase that got me to buy a new NVidia graphic card…) and was looking for a new game to play. Since I’ve owned every Wolfenstein game that was ever produced this seemed like an easy choice to make.

It’s a 40+ GB download from Steam. Wow.

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.

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

Better SSL with mod_substitute

Renewing my SSL certificates was on my to do list for months and today I’m at home recuperating from a fever that kept me up all night. Since my web server is now patched it is a good time to get new SSL certificates. So I contacted StartSSL and did the deed.

WordPress and SSL has always irked me because just putting a certificate on the web server and using the https URL would still give you elements that are loaded via http (not SSL) and your browser’s address bar would look like this.

ssl-conflict

See that yellow warning triangle over the lock? It irks me. It does. It’s a personality flaw, a blemish, an imperfection. It loudly announces to the world that I’m Doing It All Wrong™. I see that on my site and I hang my head in shame.

OK it’s not really that big a deal. I could play with WordPress SSL plugins but part of my background is configuring applications on servers and Apache2 has a useful module called mod_substitute.

I have two configuration files for my site. One is for the http version and the other is for SSL. It’s like two separate virtual hosts with the same directories.

After I enabled mod_substitute I added these lines to my SSL config.

<Location />
 AddOutputFilterByType SUBSTITUTE text/html
 Substitute "s|href="http://blog.dembowski.net/|href="https://blog.dembowski.net/|"
 Substitute "s|href='http://blog.dembowski.net/|href='https://blog.dembowski.net/|"
 Substitute "s|src=' http:|src='|"
 Substitute "s|src="http:|src="|"
</Location>
# NOTE: Remove the space before the http above

I’m using the alternate delimiter “|” because I don’t want to escape out the URL slashes.

That’s probably too many lines. The first two Substitute lines replaces any URLs of mine from http:// to https://. The next two are for any reference that load elements using plain “http:”. I don’t substitute those with “https:” but instead make those URLs “//” without an explicit protocol.

Doing that gets this image in my browser’s address bar.

ssl-conflict-gone

Green is good. Order is restored.

Why didn’t I use a WordPress HTTPS plugin?

Because I’m lazy and not feeling well. Also using mod_substitute lets me filter the HTML output after WordPress has generated it but before it is sent to the web browser. That gives me more confidence that I’ll get all of the URLs that I want to change.

I’m only using this trick on the SSL version of my site. It’s not a perfect solution and I’m curious to find what this breaks. I had to disable Jetpack’s Photon option because some of my images were not being sent to that CDN properly and there may be other thing as well.

This is not something for everyone (if you’re on a shared host for example) but if you can load Apache2 modules and restart your web server then this may work for you too.

Update: Using (.*) instead of “blog” works for my other vhosts as well. Nope, that breaks LOTS. reverting back.