Press "Enter" to skip to content

Author: Russell Finn

WordPress, nginx, and category links

I’m dabbling in gaining experience with web services in my spare time. I decided to bring my blog up under nginx rather than Apache. Everything seemed fine except that the category links oddly stopped working and led to a 404 result from nginx. Googling was strangely unproductive at first until I realized that the common guidance for fixing permalinks (which I did not see a problem with) also applied to category links.

The solution is to modify the location / directive in the server block to include a last-change rewrite to feed the URI back to WordPress’s index.php, and more importantly, to remove the =404 that causes nginx to fail when it can’t match the permalink to a file on disk. Specifically, my location originally read:

location / {
    try_files $uri $uri/ =404;
}

and needed to be changed to:

location / {
    try_files $uri $uri/ /index.php?$args;
}

Now nginx will do the right thing. Yay.

Comments closed

VisualEffectPlayground in Swift

When searching for information on implementing vibrancy effects and NSVisualEffectView, developers often find references to the VisualEffectPlayground sample code presented by Apple at WWDC 2014. However, they soon quickly discover that Apple pulled the sample code from the Apple Developer site. Perhaps the application was thrown together for WWDC and didn’t meet the usual standard for Apple sample code; however, to date Apple has not seen fit to post any replacement. And so the search continues.

During my own search, I discovered that a Xamarin engineer named Oleg Demchenko had ported the sample code to Mono and posted it to the Xamarin samples site. In order to get a working sample application, I decided to port this code back to Swift and posted it to GitHub.

DISCLAIMER: I don’t know C# and I’m still learning Swift. Nevertheless, the resulting application appears to perform as expected (although I haven’t made an exhaustive test). I will certainly consider any pull requests.

1 Comment

Blocking autoplay videos on Macworld

I hate ’em, you hate ’em; even the writers hate ’em as well.  I finally got fed up enough to figure out how to completely block the autoplaying videos on the Macworld website.

Most instructions tell you to disable Flash, but I don’t even have Flash installed on my main computer (outside of the player embedded in Chrome, but I primarily use Safari).  It turns out that the Macworld website will then load a video player from Brightcove, so you have to block that too.

I’m using AdBlock, so I click its toolbar icon, choose Options, and go to “Manually Edit Your Filters”.  Click “Edit” and insert this text:

! Block autoplay videos on Macworld/PCWorld (need to block Brightcove as well)
www.macworld.com##DIV[class="video-wrapper small-player"]
www.pcworld.com##DIV[class="video-wrapper small-player"]
players.brightcove.net

That seems to be the lowest common division; higher level entities are named “how-to” or “security” or some such. Might as well get PCWorld while we’re in there. Don’t forget to click “Save”, and you’re done. (Also don’t forget to pay for AdBlock; I’m doing that right now…)

3 Comments

Downloading Office 2011

What do you do when it turns out that your downloaded disk image of Microsoft Office 2011 for Mac is on the 3TB Seagate drive that failed last week, and you didn’t back it up because you thought all that was on it was archived TiVo recordings?

Turns Out™ TJ Luoma knows what to do. Thanks, TJ.

(Next time: recovering data from a 3TB Seagate drive…)

Update 2016-01-21: Also Turns Out™ that if you already have Office 2016 installed, you can log into your Office account and go to the Install page; there is a link that says “Install previous version”.  Clicking this will download a disk image file containing an Office 2011 installer.  (The creation date of this installer is November 20, 2015, and the contents appear to be version 14.5.9; the most recent update as of this writing is 14.6.0, so remember to run Check for Updates after installing.)

Comments closed

Hold your calls…

I believe we have a winner. Still wrapping up a few details, but it looks like I’ll be starting a new position that fits my interests and experience, cuts down my commute by a significant measure, and hopefully will be more stable to boot. (Two layoffs within a twelve-month period make for interesting times.)

Here’s to the future!

Comments closed

Looking for work redux

As a result of a change of direction at my current employer, I am once again open to a full-time position as a software developer — preferably on Apple platforms, i.e. OS X and iOS, using Objective-C or Swift with Xcode. View the “Résumé” page (linked above) for links to my current résumé, my LinkedIn profile, etc.

Comments closed

Looking for work

As a result of a reduction in force at my previous employer, I am now looking for work as a software developer — preferably on Apple platforms, i.e. OS X and iOS, using Objective-C with Xcode. I prefer a full-time position but would accept short-term contracts as well. View the “Résumé” page (linked above) for links to downloadable résumés, my LinkedIn profile, etc. (If the “Résumé” page isn’t linked above, then I’ve found a job. Hooray!)

1 Comment

Updating the cover of the Swift iBook

Apple updated the cover of The Swift Programming Language to match the new book in the series, but deleting and redownloading the book within iBooks in OS X Mavericks didn’t update the cover — it continued to display the original cover.

The solution was to quit iBooks, delete the iBooks cache located at ~/Library/Containers/com.apple.iBooksX/Data/Library/Caches/com.apple.iBooksX, and restart iBooks.

You’re welcome, Internet.

5 Comments

Improved cwd restoration in tcsh

My previous post illustrating a technique for restoring the current working directory in Apple’s Terminal for tcsh users was discovered by Khoo Yit Phang, who suggested an improved version down in the comments. I’m reproducing it here for greater visibility:

if ("$?TERM_PROGRAM") then
  if ("$TERM_PROGRAM" == "Apple_Terminal") then
    alias cwdcmd '( set echo_style = both; echo -n "33]7;file://${host}${cwd:ags/ /%20/}a" )'
    cwdcmd
  endif
endif

Compared to my approach, it has two improvements: (1) by using cwdcmd (of which I was previously unaware) rather than precmd, it only runs when you actually change directories; and (2) by using a suitably configured echo, it avoids running an external command (printf is not built into tcsh, but is present in /usr/bin).

Thanks, Yit.

Update: Of course, with this technique you have to explicitly run the command once, to restore the working directory to the title bar for the first time when you start up. Fixed above.

Comments closed

Current working directory restoration in Mavericks Terminal with tcsh

In John Siracusa’s excellent review of OS X Mavericks, he (originally) mentioned that the Terminal application is able to restore the current working directory of open shells across launches.

However, this section has subsequently disappeared from the online version, perhaps for the reasons given below (update: see below). Try looking here for a cached version of the original; scroll down to page/slide number 94. Sorry, John. Please purchase the full review on the iBooks store or the Amazon Kindle store to support John’s work.

Of course I was excited to try this out as, in the course of my work as a software developer, I often have several shell windows open in specific directories. So I tried it, and it didn’t work. It turns out the built-in support supplied by Apple assumes that you’re using the bash shell, but as an old-timer I’m stuck on tcsh instead:

Well, that’s no good, I thought. So I looked in the supporting code’s implementation (/etc/bashrc), and figured out how to do the same thing in tcsh. Simply place the following in your .tcshrc file:

if ("$?TERM_PROGRAM") then
 if ("$TERM_PROGRAM" == "Apple_Terminal") then
  alias precmd 'printf "33]7;%sa" "file://$host$cwd:ags/ /%20/"'
 endif
endif

This uses the appropriate escape sequence to send the URL of the current working directory to the terminal before each command; Terminal detects this information and uses it to update the state of the window (including a proxy icon in the window’s title bar for the corresponding folder). It turns out that the key is doing it using precmd (tcsh’s equivalent of PROMPT_COMMAND), and not sending the sequence in the prompt string itself as one might think. (The outer if statement is necessary to avoid an error when remotely logging in, as with ssh. It has to be a separate statement because of the variable expansion rules in tcsh.)

I’ve notified John via Twitter, so perhaps he add restore this information back to his review. In any case, it’s documented here for future generations. Drop me a note below if you have any issues with it.

Update: It turns out John removed it because he discovered it was a feature in Mountain Lion as well, which had happened not to work on his machine:

If you listen to John’s podcasts, you’ll realize that makes sense: he wouldn’t let something not new in Mavericks stand in the Mavericks review. Regardless, I wasn’t aware of the feature before and it still wouldn’t have worked in tcsh, so this post is presumably still useful. (Note that I haven’t tried it on Mountain Lion, and I’ve already upgraded my working machines to Mavericks; I don’t know why this technique wouldn’t work on Mountain Lion, but use it at your own risk.)

Update 2: OK, so it turns out the feature was first implemented in Lion, and other people have already figured out how to port it to other shells; see here for an implementation in zsh, for example. How did I manage to not learn about this for the last two years? Oh, well…

5 Comments