Mostly about my amusement

Month: October 2014 (page 1 of 1)

October 24th

Tomorrow is the 2nd anniversary of when my Dad passed away. It’s also the day I fly to attend WordCamp San Francisco and in all the excitement I’d completely forgotten the significance of the day.

That’s alright and it’s good. In my immediate family we’ve never been concerned about such dates. The thing to remember is the person and the impact they’ve had on you. You remember their life and not their death.  That doesn’t mean I don’t remember Dad; not a day goes by when one of us will say something like “Grandpa could fix anything”.

Dad’s hobbies where simple: learn how to build anything that he needed to make or repair something else. He was an electrical engineer and that often meant he would write his own custom assembly language compilers for some EEPROM he needed to program. Or test different paints for cooking a 1930’s radio chassis in the oven to reproduce the right wrinkle effect. Did you know that you can bake some clear plastics to remove the cloudiness and make it more transparent and new?

I don’t have that level of expertise in my hobby but I knew that Dad understood why I like to get involved with WordPress. He would approve of my attending a WordCamp (I only started at WCNYC this year) because you can’t ever stop learning new things.

That’s a recurring theme in my family: learn new things and do those things you like to do. That’s a large part of what my family taught me and I hope I pass that onto my children. That’s what I’ll remember tomorrow and how I’ll observe the day.

Remove shortlink URLs from comments

Or remove them from anywhere, though I’m not sure why you’d remove shortlinks from your own author’s posts.

I’ve written a small plugin that will filter your comments using preprocess_comment which is a useful filter comment data before it’s committed to your database. The other toys I used are wp_extract_urls and wp_remote_head to make http head requests to web sites.

The plugin works like this: you feed a function a URL and it gives you back a URL but with shortlinks you get the real destination. It uses wp_remote_head() to make an http HEAD request and looks for the location header.

If it finds that header then it recursively calls itself to get real destination up to 5 requests. After 5 requests the URL is replaced with the # sign. If it doesn’t find that header then the original URL is returned.

Depending on your site that can be a lot of URLs and to cache those results I create transients for those URLs. The next time in a 12 hour window that URL is tested then WordPress will pull the data from the transient.

I’ve never used transients and I’m not sure this is a good idea or not. But if you need to eliminate shortlinks then this plugin might do it. Also this parses all URLs in the post or the comment and that’s probably not necessary. A simple check can be put in to see if the URL is on a list of shortlink providers and ignore all the rest.

You can download the plugin from this Gist page.

Once you’ve downloaded it save it to your wp-content/plugins directory as short-links-begone.php and activate the plugin in your WordPress dashboard. This plugin will not change any post data or old comments. It will modify new comments when they are submitted.

sed to the rescue again

Some days you just want to quickly edit a bunch of config files in one go.

One of the reasons I use Ubuntu LTS is that it’s got long term support (<light sarcasm>is that why it’s got LTS in the name?</light sarcasm>) and I make configuration templates that I just reuse in all the places. Poodle was announced and the short of it is that you need to disable the SSLv3 protocol on your web server.

No big deal. Visit your sites-available directory and change “SSLProtocol All -SSLv2” to add “-SSLv3” at the end. 17 times.

*Drinks more coffee and makes that face*

Or you know, run this command after checking you have “SSLProtocol All -SSLv2” in those mod_ssl config files.

sed -i.bak -e 's/SSLProtocol All -SSLv2$/SSLProtocol All -SSLv2 -SSLv3/g' *.conf

The -i.bak is to create unedited copies because bad things do happen to nice people.

Once I made sure that the files were edited I ran these commands to restart the web server and test.

service apache2 restart
openssl s_client -connect blog.dembowski.net:443 -ssl3

I promptly saw this line.

140496364975776:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:596:

And all was right in the world. I deleted the .bak files and finished my coffee.