Toby's Log page 84

Globbing files including dot-files

Normally globbing for the wildcard * will find all files in a directory except for ones beginning with a .. Sometimes I need to get all files including the dot-files. The pattern .* will find these hidden files, but will also include . and .., referring to the directory and its parent. As I’ve learned in the past, this can be dangerous with commands like rm, (i.e. you running rm -rf .* to remove dot-files will remove more than expected). Today, needing to get all files in a particular path in PHP, I sought a solution. A post on a Perl forum gave me a solution using curly braces: {.??*,.[!.],*}. Braces basically allow multiple comma-separated patterns to be evaluated. The three patterns are:

  1. .??* matches a dot followed by two characters followed by any number of characters.
  2. .[!.] matches a dot followed by a single character that isn’t a dot. This is needed since the previous pattern doesn’t match this case.
  3. * is the normal wildcard glob, matching all non-dot-files.

In PHP, the glob() function requires the GLOB_BRACE flag to use braces. An example might look like: $files = glob($path . '/{.??*,.[!.],*}', GLOB_BRACE);. This did exactly what I wanted.


Moving folder symlink and trailing slash

It caught me by surprise that if you use mv on a symlink to a folder and have a trailing slash on the path, it will move the entire original folder rather than the symlink. As a simple example, if you have a symlink ‘symlink’ pointing to the folder ‘original’ and run mv symlink/ new-symlink, you will end up with ‘original’ now being named ‘new-symlink’ and a symlink ‘symlink’ still pointing to the now non-existant ‘original’. Luckily, merely reversing the arguments will move the folder back to its original location: mv new-symlink symlink/. The symlink becomes like a magic portal. I probably wouldn’t have run into this if it weren’t for the ‘fish’ shell adding trailing slashes when doing tab completions on folder paths or symlinks to them.


Finally finished my taxes and got everything mailed. Always a relief with a tinge of worry that I did something wrong. I’m getting money back for the first time in years, and was able to pay this years first quarter estimates with over-payments of last years estimates. This was due to me making less than previous years, but it did feel good to not have to deal with the estimates.

Except, of course, for Cleveland, part of CCA. CCA makes you, with the way the form is set up, subtract your over-payment from the whole year estimate and then pay a quarter of the remainder. Even though my over-payment was more than my estimated quarterly owings, I still had to mail in a check. It’s like a penalty for over-payment. And if I instead took my over-payment as a refund and then payed the real quarterly estimate, they have separate mailing addresses for returns that have refunds and returns that have payments. Not sure what I should do when one return is both. Confusing. Which is a common problem with city taxes. They always seem to have things that are vague and confusingly worded, set up differently than federal and state, and there isn’t the software guidance or countless web articles, posts, and answers to help that there is for federal and, to a lesser extend, state.

As I say every year: Next year I should probably pay an accountant to help me with this stuff.


Feeling worn out after spending somewhere near five hours this evening between:

  • breaking down and burning sticks and other wood from previous tree / branch / bracken removal and dead-fall
  • scooping dog poop

The start of a busy weekend.


WordPress plugin: changing rel-canonical

I serve my site over both HTTP and HTTPS to support older browser that can’t support modern or any HTTPS protocols. I prefer HTTPS for search engines and general use though, as it is more secure, increases user privacy, and is factored into SEO rankings. Due to an issue with my sitemap, Google ended up indexing all of my blog pages as HTTP. The first thing I’m going to try to get Google to show my blog pages as HTTPS is to set the rel-canonical link to the HTTPS version regardless of which protocol the visitor uses. WordPress doesn’t have a built in way to change the canonical URL, and I didn’t want to install a heavy SEO plugin just for this, so I wrote my own.

This simple plugin removes WordPress’s rel_canonical action, then replaces it with its own. I basically re-implemented WordPress’s own functionality, replacing the http with https before outputting the link. It looks like:

Continue reading post "WordPress plugin: changing rel-canonical"

Tax worries again

This past night I worked on my taxes, a stressful endeavor. I am an independent contractor, which has made things way more complicated than they used to be. I’ve been using the Free File program to use online applications for filling out taxes for years now, usually using TurboTax or H & R Block. They abstract from the forms and walk me through everything, and often provide help when I’m confused, but they can sometimes be worded confusingly. I just do the best I can. The biggest problem with the abstraction is that everything is trapped in this interface, so it’s hard to review it yourself and make sure everything is right.

Every year I worry that I’ve done something wrong, and this year is no exception. Since becoming an independent contractor, having to pay estimated taxes, I don’t really get a “return”, either applying my over-payments to next year or often having to pay additional. This year, though, I have a rather large over-payment, more than enough to pay my first quarterly estimates for 2016. That worries me. I’ve made a fair amount less than last year, so it may be right, but I’m still unsure. I’m going to sit on it and come back to it another night, see what I can do to review it.

Another thing I do every year is say that next year I’m going to work with an accountant. Every next year I wait until it’s too near tax time to comfortably figure out how to do that. I don’t really know how that works or what it would cost. It’s more of a consultation and review of how I’m doing the taxes myself that I need. Maybe next year. We’ll see.


Got moved to a new server in a new datacenter by Dreamhost this weekend. Seems to be significantly faster than the old one for first page load, like an order of magnitude. It’s more in line with what I get when testing locally. I assume the server I was on was just overloaded. It had often had a load average in the 6’s or 7’s. I had been wondering what was wrong and if I should swtich to VPS. This one’s been at less than one. Hopefully it stays snappy and doesn’t get too loaded up over time.


I was using Jetpack’s sitemap plugin and even submitted it to Google until I noticed that it had the wrong protocol for all of the post URL’s. Now Google has a bunch of ‘http’ URL’s for my posts in its listings, even though they are available over ‘https’. I couldn’t figure out how to change the protocol (there is no config or documentation about where that is coming from) so I just disabled the sitemap for now.