@madpilot makes

MythTV + XBMC = HOT SAUCE

In December, I blogged about my new Atom-based MythTV setup. Whilst is was OK, I’ve since bought a Jetway J9F2 coupled with a Core2 T5500 (1.6Ghz) CPU. Let me state this now: it is the best MiniITX based media centre setup there is. It has HDMI and DVI outputs, two gigabit network ports and digital audio, and has enough power to happily decode free-to-air HDTV. The layout suits my case better than both previous boards, as there seems to be more airflow – with two caveats:

  1. You NEED to use low-profile RAM if you want the DVD player to fit. I got some Kingston dual-channel sticks off eBay (2GB worth).
  2. Because I use right-angle PCI riser for my trusty AverMedia DVB-T card, I had to slice some of the plastic off the SATA cable to make it fit (The SATA ports are in a really bad spot). The SATA cable that comes with the board is slightly non-standard, which made it possible to perform the surgery – I don’t think it’ll work on regular SATA plugs, as they are thicker.

But besides that, it really is an awesome rig. Oh, it turns out that the “power” issue I had was actually because the DVD wasn’t sitting properly with the old board, which was causing something to jam, which in turn drew too much power and shut the system down. With the new board (and the low profile RAM) DVD playback works perfectly. I’m yet to try burning.

Anyway, since everything is now working properly, I thought it time to mess around with some more software! It is no secret that the MythTV UI is pretty bad (understatement!) – particulary the video and music plugins. Whilst we use the PVR features A LOT, we also watch videos and listen to music quite a bit, and with the library growing and growing it was getting harder and harder to find what we wanted to watch or listen to.

My little brother introduced me to XBMC a while ago, and I was really impressed. It actually feels like a real media center – it has slick effects, nice themes and just feels better. Up until November last year, it was a Windows only affair, but now the port to Linux has been released, so I have installed it. And it is ace. It’s not perfect, but it sure beats MythTV for video and music watching. Some highlights:

  1. When you are watching a movie, and need to go back to the menu, the video continues playing in a smaller window
  2. You can browse music by Artist, Album and Song (unlike MythMusic which is a horrendous tree setup)
  3. It is smart enough to group TV shows together AND it can pull meta data out not only for TV shows, but episode in those TV shows
  4. You can group different directories, so, if you are like me and have a couple of external drives, you can group movie directories from both drives into one list
  5. I’ve said it before, but (almost counter-intuitively) having nice animations and transistion makes things feel more polished and it does.

Although it does support the MythTV protocol partially for watching live TV, it isn’t ready for prime time yet – you can’t easily change channels, or view the EPG, nor can you change signal inputs or hit record to record a program which means I still need to run MythTV. Mind you, when they implement the API fully, I would happily drop mythfrontend for XBMC.

So make life a little more remote control friendly, I’ve added a custom menu item for XBMC into my /usr/share/mythtv/library.xml that just runs xbmc -fs (full screen mode), so I can select it from the Media menu item in MythTV.

There is still some outstanding issues though:

  1. I need to get my remote mapped properly – for some reason it ignores my arrow keys, which is really annoying. I guess I just need to mess with the Lircmap.xml file to sort that out.
  2. I need to work out how to add an exit menu item on the main menu – I haven’t got a key I can bind to the shutdown menu, which makes to make dropping back to MythTV impossible without a keyboard
  3. There is no interlacing support in the Linux version yet (that I can find anyway) so HD tv is unwatchable – no biggie – I use MythTV for that.

Other than that, give it a go – it is what MythTV SHOULD be. 4 1/2 stars.

Eway Rebill and Managed Payments for ActiveMerchant

If you are an Australian Rails developer and have had to deal with online payments, chances are you’ve dealt with Eway. ActiveMerchant has supported Eway for single transactions for a while, but if you have had to deal with rebilling, you may have been at a loss.

I’ve just forked ActiveMerchant and added support for the new Eway Rebill and Managed Payments SOAP API (Obviously, you’ll need soap4r). It’s on github. Very sparse instructions are here. The Rebill API might still need some work, as I ended up concentrating on the Managed Payments API, as that is actually more flexible.

Some background: When using the Rebill API, you tell Eway who you are billing, and when to bill them, and it takes care of the rest. The Managed Payments API on the other hand has Eway storing the users credit card details, and when you need to charge the client, you send a request via the API.

The problem I see with the Rebill API is there is no easy way to check if a payment has failed, other than pulling out ALL the past transactions and checking, where as Managed Payments will give you an immediate response, at the expense of having to maintain your own scheduled task/cron job.

Let me know if it works for you!

Global search and replace using the command line

If you have ever used Dreamweaver, you are probably familiar with the Global Search and Replace feature, which allows you to search and replace amongst all files with in a site, which can be very handy if you are doing a static site. If you are too hard core for Dreamweaver though, and you spend your whole day buried in a terminal window, how can you achieve the same thing? By this piece of bash-trickery, that’s how:

find . | grep html | xargs -t -I {} sh -c "cat {} | sed 's/Stuff to find/Replace with this/' > {}"
  1. find . – find all the files from the current directory down
  2. grep html – filters the output to include only filesnames with html in them
  3. xargs -t -I {} sh -c – pumps the file names into the cat command, but also sets a variable called {} that holds the filename
  4. sed ‘s/Stuff to find/Replace with this/’ – just a search and replace
  5. > {} – save the output back to the original file name A word of warning though, leave the last bit off until you are sure your output is correct, because there is no undo feature :)

MythTV on an Intel Atom

I’ve been using MythTV for about 4 or 5 years now, first as just a DVD player, video and music player and more recently as an actual television replacement.

Unsuprisingly, my old VIA M10000 was starting to get a bit long in the tooth (it IS a 4 year old motherboard that was underpowered when it was new), so when the D945GCLF was released by and Intel a few months ago, I decided to give it a go.

Just like all the netbooks out there at the moment, it’s a Atom 1.6Ghz, so it’s still underpowered, but it surely has to beat the old 1Ghz Nemehiah…

Since the board was so cheap – it was about $AU90, compared to around $AU300 I paid for the M10000, so the extra dollars I had to fork out for new RAM, a HDD (I needed a SATA one), power suppy and extra heatsink didn’t hurt as much as it could have.

The last two items were required because the Travla case I have only had a 60W PSU which turns out wasn’t quite gutsy enough (more on this in a moment) and because of the large factory heatsink (for the Southbridge or Northbridge or whichever one ISN’T the CPU) stopped the DVD player from fitting – thankfully an after-market low-profile heatsink seems up for the job.

Problem 1: The Realtek 8165 network card wasn’t recognised by the Gentoo 2008.1 live CD, since the kernel was too old. Throwing in a spare PCI network card allowed me to bootstrap it, and kernel 2.6.27+ seem to support the card. Thankfully the rest of the base install was realitely painless – well as much as a Gentoo install can be… As of that kernel, there isn’t yet a kernel optimisation options specifically for the Atom, so I picked the Dual Core defaults which seems fine.

Problem 2: I spend WEEKS trying to fix this until I gave up. As usual XvMC, the interface that makes DVD and digital TV playback less CPU intensive would segfault on Xine, mplayer and MythTV (From memory I spent two years trying to get the M10000 working – I’m obviously less persistent now). I tried different gcc flags, getting the latest version from the relevent repositories, but nothing seemed to work. However, since the CPU would happily decode SD over-the-air broadcasts and DVDs I was tempted to cut my losses and forget about it. The fact that XvMC wouldn’t have helped out HD content either (It theoretically maxes out for anything bigger than 1024×768 I think. Oh, and it doesn’t do MPEG4) the decision was made.

Interestingly, Xine would happily decode a Channel 10 “Full HD” ATSC recording, but MythTV seems a little more CPU hungry, so live tv is too choppy to watch. I wonder whether the dual-core version might have enough headroom – I might try that in the new year (Although I have a feeling the larger CPU heatsink will stop it fitting in my case).

Problem 3: The board would randomly (or not so randomly as it turns out) reboot itself. You would have thought after spending so much time in class during electronics units at Uni, I would have worked out that the 60W wall adapter I was using couldn’t supply enough juice. If the second USB tv tuner and the DVD player were in use at the same time, the picoPSU 120 would shutdown. Thankfully ebay came to the rescue, and an 80w adapter is sitting on a delivery dock somewhere in Hong Kong. Hopefully it will find it’s way to my house.

Problem 4: The volume from the Intel HD chipset is REALLY low. Normal listening has the volume at ~80-90, rather than the 30-40 of the old board. I can probably fix that, but it’s tolerable, so I’m not to worried…

Problem 5: The GPU fan IS LOUD. It’s ok when there is something on the TV at a decent volume, but when it’s off, it sounds like a really small 747 in there. Mind you, if we are in the lounge room, the telly is probably one, so again, no biggie.

Problem 6: The latest version of Gentoo has trouble compiling mjpegtools-1.8 which is required by mytharchive. I had to compile it by hand, after applying some patches.

Problem 7: There is a bug in the network card driver, where sometimes, if the system performs a warm boot, the network card will stop working, which can only be fixed by a cold reboot (sometimes multiple times).

Problem 8: Clutch – the web interface to Transmission has remove the ability to have transmission download .torrent files for you. Now you have to download them to the desktop, then upload them. Dumb. The developers said something about not wanting AJAX calls to have to wait, which sounds like a dubious excuse to me – file uploads aren’t AJAX calls, they have to make a full round trip to the server.

So after all that (Oh, come one – 8 issues is a walk in the park for installing Linux! :P), the system is up and running. Overall, it’s not bad.

Advantage 1: The menus are much, MUCH snappier than the old machine. I can press a button on the remote, and I no longer have enough time to make a cup of coffee before the menu item changes.

Advantage 2: The standard transitions in  mythphotos now work. OpenGL doesn’t though.

Advantage 3: One of the plus sides of not having to use XvMC means the OSD is in colour and not distorted (Because the overlaygot mixed in before the scaling is done, the font rendering always looks weird).

So if this a good buy? If you aren’t afraid of a compiler, and aren’t going to miss HD OTA (Blueray WILL NOT WORK), then sure – it’s cheap and mostly easy to get working. It would be nice if there was a DVI output on the board – Intel could have easily replaced the serial port or parallel port with one. It also would have been nice it they had put a better GPU – either a low powered one, or a better spec’d one, I’d be happy with either.

But all in all, for a cheap, interium board it’s quite nice. 3 stars.

Now do I make a bad pun about Christmas or summer BBQs…

You know what, I’ll save you the pain.

The reason I’m being tempted by such high-brow literary devices, is the AWIA Web Mixed Grill – 24 short web articles from now up until Christmas – a web advent calendar if you will. Today saw Miles Burke givng hints and tips about being a successful freelancer, and tomorrow I’m blabbering on about HTTP request codes or something, and I hear from a small avian creature that there is a number of other hawt-sauce articles coming up, so it’s well worth the RSS subscription.

Of course, if you think that you have what is takes to impart some knowledge on the web world at large, then there is still a few spots left, so email mixedgrill@webindustry.asn.au and pony up some grey matter.

Get the skinny on the Mario Brothers in Javascript

Since I’m trying to milk the Mario Brothers in JavaScript thing for all it’s worth, I’d like to announce part two of my SitePoint article, which gets into the juicy bits – collision engines and physics as well as side scrolling screens. Go forth, read and learn.

The need for speed

If you are a DBA, and your reading this – look away now, because I’m pretty sure they covered this in Database Optimisation 101 and you WILL laugh at me having this revelation. 88 Miles hasn’t been the snappiest web application around lately thanks mainly to an influx of users (NOT that I’m complaining :P). I’d successfully added some views to speed up some of the reporting recently, and I went through today and optimised a lot of code, but it still wasn’t as quick as I would have liked it (A page load in the main index page was taking on average 1.5 seconds – down from the 4 seconds pre-optimisations).

I was googling the performance differences between INNER and LEFT joins (INNER wins most of the time for those of you playing at home), and came across a word that I vaguley remembered between dozing off in my Database class at university – indexes. Now, don’t get me wrong, I KNEW these things existed, I even knew what they did, but because I don’t use them regularly, I didn’t even think to look at them. As all of the primary IDswere already primary keys, my gaze turned to the foreign keys (I use the term relatively loosely – they were foreign keys in the sense that they referred to another table ID, not because they had been explicity setup that way).

I added indexes to the foreign keys on the three main tables, and voila! A ~10x speed increase on that front page! It’s such a simple optimisation too! *Slaps head*

Running Passenger on Joyent

I’ve never been particularly happy with proxying Mongrel processes behind Apache – for one if makes it really hard to scale without using something like God (which adds yet ANOTHER process your website is dependent on) and having separate services means multiple points of failure.

PHP has had mod_php which makes PHP a first class citizen in Apache land, and with the release of Passenger (aka mod_rails) a couple of months ago Rails can now get the same privileges. As most of my production Rails apps (both for me and my clients) run on Joyent, here is a quick recipe for setting up passenger on the newer pkg-src accelerators. You need to be root to do a lot of this, so it might be easiest to

su

before you start.

  1. Getting passenger. DON’T use the gem, as it won’t work on Solaris – you need to pull it from git (I think it makes sense to put it in /usr/local):
cd /usr/local
git clone git://github.com/FooBarWidget/passenger.git
  1. Run the apache module installer:
cd passenger/
bin/passenger-install-apache2-module
  1. Create a configuration file for apache:
cd /opt/local/etc/httpd
echo "LoadModule passenger_module /usr/local/passenger/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/passenger
PassengerRuby /opt/local/bin/ruby18" > includes/passenger.conf
  1. Add the following line to /opt/local/etc/httpd/httpd.conf:
Include etc/httpd/includes/passenger.conf
  1. Make Apache a little less strict on what it can run. Open /opt/local/etc/httpd/includes/directory.conf and change the Directory directive to (Apache security geeks will probably lynch me at this point – please suggest a more secure setup):
<directory>
Options +FollowSymLinks -SymLinksIfOwnerMatch +MultiViews -Indexes -ExecCGI
AllowOverride ALL
Order allow,deny
Allow from all
</directory>
  1. Restart Apache:
svcadm restart /network/http:apache

At this point Apache will be mod_rails enabled. Now to update your application. There is two ways to do this: manually or via the Joyent capistrano receipe. I’ll outline the latter, and you should be able to work out the former for these instructions (Hint: the virtual host descriptions are in /opt/local/etc/httpd/virtualhosts/). Edit config/accelerator/apache_vhosts.erb and find the VirtualHost directive and make it look something like this:

<VirtualHost <%= public_ip %>:80>
  ServerName <%= server_name %>
  RailsBaseURI /
  DocumentRoot <%= public_path %>
</VirtualHost>

Then run

cap accelerator:create_vhost

followed by

cap accelerator:restart_apache

If all went well, your site should be now running via passenger! If all is well, we should remove the mongrel service and update our capistrano receipe, as the restart options are now different. To remove the the mongrel config, run cap accelerator:smf_delete. Finally open config/deploy.rb and remove the start and stop deploy tasks, and replace the restart task with:

deploy.task :restart do
  run "touch #{current_path}/tmp/restart.txt"
end

That should be it. Next time: How to do it on the older Joyent accelerators.

Interview: Marc Lehmann from Saasu.com

You may or may not have heard about a little conference we are putting on in a couple of weeks. We are particularly excited by the speakers that we have coming over. I was luckily enough to catch up with one of them: Marc Lehmann from Saasu.com for a quick chat about SaaS.

ME: Briefly explain what it is that your company does.

ML: Saasu provides secure and reliable online accounting software via the web so businesses can concentrate on financial success. In a practical sense you can create invoices, manage inventory, do the payroll and pay bills using a web browser in a synchronised way.

ME: You have been in SaaS, back when is was called ASP (Application Service Providers), how has the landscape changed?

ML: We used to call this a shared application back in 2000 before terms like Multi-Tennant and SaaS came along. The uptake was slow until eventually Salesforce.com educated the corporate market enough that they got traction in 2005. At the same time the consumer was falling more and more in love with having their stuff online. It was almost a barbelled acceptance by consumers and enterprises in 2006 and 2007. Small business and their advisers were probably the last to start the move and that was partly caused by the lack of applications targeting them. Now it mainstream with more than 20% of consumers who use computers using SaaS applications of one kind or another. I think 2010 will be the crossover year where software losses it’s grip.

ME: If you were back working for a corporation, how would you convince your manager to adopt SaaS systems?

ML: Getting people to accept they are already SaaS converts is the best way. They probably already use web based gmail, hotmail or online banking as examples. I’d then hammer it home by getting the P&L out and putting some big chunky black lines through the hardware, depreciation, software and servicing costs. Then add $20 to $200 per month for online accounting. Demonstrating the financial difference is very effective in larger companies.

ME: What are some of the challenges faced by SaaS providers, and how do you see companies like yours overcoming them?

ML: By far the biggest challenge is convincing people to kick their software habit. Fortunately they only have to try SaaS once before they realise it’s a much more powerful drug. They tend to flip the SaaS Utility switch on so they can have their business life online. Shifting their data to a high-end data centre with all it automated backups and high level of security becomes a whole new peace of mind addiction they didn’t know about. And at the same time it’s not ripping a hole in their pocket.

ME: Your background is in finance, so I’m sure you have an opinion on how SaaS will fair during this current climate – how do you see it affecting the uptake of SaaS services, and why?

ML: The low capital, fast implementation cycle for SaaS suits this financial crisis and economic slowdown very well. If you are looking to cut hardware, software and HR costs then invariably people keep coming back to SaaS as the answer. It is a user pays system that scales with business, saves capital expenditure and simplifies deployment and training.

ME: Thanks Marc!

If you want to hear more about SaaS, then head over to the Edge of the Web website and register your tickets!

Why freelancers should go to conferences

Let me take my Event coordinator hat off for just one moment, and replace it with my “Hey, I’m a freelancer – why should I fork our hundreds of dollars to go to a conference” hat (I have a lot of very specific hats). Miles Burke recently wrote about why you should attend two conferences every year, but what about you, my fellow freelancers, who have to watch the pennies? I personally think freelancers have the most to gain from attending conferences – think about it:

  1. Learning new stuff. As a freelancer, every minute you aren’t working on a client project is money you aren’t making. When do you get a chance to find out about new stuff? It’s usually squeezed in around lunch time or after hours, which is cool but how can you moot the benefits of a new tech? Although things like twitter or forums fill the gap a little, nothing beats old school, real word face-to-face talks. There are lots of people at conferences who’s minds are focused purely on new stuff.
  2. Meet famous people. Conferences are really just an excuse for the organisers to fly over people they admire. The thing is, because these people are only really famous on the internet, they are still usually really down to earth and approachable and are more than happy to chew-the-fat over a beer or three.
  3. Inspiration.  Smart people hang out at conferences. Smart people talk about smart stuff at conferences. Smart ideas are inspirational. Every time I come back from a conference I have a head full of crazy ideas that I wish I had more time to implement.
  4. Networking. I don’t care what anyone says – the MOST important skill a freelancer can have is the ability to network. 90% of my freelance work comes through people I’ve met (And I’d put money on the fact that most freelancers are the same). Freelancers by definition won’t have a dedicated marketing person, or a huge marketing budget, so networking is really a cheap and easy way to meet new clients (and more importantly new friends). Conferences have many people in a small area who could potentially want to talk to you. (Don’t forget your business cards).
  5. Tax Deduction. ‘Nuff Said

Ok, ok talk is cheap (thank god, otherwise I’d be bankrupt) but there really isn’t a way to describe the experience of a conference – the only way you’ll understand is to go to one. Now, you sandgropers are lucky because we have Edge of the Web on our doorstep. I had to fly to Sydney and sleep on a mates floor to get my first conference experience, and it still cost me nearly $2000 (but it was freaking awesome). You can get the same experience for $495 – I’m no Dr. Maths, but that sounds a truck load better.

Seriously, if you are umming and ahhing, just do it. I’ll see you in November :)

Previous Next