Ruby code for creating redirects for my (roughly) 100 old posts

As I mentioned in a previous post, I moved my blog from my own host, to Google’s blogger. As a result, there are ~ 100 old blog posts that are linked to from all over the place and I’d like to have a graceful way to re-direct. The previous post mentioned updated the header with a 301 redirect. Going through so many old posts, and updating each one was nuts, so I wrote a small ruby script to handle the duties.


#!/usr/bin/ruby
# update_redirects.rb
# This script will traverse the directory given as the first argument
# and replace the contents of all files with the 'redirect_text'
#
# some special conditions: it assumes that they are php redirects, but you
# can use <meta> redirect tags as well for plain HTML
#
#

require 'find'

dir = ARGV[0]
redirect_text ='<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://blog.myhdbox.com/%%PATH%%");
exit();
?> '

# find all the files that were published by blogger (they are all in their
# respective year directories)
#
Find.find(dir) do |path|
if path=~/^./200.*.php$/
f=File.open(path,'w') # open 'w' truncates the file
new_text= redirect_text.gsub("%%PATH%%",path.gsub("./",""))
f.write(new_text)
f.close()
end
end

MythTV on a Mac Mini


I’ve finally gone and done it. I’ve purchased a new mac mini for an upstairs MythTV frontend. MythTV runs well on Mac OS X so I figured I’d give it a shot. I’ve never experienced anything quite as easy as this. The Mac Mini is the *perfect* MythTV frontend. I’ve unboxed (always fun with Apple products), plugged it in, gone through initial Leopard setup, and downloaded the precompiled dmg from The Snider Pad. I have my backend broadcasting itself as a UPnP Media Server, so when I fired up Mythfrontend.app on the mac for the first time, it found it right away. Once it connected, I was done. There were all my shows. Of course, the first thing I did was go straight to some of my traditionally difficult HD content, and it played it back flawlessly.

Now onto the next steps

  • I streamed HD over 802.11n in the same room as the router, I need a real-world test upstairs
  • The apple remote worked out of the box, but only has six buttons. The nice thing about MythTV is you can remap the buttons, but six… hmm… just not quite enough. I’ll need to find out if there is another remote that can work. I might go down the lirc path

Bottom Line

This was such a pleasant experience and the mini is soooooooooo silent that I’m counting the days until my monstrous 4 year old media PC dies in the family room! Another project might be to figure out what the most compatible tuner’s are for a mac and kill my loud backend in the office. I’ve been impressed with MythTV on a Mac OS X. I hope to write some apple friendly applescripts/automator actions to do some fun things that I’ve been dying to do.

Making google happy with redirects

I’ve been moving my blogs around a bit the last couple days, and the thought occured to me that I have years of posts that are still generating pretty significant traffic to my blog. How can I update the ‘old’ urls so that they 1) redirect the person who runs across an old link and 2) tell google to update my link in their search results and keep my rank.

Here you go:

<?php

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://blog.myhdbox.com/newpage/newurl.htm");
exit();

?>

That little dandy replaces every page that I want re-directed. Now… wouldn’t it be nice to write a little ruby script to go through my 100 posts and update each one!

New mac mini


The new mac mini has been released, and we’ve decided to go ahead and use it for a second frontend for the MythTV backend. Not that we’re big TV watchers, but having a second frontend upstairs gives us a chance to hole up upstairs when sick/etc… and watch the same programs as downstairs. We’ll see how streaming HD over 802.11n goes!

Upgrades galore

For the past six months, I’ve been content with Ubuntu 7.10 and mythtv 0.20. Very stable, very smooth solid HD playback, no recording glitches. Everything I could ask for. When Ubuntu 8.04 came along (along with an upgrade to MythTV 0.21) I resisted for a bit. If it ain’t broke, don’t fix it. Maybe it was just an excuse, but after deciding to set up a second front end upstairs, I also decided to install Mythbuntu 8.04. Little did I know that 0.21 frontends are not compatible with 0.20 backends… and so my upgrade began.

I’ll chronicle a few of the major gotchas I had and how I solved them over at the MythTV Tips page, but as a quick summary, it took about two days, and several nasty looks from my wife and kids to complete the upgrade of both the backend and the frontend. Everything is working wonderfully (again/finally) and there are a few cool surprises in 0.21 that made it all worth it.

Next up… installation of a frontend upstairs. I think I might go with a mac-mini for that one, and since I don’t have cat-5 upstairs, I *might* just try 802.11n.

Ubuntu + MythTV = happy me

Well, I know it’s been a while since I’ve posted. I’ve been a busy camper, and this blog hasn’t quite risen to the top of my todo list in a while. I was re-reading my past posts, and noticed that the theme has been my thoughts about switch from Fedora Core to Ubuntu. An update is that I made the switch a few months ago, and haven’t looked back. Ubuntu comes with all the mythtv packages that I use and was incredibly easy to set up for both my backend, and my frontend systems.

My current system is Gutsy (7.10) and I used the guides from the Ubuntu community docs for setting up mythtv (https://help.ubuntu.com/community/MythTV). No big gotchas for me, even with my HD setup.

Mythbuntu looks promising

I just ran across a new distribution of mythtv in a box (along with MythDora and KnoppMyth) called MythBuntu and I plan on giving it a test run this weekend. The project is currently in alpha. One nice thing is that they offer a live cd version so that you can simply drop in a disk and run a mythtv frontend anywhere you want (we’ll have to see how well that one works!). Lirc is not available yet, so it won’t be an option for me in terms of actually replacing my FC5 frontend, but I can’t imagine it will be too long before they get that working.



Technorati Tags:

Back from Vacation

I just got back from a vacation with the family. 2,000 miles in two weeks with a four and seven year old in the back.

Of course, no major road trip would be complete (or even possible these days) unless you provide some kind entertainment. When I was a kid, that consisted of hours on end of singing “I’ve been working on the railroad”, and playing every possible variant of I-Spy (I spy something that starts with the letter P — Peterbilt — again…). But for somebody with MythTV on the brain, you have to think a bit outside the box. Enter LaCie’s Silverscreen.. I won’t go into a major review here, but this little guy can output up to 1080i via component, it also outputs S-Video, and composite, and can play almost every popular video format. We hooked it up to a pair of 7″ TFT displays strapped to the back of our headrests, and the kids had more shows than they could possibly watch during the trip. Where did the shows come from? MythTV + nuvexport to Xvid format. Being able to take my content on the road with me in a totally open format is one of the great advantages to MythTV. I know there are other commercial solutions available, but since they are all closed source, you need to use proprietary solutions which are either more expensive, or have less features.

Wendy Seltzer, EFF Lawyer and MythTV user debates Fritz Attaway from the MPAA in the WSJ

When Fritz Attaway starts out the entire debate with this line:

Attaway:“Digital rights management is the key to consumer choice…”

He then goes on to explain how by being able to control the content, and how it can be distributed, and used, the movies studio’s can get a return on the millions they made to make a movie. See how much better that is for us? It occurred to me that he really believes that.

Wendy replies that the DMCA stifles technological innovation, and she describes that there are still no legal solutions for viewing DVD’s on her Linux computer (go Wendy). Then she throws him this:

Seltzer:“DRM plus DMCA protects existing business models, such as that of the blockbuster movie, but at the expense of new developments that could create more value for both creators and users of content. In the era of podcasts and YouTube, I’m quite interested in seeing what those users can do as they become creators.”

What she’s getting at here is that if the MPAA continues down their current path people will find ways around them, not just DRM.

Over and over again, Fritz stresses that any possible innovation around Media technologies that are disallowed because of current DRM are completely acceptable because it’s more important that the studios make money.

Fritzie:“‘Transformative’ uses are fine, but they cannot be given priority over the incentive to create new works. A central tenet of our fair use doctrine is that fair uses do not interfere with the ability of the creator to exploit the economic value of her work.”

I don’t know about you, but it seems clear to me he knows exactly who pays his bills.

The debate rages on, and is a must read.