home

Archive for the 'Code' Category

MythTV + PVR150

Sunday, July 23rd, 2006

I have been using MythTV in my living room for the last couple of months, and it’s quite a nice setup. Originally, I got it as a media player after the DSM-320 didn’t live up to my expectations (it’s still usable, but it’s been relegated to the 13″ TV in the bedroom).

MythTV main menuWe don’t actually subscribe to cable, and only get a few network channels that ‘leak’ through from the cable internet, so I never really intended it to act as a PVR. One day I happened to see a good deal on a Hauppage PVR-150 that included a remote, so I figured what the heck.

Recordings screenIt’s nice to have it record a few shows every day, and the “only keep x episodes” feature is handy. I even have it recording the local 6 o’clock news (and only keeping 1 episode) since I never usually watch it at that time. It’s also nice to always have a few episodes of The Simspons to pick through.

Media Library screenI’ve never been a slave to the TV schedule, I’d rather just not watch something than re-arrange the rest of my life around a tv show. For shows that interest me enough, I’ll download them and watch them at my leisure, and never miss an episode or watch them out of order. Having a PVR to do that just makes things easier.

Live TVOverall, myth was fairly straightforward to get working. I installed it on a Debian Sarge box, from source, along with ivtv and lircd.

Program GuideI wanted to post some of my config files, particularly for the remote setup, since it was very difficult to find the files for these, and for some unknown reason almost no one has posted complete configs (that have all the buttons configured) for the remotes.

  • /etc/lircd.conf – Remote definitions for various Hauppage remotes
  • /home/mythtv/.mythtv/lircrc – Mapping of remote buttons to MythTV commands

Caller ID on screen displayI also have asterisk and FreePBX installed to run my phones (I’ll write another post about that another time). One of the nice things about it is I have an on-screen popup when someone calls. I’ve written instructions on how to set up freepbx with mythtv osd on the FreePBX documentation wiki.

It does take a bit of reading and a bit of playing around, but it’s well worthwhile to setup MythTV as a PVR.

By the way: sorry about the crappy quality images for the live TV, it’s from my cell phone camera. I couldn’t take a screenshot of the video output (it just came out blue, like in the program guide picture).

CodeIgniter

Tuesday, April 18th, 2006

I’ve been playing with a sweet PHP framework called CodeIgniter, and I have to say: I love it. It uses the MVC pattern, which I’ve never much cared for, but does it in a nice way: by staying out of the way. The models are incredibly basic, and really, you don’t even need them. The views are PHP templates done the way PHP templates should be done; with PHP.

Something many frameworks miss: the documentation is amazing. There is a great tutorial video on their website, and after watching it, many people say they’re hooked. The user guide is even better: well laid out, and it even has a slick interface and look that makes it pleasurful to use. What’s missing is pure API documentation, but there is a reference (that I now have printed and posted just above my desk) and most of the calls are outlined in the manual.

Unlike many other frameworks, it doesn’t impose any strict methods of doing anything. You have a controller that is a class with a bunch of functions. There are ‘helpers’, ‘libraries’, ‘plugins’, that all have a common way of loading ( $this->load->library(’session’); for example). These can be core libraries, or application-specific (installed in the application/ folder). The directory layout is very intuitive, and it can all go underneath an HTTP root folder (not requiring certain files inside/outside of a web-accessable folder — double plus for people using shared hosting with open_basedir restrictions).

I started experimenting with it for the second version of web interface I’m writing, and I actually decided to port another application I had 75% done to it. It’s still in-progress as I write some user authentication routines, and I decided to write a “SuperModel” class (yeah, kind of dumb name) that builds forms and validates them – because I hate manually building forms.

If you’re a PHP developer, I highly recommend checking this framework out. It’s only been around publically for a couple months and has been aparently downloaded over 5000 times, and has a growing and active community in the forums.

Sendmail Wrapper

Friday, December 16th, 2005

We had some spam problems last week, one of them caused by a form that wasn’t properly escaped. While that problem was fixed, the real problem was that it was hard to figure out what script had the issue.

To solve this, I wrote a sendmail wrapper for use by PHP (though really it could be used by anything) that logs the message along with the date, a message id (also inserted in th e headers) and the current directory (which gives the location of the original script).

It also extracts out the domain name from the current directory, but this is server specific so you’ll need to change the pattern to match your file system.

Eventually I’d like to include support to check for a maximum number of recipients, and maybe some other heuristics to check for spam.

You can get the script at:
http://gregmaclellan.com/php/sendmail.phps 

You should save this file as /usr/local/sbin/sendmail_logged.

The reporting script is at:
http://gregmaclellan.com/php/mailreporting.sh

There are instructions in this file for how to add it to cron.

Let me know if you have any comments, suggestions, do any improvements, or find any bugs.