Mostly about my amusement

Category: Geek (page 6 of 36)

OK, no more Xmarks for me

I like the idea behind Xmarks but there seems to be something I am doing that’s just not working.

Here’s what I’ve done.

  1. Installed Xmarks on all of my browsers. For Internet Explorer this meant a small system tray app.
  2. Made one set of bookmarks the Master To Rule all of My Bookmarks™. I did that once and confirmed that Xmarks has those bookmarks via the My Xmarks page. Neat page BTW.
  3. Synchronized all of my browsers. The first time I selected “the download and erase bookmarks on this browser” option.
  4. Bookmarks are synchronized! Sweet.

A few days later I started losing whole sections of my bookmarks. Not so sweet. Fortunately Xmarks has a great revision system and I was able to roll back to the set I wanted. Repeatedly. Sometimes more than once an hour.

I think the culprit is Chrome but I just couldn’t get the darn thing to behave. I’m sure Xmarks is not at fault, It’s just that one of my browsers never attended kindergarten and doesn’t know how to share with the other kids.

I’m back to manually synchronizing my bookmarks which isn’t a big deal as I don’t add to them that frequently. For Firefox I’m using Mozilla Sync which has developed into a nice option from years ago. For that browser it just works and also synchronized my add-ons, preferences, etc. For Chrome the bookmarks are shared using the Great Google Data Collection Experiment™.

This may have been why I stopped using this software in the first place. Meh, back to sorta syncing my bookmarks at least in Firefox and Chrome.

I may have broken my Feedburner feed

After I converted my WordPress install to 100% SSL I noticed that my own feeds in Tiny Tiny RSS were not updating. Years ago I forwarded my RSS feeds to Feedburner and 301 redirects from https://blog.dembowski.net/feed/ https wasn’t working.

I can’t even remember why I used Feedburner. I’m pretty sure I turned it on in a moment of “What’s that button do? *Monkey pushes button*”.

I’ll keep testing but eventually I’ll disengage Feedburner and just use https://blog.dembowski.net/feed/ instead.

Edit: This work around seems to fix it.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} blog.dembowski.net [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/feed/$
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteCond %{QUERY_STRING} !^feed=rss2$
RewriteRule ^(.*)$ https://blog.dembowski.net/$1 [R=301,L]
</IfModule>

The part starting at line 5 is where I added conditions so that the SSL 301 redirect will be ignored.

Why not use SSL and be done with it?

On the Internet there has been talk about Google and SSL based web sites. Apparently you may get a small boost if you switch to https. I myself doubt that (I’m jaded that way) and the additional SSL math will slow down busy sites a little. But I don’t get enough traffic to care really and I do like to play. This seems easy enough to do.

I Like Server Based Solutions and I Cannot Lie

I use WordPress multisite and on my web server I have a valid SSL certificate installed. I’m already using Apache’s mod_substitute to modify https://blog.dembowski.net/ to https: before it get’s sent to the browser for my SSL site.

Why not switch to SSL and be done with it? I could have used a tool to change all the WordPress database references to https but I’m running multisite and I wanted to be a little more site specific so I added this to my .htaccess file above the WordPress part but below the “Get Lost, I don’t like you” part.


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} blog.dembowski.net [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://blog.dembowski.net/$1 [R=301,L]
</IfModule>

So far it hasn’t broken anything and is limited to my this one and not the other sites. I’ll keep an eye on it but there’s no reason for me not to leave it that way. I like server based solutions but for other people a HTTPS plugin may be an easier way to go.

The only downside is that I will need to maintain my SSL certificate but I plan to do that anyway.

So this means I wear a tin foil hat?

Not really but it does mean in most cases people visiting my site will get the traffic encrypted between my site and their browsers.

*Adjusts Tin Foil Hat™ and skips conversation about  SSL transactions and man in the middle interception*

It’s more a concern that someone will have some key logger or other hack installed on their machine.

Sniffing unencrypted data on the Internet is easy. Doing so for encrypted SSL traffic is more difficult. It would require the Bad Guy or Spook to have access to the private certificate issued by the certificate authority. Or exploit a server bug and harvest the SSL private certificate from the web server. That would never happen right…?

If your interested in how it all works then start with this Wikipedia article on TLS. This Digicert article is good too and may be easier reading. In the meanwhile anyone coming to my site will get redirected to the SSL based version.

That was a short walk and I installed Xmarks

When I switched the laptop back to Firefox I bemoaned the lack of being able to synchronize my browser’s bookmarks with each of my other devices. That was on the list for why I used Chrome in the first place:

  1. Shared passwords
  2. Shared history
  3. Shared bookmarks
  4. Participating in the massive data collection experiment known as The Great Google™ BOW BEFORE THE DATA COLLECTION MONSTER!

That last one always made me tighten my tin foil hat just a little.

Shared passwords are easy with 1Password. I set it up to synchronize with Dropbox, picked a reasonably complex password that I can remember and just go. I have my passwords on Windows, Mac, my Android phone and the iPad. It doesn’t work with Linux as far as I know but I always have my phone with me and it’s all good.

Using Xmarks covers the other items and it works well.

I use it to synchronize my bookmarks and history but I turned off the other add-on items like site info. This shouldn’t surprise me as I’d used this tool before and I still can’t recall why I stopped using it (though it might have been because it shutdown for a while).

It works in the background and with those other features disabled it’s really transparent and unobtrusive. That’s good software design: it performs it’s job and gets out of your way. Cool.

I could setup my own server to sync with but I don’t think my bookmarks are really that telling. That doesn’t mean there is not a lot of good social engineering potential in my bookmark data: it’s just that I’m already tracked one way or another by the Great Google Monster™ so Xmarks isn’t high on my list to be concerned about.

Featured image photo by B Rosen

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

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.

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.

Careful what you post online

So it began innocently with this Tweet/Foursquare check in.

Screen Shot 2014-04-04 at 8.09.43 AM

I checked in with Foursquare which is something I do on a regular basis. I do this every time I visit the store. It’s a form of advertising in my not so humble opinion.

The store then got a call from someone named “James” asking for me. When I picked up the phone I was asked if I’d locked my key in the car. Naturally I asked who is this and a short game of “Don’t you know?” which ended with Lily saying “That’s nice, everything is fine now, goodbye.” and hanging up.

I thought the call was from a customer so I gave the phone to Lily. “James” claimed to have met her yesterday.

Here’s what happened: either the Tweet or the Foursquare check in matched a search. Somone saw that the store has a web site, the phone number is there and the rest is history. Or it could have been one of my followers (I’d like to think that’s not the case) or I’m on a Twitter list.

Now as stories go this is creepy and definitely stalkerish but it could have gone much worse. There was no swearing, no shouting and we didn’t get a call back (the number was marked private of course). But that really was my own personalized PSA about casually posting some details online.

I’ve been using social media (that’s a great term isn’t it? It beats “online extrovert”) and I am always aware of the risks. We’ve all read about or even know someone who has been harassed and stalked. I’ll try and be more circumspect about details like that in the future. It’s unfortunate but it’s the reality of this media. The world is more connected and that fellow could have been calling from anywhere.

If someone’s reading this and getting a chuckle then thanks for the wake up call. I’ll adjust accordingly.

What really irks me is that I’ve been trying to get Lily to use Twitter. This little episode really cements her opposition to that. It’s not that she has anything against Twitter it’s just that that medium doesn’t interest her. This small event pretty much means her social interactions will remain squarely in the real world.