Monday, December 11, 2006

MythTV - just a myth or a reality for the Linux neophyte

<rant>Rant #1 - I have to start this off with 'WHY ME, WHY ME, OH THE HUMANITY!' Why you ask - well barring the fact that this is now 2:30 am, I have been attempting to get MythTV running on my CentOS Linux box for the past 4 hours. I have to hand it to Microsoft and Windows application developers, at least when they need a dependency they either include it or provide a direct link to it (well most of the time). My limited experience with Linux makes me the perfect candidate for RTFM, however who needs a manual??? Ok well I do, but it doesn't help - provide examples that anyone can understand, not just Linux guru's!</rant>

<rant>Rant #2 - BestBuy you kinda suck. I went to BB yesterday (Saturday) to pick up an ATI TVWonder 650 card for like $130. I got it with no probs, then the next day I look at the circular and what do I see - the card for $99! However, I had a bad feeling last night so I never opened the box. I was reading some posts about people having Windows/Linux driver problems and various problems all around so I elected not to open it and go with my original plan - the Hauppauge WinTV-PVR-150. Normally it retails for about $100, however CompUSA had a special this week (Dec 10, 2006) for $40 after rebate!!! Joy! I picked one up and returned the ATI and I'm super (thanks for asking). BB, you should have had some means of telling me that the product would be on sale the next day (hmm if only BB had a computer, or a room full of Monkeys to input the sales for the next week and then compare items when purchased...) - Boooo</rant>

Ok now that that is out of the way lets dig into what happened these past for hours. First off I have to give EXTREME thanks to a guy called Jarod C. Wilson. He wrote this great tutorial on how to set up MythTV on Fedora.

While it got me about 70% of the way there, there was another person - 22Eleven who created a tutorial for the CentOS specifics

Ok a tutorial can only take you so far with Linux. In a perfect world (not that I'm calling Windows the perfect world) you could just run the installer and boom it would be done. Well when I installed CentOS, I chose some extended options like GIMP so I could potentially do some photo editing. Well MythTV installer wants nothing to do with GIMP or any other photo type programs. So during my installation of MythTV as per:
> yum -y install mythtv-suite

I received many errors like the following:
Missing Dependency: libstdc++.so.6(GLIBCXX_3.4.6)
Missing Dependency: perl(File::Slurp) is needed by package perl-XMLTV

Well I'm not a Linux master, but wouldn't you think that you could just install libstdc++ with a yum command? NOPE forgetaboutit! So then I had to uninstall them with commands like:
> yum erase gimp

After uninstalling anything that was in the "is needed by" list, I tried again - no good, other probs still. I ended up going into 22Eleven's tutorial again and looking at the YUM configuration again. I noticed that I had mixed some of the YUM configs from Jarod's and 22Eleven's. I wiped out the unnecessary configs and tried again - no luck. Then I went in and enabled the "atrpms-testing" and tried again. This time still no luck. Ok I was about to throw in the towel and then with dumb luck I tried installing it with the following command:
> yum -y install mythtv

Notice no "-suite" on the end. Well to my suprise it worked!!! It installed with no errors (at this time it is about 1am). Well now I'm on a roll so I figured what the heck - lets try for the home run and I ran the yum command with the -suite and it too worked properly with no errors!!! My assumption is that by installing MythTV standalone first it fixed some dependency issues.

Well now this is freaking sweet so I just followed along "10. Get and install capture card driver(s)" within Jarod's tutorial and I didn't hit any hiccups since. I was able to query my card and the picture looked like crap, but I had faith that it was just using some baseline driver for looking for video. After the tv tuner card was set up, I walked through setting up MySQL with no problems either. Then came the setup for MythTV. That too had no problems. It brought me into a wizard which walked me through its initial setup. My only problem was that my mouse had no cursor in their setup wizard so I had to either use the keyboard or eyeball when the mouse was over a field by looking for the box to lightup.

I realized the first time through the setup that I didn't have the channel guide. Upon RTFM'ing I realized I had to create a Zap2It account in order to retrieve the channel listings. After creating it with no problems, it reminds you that you have 3 months of free usage, then you have to come back to the site and take a survey before it will let you use it again. A small price to pay for something free like this.

Finally I made it through the setup and finalized the download/processing of the channel guide (which btw took about 10 minutes to grab 2 weeks worth of channel data). Now comes the juicy part - using the program! I ran:
> mythbackend

to start the service - then I ran:
> mythfrontend

to run the actual application. I immediately went in and tried the tv and........... IT WORKED!! The quality was a little off, but that could have been because of a number of reasons:

  • Old cabling

  • Old cable splitter

  • Bad signal coming in (not likely since the tv looks fine

  • Computer is too slow - could be since it is only a 700mhz, 512mb ram, 16mb Voodoo 3 3000 vid card

  • Computers don't like me


Well I would love to stay up and tinker some more, but I have to get some sleep before work starts in a few hours. Tuesday or Wednesday I'll get more time to tinker again.

Wednesday, November 29, 2006

What did we learn today kinder - Flex!

Well here we go again - nothing like midnightish programming. Today in webdev, we watched an Adobe Flex presentation on Flex Data Services. It had some really promising ideas (webcasts/chat rooms/games potentially). I had not had a chance to dive into Flex development yet so I thought this would be a good opportunity to kill two birds with one stone - learning Flex and integrating Flex with its Data Services.

As with any new language that you learn you have to start with the equivalent "Hello World" app which I did. It simply consisted of:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
   <mx:Panel title="My Application" width="200" height="300">
      <mx:Label text="Welcome to Flex!" mouseDownEffect="WipeRight" />
   </mx:Panel>
</mx:Application>

After saving and running the app within the bundled Flex Builder Application it worked! Ok this is super (thanks for asking)! Well I'm in a groove now so I then moved on to "How to pull in an RSS feed with Flex" I followed along with the handy dandy tutorial that came with Flex Builder and it worked perfectly (Good job Macrobe).

Well this looks like a double win for me, time to do some real testing - Data Services. First off I installed the Flex Data Services with the embedded JRUN J2EE server installed (I have ColdFusion MX, but for simplicity I chose to do it with the embedded version. So far so good. I installed it and ran the "Start Integrated Flex Server" icon; allowed it access within ZoneAlarm; hit the web page: http://127.0.0.1:8700/ and viola!! a web page shows up. I tinkered with the sample apps and they are very interesting. In general this gives me a NetMeeting-esque feeling. NM was desinged for sharing a whiteboard, computer space etc with multiple users. This was back in the 90s and now we are accomplishing this with Flash. Java had stuff like this back in the 90s as well with RMI.

[inserting wild tangent here]
My first experience with RMI was with a guy named Harry Baya. Back then in the Computer Center of Hofstra University we held a web page contest every year showcasing new technologies. At the time flash was in version 4 so you can imagine all of the timeline based movies :-) Harry decided to work on a game in Java using RMI (Remote Method Invocation). His game was almost like a Monopoly type board game where different users would control different pawns. Unfortunately the game never really panned out, but he did get the RMI stuff working and multiple users could connect with a java applet to his central server and move pieces around. It was really mind blowing at the time. After that Shockwave came out with their version of an xml socket server which is still used today with many multiplayer games. And now back to the topic at hand - Flex Data Services
[/inserting wild tangent here]

So far so good, I can run the sample applications, but can I build my own? To quote Bob the Builder, "Yes We Can!" (well I only found that out after about a half hour of trying). So here we go:

First off, it helps to RTFM. I started with: Macrobe's Note's example. It seemed like a good place to start.

Here's a little Flex Builder info that I ran into - When you configure your project to use Data Services, it asks you for the WEB-INF/flex root folder. If you are working on the samples web app, you would specify the web root of:
C:\fds2\jrun4\servers\default\samples

And a url of:
http://localhost:8700/samples

Oh one more thing - by default JRUN runs off of port 8700 with this version. Now keep in mind that Flex Builder will create a folder with the project name that you choose. So in the documentation if you want to put this into the "DSLessons" folder as per the instructions, make your project name that.

I went through page by page looking at the code and copying it into my Flex Builder. I built an application called "lesson1" as per the instructions in Flex Builder (if I truly followed the instructions I would have used DSLessons, but you know I'm a bad ass). After that the directions said to add the "destination id" to the data-management-config.xml and had no problems in the sample area (especially since it was already there for me!). After putting all the code into Flex Builder and compiling and opening two browsers, Viola, it worked! Here is my sample code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" creationComplete="initApp();">
   <mx:Script>
   <![CDATA[
   /* IMPORT STATEMENTS */
      import mx.data.DataService;
      import mx.data.events.*;
      import mx.rpc.AsyncToken;
      import mx.rpc.events.*;
      import mx.messaging.events.*;
      import mx.utils.ObjectProxy;
      /* GLOBAL VARS */
      public var noteObj:Object = new Object();
      public var getToken:AsyncToken;
      private var ds:DataService;
      [Bindable]
      public var noteProxy:ObjectProxy;
      
      public function initApp():void {
         ds = new DataService("notes");
         ds.addEventListener(ResultEvent.RESULT, resultHandler);
         ds.autoCommit = false;
         noteObj.noteId = 1;
         noteObj.noteText = "Type your notes here and share them with other clients!";
         getToken = ds.getItem(noteObj, noteObj);
      }
      
      public function resultHandler(event:ResultEvent):void {
         if (event.token == getToken)
            noteProxy = ObjectProxy(event.result);
      }
      
   ]]>
   </mx:Script>
   <mx:Binding source="log.text" destination="noteProxy.noteText"/>
   <mx:TextArea id="log" width="549" height="216" text="{noteProxy.noteText}" x="27" y="24"/>
   <mx:Button x="269" y="265" label="Button" click="ds.commit();"/>   
</mx:Application>


UPDATE 1/6/2007!
Click here for the project files - including mxml

Tuesday, November 21, 2006

Java CFX and Jar Hell

While this topic may not come up all that often, it came up recently for me. I started to play around with building Java CFX tags for ColdFusion to add in some functionality. While I could have just invoked the java code within CF, I chose to try learning how to build a CFX tag. So first off I went with the absolute basic - the Hello World Application:
import com.allaire.cfx.*;
public class HelloWorld implements CustomTag
{
   public void processRequest(Request request, Response response) throws Exception
   {
      response.write("Hello World");
   }
}

Now comes the compiling part. This was a little tricky, but the only key to this is knowing that you have to include the classpath to your cfx.jar file in order for it to compile properly. The following example assumes javac is in your path and you are in the same directory as HelloWorld.java:
javac HelloWorld.java -classpath "C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib\cfx.jar"

Once that compiles properly put it in the "C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\ classes" folder.

Now register it within the CF Administrator by going to the Extensions -> CFX left navigation and choose "Register Java CFX". Then make the tag name CFX_HelloWorld and make the Class name "HelloWorld" (sans quotes and Case Sensitive based on the name of your class file you just compiled)

To call this on a .cfm page use:
<cfx_HelloWorld/>

(not case sensitive). That's it!!! However I started to think - hmmm applications can have more than one class file, so normally I would just jar the files. Simple enough in theory. HOWEVER, after spending several hours trying to get a JAR to work by putting it in various areas (classes folder etc and even adding it to the JRun classpath) I had to resort to asking for Macrobe (it's hard to get away from Macromedia and calling them Adobe) help through their support line. They were very helpful and in one simple e-mail they said that all you have to do to get a jar to work is put the jar in "C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib" and restart the server. Registration within the cfadmin is the same for the class. For my simple example I took the same HelloWorld class file and jar'd it. Then I named the jar the same as the class file and put it in the lib folder. After a restart, it worked! Whew - I wish I knew that many hours ago. Just for a little background - I was using CFMX 7.0.2 with JRun 4 with the JDK 1.4.2_12 (the version of the Java SDK should match the JVM version of your ColdFusion Server)

Hopefully my little walk around the park will help someone else out since Google didn't seem to help this time. Good Luck!

Wednesday, November 15, 2006

Traffic Rant and Introducing kHTTP!

Well it has been a few days since I last posted and I first want to start off with a little non technical rant about NY/NJ roadways. PEOPLE NEED TO LEARN HOW TO DRIVE IN THE RAIN!!!

Ok enough said about that, on to bigger and better things!!! A while ago I was learning some VB using Visual Studio .NET (btw an excellent IDE imo - one of my favorite features is the tag insight which includes your own custom functions). I wanted to learn more about how to develop a command line application for doing HTTP calls. This originally came about because of my work at Hofstra University. We use this job scheduling software called AppWorx which unfortunately can't make a simple HTTP request, but can execute any other program under the sun. Well I figured - how hard could this be to write a command line program that will make a request to get a page. Turns out it wasn't that bad in VB. Click the link below to download my program khttp.exe (win only). Type khttp.exe -help for usage. This little program will return information like the headers/page content/date modified etc. For a quick demo try:

khttp.exe -a "http://www.google.com"


Let me know what you think, and if you do happen to like it or use it somewhere drop me a message I would be very interested in hearing how it is used.

Click here to download khttp.zip

(the usual rules about downloading strange applications applies - always check for viruses - if this blows up your machine it is not my fault - blah blah).

Tuesday, November 07, 2006

And here we are!

Well long after blogging has started I have been coerced into starting a blog too. Brian has built quite the following with his blog: WebDev Central, and who am I not to jump in and let my $.02 be heard too! I hope to discuss varying topics from programming, to anything that is really cool that we found on the internet.

As my first order of geekdom, I highly recommend the Daily Buzz from CNET. This is a podcast of 3 CNET editors who discuss up to date topics that affect current technology. Their shows of indefinite length generally run about 25 minutes.

As my second order of geekdom, I want to talk about something new from Microsoft - Live Maps (maps.live.com). This is Microsoft's version of Google maps and I have to say that while they put their best foot forward they fell a little short. Google maps is very streamlined and works well in modern browsers.

I tried Live in Firefox 2.0 and it functions, but you lose out on 'cool' functionality. What is cool you may ask - well if you use IE 6+ and download their ActiveX image enhancer, you can now look at a few select cities in a new way - from a horizon view to a complete top down AND it is 3d meaning the actual buildings have height to them. At first I thought this was great eye candy and would eventually save the world, but then the geek in me started to realize that this must have been a massive undertaking to get all of the buildings in 3d like that for the entire city. I quickly got bored of this candy and then I decided to see what happens when you look around.

First I checked out the Hofstra University area and for some reason that area was in greyscale in this view. If I try it in 2d version with the topigraphical turned on, it looks ok, but in the super 3d it looks like crap. Ok well it is basically a beta and it is Microsoft so I chalked it up to business as usual. So then I went looking around Las Vegas. The buildings are really cool, but what did I see off to the distance in the northwest quadrant, but a freaking car advertisement!!! No one would have ever believed me if I hadn't taken a screen shot. Well lucky you, you get to see it too. All I have to say to Microsoft is:

LAME