Skip to content

uselog demo with jquery

With a focus on interactive video search for a thesis topic, having a dynamic environment is critical.  Within my lab and in my own research, a web-based environment has been the platform of choice.  This way we don’t have to worry about specific operating systems, compiling with the right set of binaries, and dealing with a lot of graphic primitives.  With that said, within browsers, a new set of AJAX libraries has become popular.  Interested parties should look elsewhere for comparisons, but my library of choice is jQuery. This was chosen kit because it’s pretty easy to understand, fairly lightweight, has spectacular documentation and has an ever-growing plugin base.  One example of that diverse plugin-space is the graph example on this page.

Live Example

Utilizing features from modern browsers, like the ‘canvas’ tag, a plugin called flot was developed for plotting basic graphs.  In only a few hours, this demo was cobbled together to plot some of the uptime and usage data being captured for my shared host.  This simple page allows the plotting of memory resources, processor load, and active users.

Bad Browser?

It worked for me on IE7, Safari, and Firefox. Perhaps you can do something with the excanvas library or just pop open a better browser.

Live Demo

Interactive Uptime Demonstration (2 days of activity, time is PST [GMT-8], highlights between 12-6 am, samples every 3 minutes)
-
Module not active. Please make sure that javascript is enabled in your browser!
Module not active. Please make sure that javascript is enabled in your browser!

Technical Mechanics

  • flot – the jQuery plugin whose functionality is shown here; thanks to the author for the numerous examples which are actually a far better illustration of the library than the documented API
  • mysql – store/query the results from the unix commands ‘uptime’
  • php – server-side processing of query range and query type
    • JSON from pear – basic formatting for jQuery returned results

NJ Transit Mobile Scheduler

Not everyone has the funds or interest in browsing the somewhat slower internet connections you experience on on cell phones, so there are quite a few mobile-texting applications that have sprung up. Of course, this implies that you can send a quick SMS message from your phone, but in my opinion this action is much less tedious and distracting than a full browser open, navigate, select, view operation. Here are some of my favorites: directions on google, google 411, directions on sms hopstop or voice hopstop, weather and flight information on google, and flight alerts on flightalerts.com.

Background

I don’t use it that frequently, and there is an 800 number to call, but I thought it would be an interesting exercise to create a mobile texting system that retrieves the nearest schedule for train travel on NJ Transit. Thanks to the users/admins at dreamhost.com for their useful procmail tutorials.

Usage

To use my mobile scheduler just send a text message or email message to this email address…

The basic syntax is to type the first few letters of the origin and destination of your travel and optionally provide the hour that you want to start your journey.  Incorporated is a little bit of logic like rolling over the departure time to the next day and determining am/pm for the hour. Below are a few examples of queries and what you might get as a reply.  While it’s intended for a text messaging system (or with your favorite email client), a live web demo is available below.  Check out the NJ Transit rail map to get the names of some destinations and try it out. To minimize delay and server load, some things are cached here on my server, so it’s possible that over time there will be some synchronization errors for station names.

Examples

Example 1: Example 2: Example 3:
“convent to long branch” “newark to middletown @ 6am” “newa1 to midd1 @ 6am”
demonstrates basic query operation and simple form of return including all transfers and the total price at current time of query demonstrate look-up on a partial hit; both terms ‘newark’ and ‘middletown’ have partial hits on multiple stations so the system asks for a resolution resolved look-up for a partial hit; the system first matches against the short form and then the full length name and notes the 6am morning train
Result 1:
[1] 5:31 P.M. @ CONVENT(On NEW YORK PENN STATION)
to 6:26 P.M. @ FRANK R LAUTENBERG SECAUCUS UPPER LEVEL
[2] 7:16 P.M. @ FRANK R LAUTENBERG SECAUCUS UPPER LEVEL(On LONG BRANCH)
to 8:38 P.M. @ LONG BRANCH
Fare:$12.00 ($5.50)

Result 2:
Please enter a shortcut or full name from below. Sorry, ‘newark’ is confusing.
[ ] NEWA1 or Newark Airport (Northeast Corridor)
[ ] NEWA2 or Newark Broad Street (Montclair-Boonton Line)
[ ] NEWA3 or Newark Penn Station (Northeast Corridor)
Sorry, ‘middletown’ is confusing.
[ ] MIDD2 or Middletown New York (Main and Bergen County Line)
[ ] MIDD1 or Middletown New Jersey (New Jersey Coast Line)

Result 3:
[1] 6:03 A.M. @ NEWARK AIRPORT RAILROAD STATION(On LONG BRANCH)
to 6:53 A.M. @ MIDDLETOWN NJ
Fare: $13.75 ($9.25)

Live Demo

Returned text message.

No query entered yet. Try something like “New York to Long Branch @ 5pm”. You can look for other stations on the NJ Transit rail map.

Technical Mechanics

  • procmail – back end to receive email for a certain address and have a script run on receipt of that email
  • mysql – cache the names of different train stations and their abbreviations
    • cache the results after each query for the specific time, start, and end destinations

  • php – server-side processing of messages and database interaction

    • curl – fetch pages from external websites; first done during the caching process to retrieve all names then for queries by users
    • smtp, mime, JSON from pear – secure mail delivery in valid mime format to standard mail clients

Special Notes

  • Mail headers – some of the phone companies have very specific header requirements; specifically, there is a particular form the ‘from’ address (i.e. “Bob McClusky <bob@doesnotexist.com>”)
  • Body encoding – you’ll need to encode your message with ‘base64′ and not ’7bit’ or ’8bit’ to avoid some strange problems regarding unwanted newline characters
  • Max length – don’t forget that older phones/systems may truncate your message at 160 characters!

adding a cablebox to mythtv

I have a working DVR, who cares…

Referred to as the ‘digital crush’, analog broadcasts will supposedly end in the US on February 17, 2009.  Few people I know are using over the air (i.e. no cable) set-ups, but for those who are, you can get two coupons for $40 each towards an over-the-air receiver for older TVs — of course, even this step isn’t needed if you bought your TV after May 2007, but that may not cover everybody.

Why you need an STB

Now, to the point of this post is that if you’re using a homebrew DVR (like MythTv), you’ll now need to have your DVR send signals to a cable box or a DTV converter box (often referred to as STB — set top boxes) because the number of DTV receivers in the US is quite low and even lower if linux suport is required.  Even worse, is that if you do have cable, it’s doubtful that these TV cards would be able to decrypt the television signal being sent to you from your provider.  Of course you can still get a card, but there’s legal ambiguity stating you may only be able to watch channels you got for free already (like the major broadcasters, not Comedy Central, AMC, etc).  Finally, there are a lot of arguments on the web about the utility/availability of cablecard support for linux a system that was supposed to solve this problem, but it seems that copyright and distribution concerns and the financial interests of television service providers  have stifled progress in this direction.

Common resources

So, if you’re like me, you will bite the bullet sometime and switch over your DVR system.  I am collecting a few useful links and notes about the process, but most of the heavy lifting (for howtos) has been by others. Here’s my hardware configuration…

  • Card: Hauppauge TV 150 which spits out a nice MPEG stream and works very well with MythTv.  It also has an IR receiver (so I can use a remote) and an IR blaster (so I can control a STB).
  • Linux kernel: 2.6.18-4-k7
  • Linux distro: Debain with unstable/testing circa October 2008
  • Kernel-based lirc driver for i2c: 0.8.3-CVS-pvr150-2;
  • Cable provider: RCN New York
  • STB model: Motorola DCT700 with this remote info
    • STB control code set: ’82′ – you’ll have to choose the right set when you get your blaster to work, for me it was set ’82′ out of the avaialble …. 106, 80, 81, 82, 84 for my STB model

Easily findable with your favorite search engine, here are a list of links that were of the highest utility.

Following the steps in the first howto should solve almost all of your problems.  As I was going along, here are a few deviations that I noted…

  • /lib/firmware – be sure to put your firmware files in this directory, not /usr/lib/firmware or the like
  • /etc/lirc/lircd.conf NOT /etc/lircd.conf – for some reason, I had two copies of the lircd configuration files; the first was the correct location and the second I replaced with a symbolic link; inspecting the contents, it looks like it just came out of an older debian package.
  • Match your lirc versions!  Don’t be tempted to go with newer/possibly more stable versions unless you’re upgrading your entire system.  I had to rev back to match my lirc version, but it worked great after that.
  • For my STB model, control set ’82′ worked correctly.
  • To make sure it works on a reboot, I’d suggest adding a modprobe/load module line to your /etc/modules file.  I already had a few in there, but just adding ‘lirc_pvr150′ seemed to do the trick.
  • You must reboot (sorry uptime fans) after putting the correct kernel driver in place…  There may be a graceful way to use lsmod/rmmod/modprobe to handle your kernel drivers, but this is much easier and you can verify that it works after a reboot.

What to look for in your /var/log/messages to know things are running correctly.

The first section verifies that the kernel driver was loaded,

Nov 27 22:18:53 localhost kernel: tveeprom 0-0050: has no radio, has IR remote
Nov 27 22:18:53 localhost kernel: ivtv0: Autodetected Hauppauge WinTV PVR-150
Nov 27 22:18:53 localhost kernel: ivtv0: reopen i2c bus for IR-blaster support
...

the second verifies the irblaster was detected and the firmware was loaded,

Nov 27 22:18:53 localhost kernel: lirc_pvr150: no version for "lirc_unregister_p
lugin" found: kernel tainted.
Nov 27 22:18:53 localhost kernel: lirc_pvr150: chip found with RX and TX
Nov 27 22:18:53 localhost kernel: lirc_dev: lirc_register_plugin: sample_rate: 0
Nov 27 22:18:53 localhost kernel: lirc_pvr150: firmware of size 302355 loaded
Nov 27 22:18:53 localhost kernel: lirc_pvr150: 743 codesets loaded
Nov 27 22:18:53 localhost kernel: lirc_pvr150: Hauppauge PVR-150 IR blaster: firmware version 1.3.0
...

and the third is what you’d see when you test our a channel change (blaster) or ‘irw’ run (remote receiver).

Nov 27 22:44:11 localhost lircd-0.8.3[5343]: lircd(userspace) ready
Nov 27 22:44:11 localhost lircd-0.8.3[5343]: accepted new client on /dev/lircd
Nov 27 22:44:22 localhost lircd-0.8.3[5343]: accepted new client on /dev/lircd
Nov 27 22:44:23 localhost lircd-0.8.3[5343]: removed client

All done

  1. hope it worked for you as it did for me.  If so, probably the last thing you need to do is update your channel table on scheuldesdirect for your new lineup.  Enjoy the preservation of your DVR and please send an update if you have it working for HD feeds or a direct linux card that can work with out an STB.

One ring to guide them all

Alas, it appears that my Order of the Engineer ring has joined the metropolitan abyss that is New York.  Although I haven’t spend enough time on the topic, it looks like getting a replacement would require some effort.  So, let me digress into the snippets of history around the ring. In my interpretation, it was constructed to represent ethical responsibility and duty to those individuals served by your engineering creation.  While this may not have been as directly apparent from my work (mostly involving computational models and static images), there is still a sense of responsibility to eliminate spurious and misleading results  as much as possible — which may be more relevant when discussing an academic work.

  1. will check back in with my alumni organization when in Austin in the future, but for now I’ll just have to have a less physical reminder of these obligations and its significance.

For those not in the know, here’s a few pages that describe that the ring was in more detail.

Finally, I know not everyone has time to traverse the depths of the web, so posted as testimony is the credo lifted from a the order’s website.

I am an Engineer, in my profession I take deep pride. To it I owe solemn obligations. Since the Stone Age, human progress has been spurred by the engineering genius. Engineers have made usable Nature’s vast resources of material and energy for Humanity’s benefit. Engineers have vitalized and turned to practical use the principles of science and the means of technology. Were it not for this heritage of accumulated experience, my efforts would be feeble.
As an Engineer, I pledge to practice integrity and fair dealing, tolerance and respect, and to uphold devotion to the standards and the dignity of my profession, conscious always that my skill carries with it the obligation to serve humanity by making the best use of Earth’s precious wealth.
As an Engineer I shall participate in none but honest enterprises. When needed, my skill and knowledge shall be given without reservation for the public good. In the performance of duty and in fidelity to my profession, I shall give the utmost.

NY/NJ diving sites and information

Although it’s still quite a bit in the future (not even done with my open-water cert yet), I’m eagerly looking forward to some of the local NY/NJ dives available.  I don’t do well with collecting and tracking bookmarks effeciently, so I wanted to collect links for a few online sites (those with good GPS or shipwreck coverage) here.  Not having been on an official dive yet, I have no experience as to getting to these sites or what dive shops or dive clubs might have good transportation and discounts for these locations, so any interesting commentary is welcome!

I will do my best to refer back to this post and add/update sites as I find more.