Buy Your Own (Time Warner) Cable Modem

Internet 3 Comments

A few months ago, my sister complained that her Time Warner Cable Internet Broadband Plan’s monthly charge had increased by $4-5. I asked to see the bill and saw a $3.95 cable modem rental fee, which after checking with her, was a new addition. A quick google revealed that Time Warner Cable had started charging a rental fee for cable modems, which previously were free. (I guess the penny-pinchers finally got control of Time Warner.)

CiscoDPC2100_BackI don’t know why my sister complains about technical stuff like this to me. Oh, wait, it’s because I usually solve the issue for her. Anyhow, I decided to buy a cable modem for my sister so that she could avoid paying that rental fee. I ended up getting a used cable modem compatible with Time Warner for $20 from craigslist. The following contains some information which might be useful if you are also looking to buy a cable modem.

DOCSIS 2.0 vs 3.0

DOCSIS (Data Over Cable Service Interface Specification) is a term which you will encounter when shopping for cable modems. Simply, DOCSIS is a communication standard for cable modems which allow cable modems from different companies to work with an Internet broadband cable provider’s equipment. There are two versions of DOCSIS, 2.0 and 3.0, which are commonly supported by Internet cable providers. The main difference between DOCSIS 2.0 and 3.0 is the speed which they can handle.

If your Internet service speed is significantly less than 42Mbps downstream and 30Mbps upstream, you should be okay with DOCSIS 2.0 cable modem because those are the maximum throughputs for DOCSIS 2.0. If your Internet service is around that speed or higher, you should invest in a DOCSIS 3.0 cable modem.

Because my sister had the Time Warner Basic plan, which is rated for up to 3Mbps and actually tested at 20Mbps (please, don’t let the penny-pinchers at corporate find out), a DOCSIS 2.0 cable modem is more than adequate.

Time Warner’s Compatible Cable Modem Models

Originally, Time Warner recommended five expensive DOCSIS 3.0 cable modems on their Buy Your Personal Internet Modem page. Thankfully, the latest version of that page adds more models, including DOCSIS 2.0 modems, and breaks them into two groups tied to service plans; which are very helpful. Still, my sister’s rented cable modem is a Cisco DPC2100, which isn’t on the official list of recommended modems to buy.

After googling, I found Time Warner’s Lease Your Modem page which lists all the rented modems that Time Warner supported. This list contains three times the number of modems as the previous webpage. In the rented list, I found the Cisco DPC2100 which is a DOCSIS 2.0 modem.

The point is that if I buy a modem in this rented list, it must be acceptable to Time Warner because they rent the same out to their current customers. This is good because more options mean a greater supply which leads to lower prices when purchasing.

Shop for Cable Modems on Craigslist

When looking for cable modems on craigslist, it pays to do your research. I found that in the majority of instances, the cable modems on craigslist were overpriced. In some cases, new modems on craigslist (without the warranty) were sold at the same price or more than brand new modems that I found on Amazon and other reputable sites. Craigslist sellers were not reducing the price to account for the risk (lack of warranty, no returns, etc.) that buyers had. So if you are looking for a new cable modem, it pays to check stores (online and offline) in addition to craigslist.

If a used cable modem is acceptable, you will want to check craigslist for deals. (Also, if you don’t mind, look for online and offline deals concerning manufacturer-refurbished cable modems, which are almost as good as new and come with warranty.) As a general rule, I would target around $20 for a used DOCSIS 2.0 cable modem and around $40 for a used DOCSIS 3.0 cable modem. If you don’t have the fastest broadband plan, you don’t need to get an expensive cable modem with extra features that you won’t be able to take advantage of.

I ended up getting my sister a Scientific Atlanta DPC2100 version 2 cable modem for $20. This is basically a newer version of the Cisco DPC2100 (Cisco purchased Scientific Atlanta) that my sister was currently renting from Time Warner. At $20, it will take five months of not paying the $3.99 rental charge before we break even; after which, the saving begins. Because I paid for the cable modem, my sister enjoyed the savings immediately. (Again, this is why she complains to me about this stuff.)

Install Your New Cable Modem

Installing your newly-purchased cable modem is very simple. Here is Time Warner’s FAQ on what you need to do to install a purchased cable modem.

Basically, you will want to know your cable modem’s model (some service agents will ask for the model, others won’t) and the MAC address. Along with the model, the MAC address should be printed on a label on your cable modem. The MAC address will look like 00B0D086BBF7. Once you have these two tidbits of info, you can call Time Warner at 800-892-2253. The Time Warner agent will ask you to hook up the new cable modem (if you haven’t already done so) and update your service with the new MAC address. Within a minute or two of the agent activating your new modem, your Internet access should be re-established.

Don’t forget to return your rented cable modem to the nearest Time Warner store. Anyone can return it. The agent at the store won’t ask for anything (like account number) and will provide a receipt. Depending on where you are in your billing cycle, you may see that rental charge one more time before it goes away.

Save money on your Time Warner monthly bill by buying a used cable modem. It’s a breeze to setup.

Create WordPress Widget for the Yelp Bling

Internet 2 Comments

I was writing a Yelp review (log into Yelp and click the “About Me” tab) and noticed a small google map object on the Yelp page that showed the locations for my reviews one by one. At the bottom of that object was a link named “I want this bling on my blog”. So I clicked on it. It took me to a page where I could generate the HTML code for my very own Yelp Bling object. (I kept the default Javascript version and did not select the Flash version.)

To put the Yelp Bling on my blog, I decided that the cleanest way is to create a WordPress widget to contain all that bling. I inputted a border color (C33907), text color (000000) and background color (FFFFF) which matched my blog’s theme. To find the RGB (Red, Green, Blue) values from your theme, use the Windows Paint program per these instructions.

Follow these instructions to create your very own Yelp Bling widget:

  1. Create a text file named “yelpbling.php” with the following content:
    <?php
    /*
    Plugin Name: YelpBling
    Plugin URI: http://www.doitscared.com/
    Description: Yelp Bling widget
    Author: doitscared.com
    Version: 1
    Author URI: http://www.doitscared.com/
    */

     
    function yelpbling_widget() {
    ?>

    <!-- Paste generated Yelp Bling HTML code here -->

    <?php
    }
     
    function init_yelpbling() {
       register_sidebar_widget("YelpBling", "yelpbling_widget");    
    }
     
    add_action("plugins_loaded", "init_yelpbling");
    ?>
  2. Paste your Yelp generated HTML code into the file under the “Paste generated Yelp Bling HTML code here” comment.
  3. Copy the “yelpbling.php” file to your web server’s WordPress plugin directory, usually “wp-content/plugins”.
  4. Log into your website as an administrator and select the Plugins tab. You should see the YelpBling widget listed.
  5. Activate the YelpBling widget.
  6. Go to the Appearance->Widgets tab and drag the YelpBling widget from “Available Widgets” into the Sidebar.
  7. View your blog and you should now see the Yelp Bling object in the Sidebar.

You may need to adjust the CSS style directives in the generated HTML code to make the Yelp Bling object fit nicely in the Sidebar. For example, I deleted the <div> containing the “Recent reviews by …” headline link (to compensate, I adjusted the header height to 25px from 40px) and the <div> containing the “What’s this?” footer link.

In the end, I decided that the Yelp Bling object did not belong on my blog and removed it.

PHP Script to Convert Firefox’s “sessionstore.js” to HTML

Internet 1 Comment

Today, my Firefox browser decided to freeze on startup while loading the pre-existing tabs. After killing it and restarting several times, I realized that the only way to recover was to prevent Firefox from loading the tabs. I located Firefox’s “sessionstore.js” file and moved it (one could also rename it). I started Firefox and it came up fine.

To find the “sessionstore.js” file on Windows 7, open up a “Command Prompt” and type the following:

cd %APPDATA%\Mozilla\Firefox\Profiles
cd <random_alphanumeric>.default

The macro %APPDATA% will translate to “C:\Users\your_username\AppData\Roaming”.
Windows XP and Mac OS X will have the “sessionstore.js” file in a different location.

I had about 25 tabs opened in the previous session and I did not want to lose those tabs. The tab URLs were stored in the “sessionstore.js” file but the file was big (it contained the open tab URLs and historical URLs) and hard to parse (it was a single huge JSON text string).

I decided to write a PHP script to convert the JSON string into an HTML file with a list of all the URL as links. Below is the PHP script I wrote. Just run it using the command line PHP executable, provide the “sessionstore.js” file location as the input, and it will create a “sessionstore.js.html” file (in the current directory), which you can then open in a browser to see the list of links.

<?php
{
 // Make sure we have the correct number of args
 $args = $_SERVER['argv'];
 if (2 != $_SERVER['argc']) {
   echo "Format: $args[0] <filename>\n";
   exit(-1);
 }
 $filename = $args[1];

 // Read the input file into a json string
 $jsonStore = file_get_contents($filename) or die("Failed to open input file");

 // Convert the json string into an object
 $store = json_decode($jsonStore);

 // Create an output .html file
 $file = fopen("$filename.html", "w") or die("Failed to create output file");

 // Add HTML header
 fwrite($file, "<html><body><ul>\n");

 // Parse the session store object and generate HTML links for each tab.
 // Session stores have windows->tabs->entries array-of-arrays structure.
 $windows = $store->windows;
 foreach ($windows as $window) {
   $tabs = $window->tabs;
   foreach ($tabs as $tab) {
     $entries = $tab->entries;
     foreach ($entries as $entry) {
       fwrite($file, "<li><a href=\"$entry->url\">$entry->title</a>\n");
     }
   }
 }

 // Add HTML footer
 fwrite($file, "</ul></body></html>\n");

 // Close the output file
 fclose($file);
}

If you find that the “sessionstore.js” does not contain your open tabs, use the “sessionstore.bak” backup file instead. I hope that the script above may prove useful for you. Good luck with your Firefox blues.

Purchasing a Wireless Router for Real People

Internet No Comments

Recently, my trusty 2.4Ghz wireless G router (a Netgear WGR614) died after many years of service. I went looking for a new router and found that the information on which router to get was not clear or conclusively. The routers that people agreed were the best cost easily over $100. I wanted an inexpensive, reliable router with a strong signal, the same or better than my old router. In the end, I got a 2.4Ghz wireless N router for $25 (a new Cisco Linksys E1000 from craigslist) that matched my needs and actually provided a stronger wireless signal.

To help others avoid having to repeat my research, I will summarize my findings below. I will simplify things and that will mean leaving out some info; otherwise, this post will turn into a small book.

Un-intuitively, the first choice is whether you want 2.4Ghz or 5Ghz wireless signals, not Wireless G or Wireless N. Though Wireless G can operate only in 2.4Ghz, Wireless N can operate in both 2.4Ghz and 5Ghz, separately (dual-band router) or simultaneously (simultaneous dual-band router). It turns out that the 2.4Ghz wireless signal has greater range than the 5Ghz wireless signal. With a lower frequency, a 2.4Ghz wireless signal will actually penetrate better through walls. The 2.4Ghz wireless signal is like a sub-woofer in how its low frequency sounds penetrate the walls and floor. Comparatively, the 5Ghz wireless’s high-frequency signals might bounce off a wall, rather than penetrate.

Note: A non-simultaneous dual-band 2.4Ghz/5Ghz Wireless N router will switch to 2.4Ghz Wireless G mode if you have just one 2.4Ghz Wireless G client device connecting. You would then end up effectively with an expensive 2.4Ghz Wireless G router.

To compensate, 5Ghz Wireless N has methods to overcome such obstacles as walls. The most visible method is to use multiple antennas. Two or three antennas are common, though the newer routers have six or more. The antennas receive the 5Ghz wireless N signal and its many reflections (from bouncing off walls), which the router analyzes and combines into a strong signal. A second method is waveform shaping to increase the signal strength. This is similar to using a cone-shaped horn to amplify your voice. Unfortunately, like with the router, you have to know where the person you are shouting to is located so you can point the horn at him. A third method is to increase the signal spread from the standard 20Mhz to 40Mhz, similar to magically doubling the width of a clogged water pipe in order to get more water through. This would result in the router taking up double the frequency range and would only be viable if there is little or no congestion; if the pipe you are doubling the size of is right next to a bunch of other pipes, those other pipes will interfere with the size change.

Your environment will determine whether 2.4Ghz Wireless G/N or 5Ghz Wireless N has the most range. Currently, 2.4Ghz Wireless G/N congestion will increase the chances of interference and reduce the 2.4Ghz Wireless G/N range. Many household devices like wireless digital phones, microwaves, garage opener remotes, etc., might use the same 2.4Ghz signal. And neighbors left, right, front, and behind are getting wireless routers (almost all 2.4Ghz Wireless G/N routers because they are cheap and provided free by the Internet broadband providers). So, it might be best to go with 5Ghz Wireless N for now, until it too gets congested.

If you have a Windows machine, I suggest getting the free inSSIDer tool. It will scan the 2.4Ghz Wireless G/N and 5Ghz Wireless N (if your Windows machine has a 5Ghz wireless N capable adapter) ranges and show all the wireless routers nearby. This will give you an idea of congestion.

Your devices will determine whether you can use 5Ghz Wireless N. If all your devices support 5Ghz wireless N, I would say to go with a 5Ghz Wireless N router. If some of your devices are 2.4Ghz Wireless G, then you might choose a 2.4Ghz wireless G/N router or if you have spending cash, a simultaneous dual-band Wireless N router. Again, simultaneous dual-band means that the wireless router handles both 2.4Ghz Wireless G and 5Ghz Wireless N traffic in parallel and at the same time. It is like having two routers, a 2.4Ghz Wireless G and a 5Ghz Wireless N router, in one. A non-simultaneous dual-band Wireless N router can operate either as a 2.4Ghz Wireless G/N or as a 5Ghz Wireless N router.

Note: I tested inSSIDer with a simultaneous dual-band Wireless N router (at work) which outputted both 2.4Ghz Wireless G and 5Ghz Wireless N signals; inSSIDer showed that the 5Ghz Wireless N signal was about 20% weaker than the 2.4Ghz Wireless G signal.

I have found that the SmallNetBuilder website provides the best review of wireless routers. If you don’t mind spending the money, the best router to get is the Cisco Linksys E4200 Wireless N router for about $180 retail. After that is the Netgear WNDR4000 N750 Wireless N router for $170 retail. Both are simultaneous dual-band routers.

I decided to get a 2.4Ghz Wireless N router because my old 2.4Ghz Wireless G router worked fine (without congestion issues), none of my devices were 5Ghz Wireless N capable, and I didn’t want to spend more than $50. In the end, buying a wireless router is like playing Russian roulette. I went on craigslist and searched for name brand wireless routers like Linksys, Netgear, and D-Link. I found a sweet deal, a brand new Cisco Linksys E1000 2.4Ghz Wireless N router for $25 (50% off retail price), and managed to purchase it. (The Linksys E1000 supports Wireless N on the 2.4Ghz frequency so I consider it essentially a Wireless G router.)

Setup was a breeze. I plugged the Linksys E1000 into the wall outlet, connected my laptop by Ethernet cable to it, browsed to the E1000′s default gateway address, logged in (had to google for the default user/password which was blank user and “admin” password), and manually configured it. (I did not run the software on the included CD.) I setup up the same WPA-Personal security as my old router’s configuration. I manually forced Wireless G only mode (since any one of my Wireless G device connecting would force this), selected 20Mhz range (since WPA-Personal and Wireless G mode would force this), and channel 11 (it worked well in the old router and inSSIDer showed it was the best option).

After I finished configuring the router, I was pleasantly surprised to find that the 2.4Ghz Wireless G signal was significantly stronger than my old router’s signal. Machines at the back of the house that showed low connectivity before were now saying good connectivity. The inSSIDer tool on my desktop (about 15 feet and two walls from the router) showed an increase from -50db to -40db in signal strength.

Finally, a cautionary tale on wireless repeaters which are devices used to extend the wireless range. It is like shouting to a friend, who then repeats the message to a second friend further away. A few years ago, I tried to use a Linksys WRE54G wireless G extender with my Netgear WGR614 wireless G router. It worked and boosted the wireless signal, but after a few minutes, my Netgear router went dead and needed to be rebooted. This consistently happened and I could only conclude that the Netgear router and Linksys extender did not like each other. Probably, compatibility is a lot better now. However, if you decide to get an extender, I would recommend getting the same brand as the router’s or getting something you can easily return. This gives me a thought… The Linksys WRE54G extender could get rid of my neighborhood wireless congestion if I were to use it to “helpfully” extend (aka “kill”) the neighbors’ routers. But that would be too evil.

Good luck with your wireless router purchase.

Post a Movie File On Your Website

Internet No Comments

If you have ever wanted to post a movie on your website (instead of using Youtube and other similar services), the steps below might help you get started. I will provide instructions for converting a movie AVI file from my digital camera into a Flash Video (FLV) file for posting on a web page.

My camera, a Canon SD870 IS, produces video files in AVI (Audio Video Interleaved) format. The videos are 640×480 at 30 frames per second (at about 18mbps bitrate) and mono audio at 44kHz sample rate (at 705kbps bitrate). The bitrate and audio bitrates, in combination with the other attributes, determine the video and audio quality. For example, at a higher bitrate, a video frame will look much sharper with less artifacts. Also, the video and audio bitrates together determine how much bandwidth you would use to play the movie when streaming it. Knowing this info will come in useful when we do the movie conversion below.

The goal is to convert the AVI movie file into a FLV movie file which is much smaller and supports streaming playback (which allows the user to view the movie as it downloads). As an example, I have an AVI file which is 17 seconds long and 30MB in size. I will want to convert that down to a 2-4MB FLV file size (1/10 the original size) with a 1-1.5mbps video bitrate and at most 96kbps audio bitrate. These bitrates should be easily handled by users who are using DSL or cable Internet broadband services. To maintain video quality, I will also switch the video to be 15 frames per second while keeping the same 640×480 resolution.

There are two free utilities that you will need to download and install:

  • MediaInfo supplies technical information (resolution, frame rate, bitrate, sample rate, etc.) about a video and/or audio file.
  • Free FLV Converter to convert from AVI (and others) to FLV format.
    Note: When installing, select “Custom Installation” and unselect the two Searchqu install options!

First, run MediaInfo and open the original movie file. Take note of the video bitrate, video resolution, video frames per second (fps), audio bitrate, audio sample rate, and number of channels (mono 1 vs stereo 2). When you set the target FLV attributes, you will want to pick values which are equal to or less than the original values. You can keep MediaInfo opened to refer to.

Second, run “Free FLV Converter” and click on the “Conversion to FLV” button at the top middle. Browse to and select the original movie file; AVI file in my case. Unfortunately, the “Free FLV Converter” does not use the original file’s video/audio attributes. Instead, in the “Output configuration”, I had to make the following changes:

  • Change Video Size from 320×240 to 640×480.
  • Change Video Bitrate from 386 to 1500. (I tried keeping it at 386 and the resulting FLV movie was extremely pixelated. Even at 800, it was still too pixelated for my taste.)
  • Change Frame rate from 25 to 15.

I left the Audio settings of Frequency (aka sample rate) at 44100 and Bitrate at 96 Kbps. Hit the Convert button to convert to FLV format.

The “Free FLV Converter” utility will save the converted FLV movie file (with the same name as the original file but a .flv extension) to the desktop. The resulting file size is 3.5MB. If the file had been bigger, I would need to reduce the FLV target settings further. In addition, the utility will nicely generate an example HTML file (with same name as the video file), a FLVPlayer.swf (a Shockwave Flash movie player), and a Skin.swf (skin for the Flash movie player) file. Open the HTML file in a browser to play the FLV movie. Hopefully, the quality of the generated movie is good.

You can use the generated HTML file as-is or as a reference. To use as-is, just copy the generated FLV movie file, the HTML file, the FLVPlayer.swf, and the Skin.swf to your website. You will want to upload the four files into the same online directory. To use as a reference, copy-paste the <object> definition from the generated HTML to your own HTML page. You will still need to copy the FLVPlayer.swf and Skin.swf files to your website.

Note: If you use another FLV conversion software and notice that the download progress bar on the movie player (dark grey background) doesn’t advance, then it may be that the software did not add the appropriate meta data to the FLV file. In this case, you can use flvmdi.exe tool to add the missing metadata.

The settings used above worked for me. You may wish to adjust for your needs accordingly. Have fun!

One Router to Rule Them All

Internet No Comments

I recently bought an iMac for my sister. While setting it up, the Software Update would keep aborting due to network disconnects. While testing, I noticed my wireless G connection would start off fast, then drastically slow down, then pause for a minute, disconnect/reconnect, and finally just unable to connect. If I reboot, the behavior repeats. Strangely, my Macbook Pro and a Windows 7 desktop sitting nearby had no issues.

After hours of googling and trying out different suggestions, I came to the realization that the Apple wireless function is just very fickle. Wireless issues were attributed to the wireless hardware card, the firmware on the card, the Mac OS X version, the wireless driver, the Airport software version, the distance to the router, the type and model of the router, the type of connection (A, B, G or N), wireless channel used (1 thru 11), the encryption (no security, WEP, WPA, WPA2), and interference from Apple’s own bluetooth mouse/keyboard (if you use channel 6), wireless phones, walls, aquarium pump, neighbor’s routers, the metal kettle sitting on the stove, etc.

If you’re lucky and your Apple computer doesn’t have any issues with wireless, count your stars and if you are not, just pray that Apple will come out with a software fix soon. Or you can buy a wireless USB adapter (many have solved their wireless issues using this solution), but something sticking out of the back of the iMac defeats the reason to get an iMac (design cleanliness).

CNet’s MacFixIt Tutorial: Fixing Wireless connectivity is one of the better references I found. In addition to the tutorial suggestions, if you have an older router like a Wireless G router, I recommend disabling the IPv6 support as this might cause problems for your router and wireless connection. To disable IPv6 support, go to System Preferences->Network->Airport, click on the “Advanced…” button on the bottom right, select TCP/IP tab, change “Configure IPv6″ to Off.

As a final test, I deployed a Wireless N router twice the distance away as my Wireless G router. The iMac connected to the Wireless N router and my wireless became 95% stable. There were still occasional drops but I could now watch Youtube videos at 360p. Strangely, I ran some wireless monitoring software (recommendations below) and the Wireless N signal was twice as bad as the Wireless G signal. Oh well, looks like this iMac puppy prefers Wireless N. Go figure.

During my investigation, I found some very cool and free (my second favorite word; my first is when you pay me) wireless monitoring software. Here are my recommendations:

  • If you are using Windows, get inSSIDer (better than NetStumbler!). I love inSSIDer’s graphical display that shows both signal strength and channel coverage (see below). You can see where the conflicts are and where the gaps are… so you can move your router channel there, assuming you’re lucky enough to have gaps.
  • If you are using Mac OS X, get iStumbler (NetStumbler for Mac?). It’s not as cool as inSSIDer, but it’s better than nothing.

Below is the inSSIDer graph for Wireless G from my Windows 7 desktop. My Wireless G router is in red and my temporary Wireless N router (supporting both G and N) is in yellow. I overwrote my SSIDs to protect my privacy while leaving the neighbors’ SSIDs visible (Muhuhaha… that’s evil laughter for the reading impaired). There is about 5-6 other wireless networks but they are so low power that they don’t show on the graph.

A month ago, it was just my nice neighbor, green 2WIRED732 (channel 8), and my Wireless G router (channel 11). Actually, my green neighbor is not too nice; he or she should be using channel 1 or 6, not 8. The recommendation is to keep 5 channels apart so in the 1-11 channel space, we should use 1, 6, and 11. Of course, this argument goes out the window when you have a lot of neighbors all over the channel spectrum.

Now, when I look at the graph, I see that my channel 11 space has been invaded by grey 2WIRE583… argh!!! And there is the evil blue belkin.3eb3 which is taking up both channels 3 and 7 (look at that wide channel coverage!). Between grey and evil blue, they have the whole 1 thru 11 channels covered! There is no gap.

That’s when an evil thought appear in my head. I need one router to rule over all other routers!

One Router to rule them all
One Router to find
One Router to bring me wireless
and in the congested emptyness to bind with!

I need the One Router that will cover the whole Wireless G and N channel spectrum (like my little friend, evil blue) and pump out 3-4 times the signal strength (need lotsa gigantic antenna and a backup generator). And maybe build an EM barrier around my house (time to stock up on aluminum foil?).

Yes, my precious! Yessss, my precioussss! Muhuhaha! (Again, that’s evil laughter for the… ah, never mind.)

Keep Your Digital Life Secured

Internet No Comments

You’re living more of your life and doing more of your business on the Internet. You’re paying bills with online banking, checking your credit cards on the web, and shopping at several dotcom stores. Every one of those sites may require you to have an account with a username and password. To make it easy, you’re using the same password for all the sites (I hope not). Or you use several passwords but there are so many to remember, so you put them all in a little text file on your desktop or write them on a post-it note. Does this sound like you?

You have decided to digitized your legal documents to save space and to speed up searching. Or maybe you have taken the step to receive all or some of your documents, like bank statements, in digital format. You scan and save everything onto your hard drive. Does this also sound like you?

You have anti-virus and anti-spyware software running on your computer and doing frequent scans, weekly and maybe even daily. (If you don’t, see my post on free anti-virus and anti-spyware software). Hopefully, the software will protect your computer from having unscrupulous programs installed, which for example, could capture your keyboard inputs when you are logging into your banking website. But what prevents someone from stealing your computer (especially laptops) and reading your password text file and digitized legal documents? Would you be one of the many who can only say “nothing”?

Don’t lose hope. There are free software solutions which can help you protect your passwords and digitized documents. (Thanks very much to the software developers who donate their time and efforts to create these free tools!) Below are the two free programs that I use to secure my information. They work on both Windows and Mac OS X.

The first is Keepass which is a simple-to-use, secured password keeping utility. It is a lightweight text editor that saves any inputted text to a single, encrypted file. The file will grow if you add more text. Just run Keepass and input your Keepass password (which you set when creating the file) to view the encrypted text file. Keepass will lock itself if you don’t use it after a certain amount of inactivity time (by default, I think it is one minute). I use Keepass to keep information that I need to access often, such as passwords and other textual data. With Keepass, I can use a different password for each website and the passwords can be gibberish. (Please make sure to use a long Keepass password and practice typing it so you won’t forget.)

The second is TrueCrypt which can be considered as a secured, virtual hard drive utility. You can use TrueCrypt to create an encrypted file which can appear as a virtual hard drive. The virtual hard drive will show up in “My Computers” as just another drive letter. Any files you put into that virtual drive is stored in the encrypted file. The size of encrypted file cannot grow; so when you first create it, please pick a size which will fit your secure storage needs. (If you run out of space, just create use TrueCrypt to create a larger file, open the old and new files as virtual drives, and copy everything over to the new, larger drive.) Because the encrypted file acts like a hard drive, you can create folders and subfolders inside it to organize your files. Like Keepass, TrueCrypt requires a password to unencrypt the file and open it as a virtual hard drive. I use TrueCrypt as a secure storage for all my digitized documents.

Well, that’s it. As the doctor would say, that wasn’t too bad, right?

Annoyance-Free Internet Browsing with Firefox and Adblock Plus

Internet No Comments

Update: While NoScript is a powerful tool, it is also a very complicated tool and hard to use. After I had used it for while, I realized that the safety it gave me was not worth the hassle of manually setting permissions for everything; not to mention that many useful sites (like banking websites) were broken unless I disabled NoScript. I think this manually-intensive permission setting by the user is also why Windows Vista failed so miserably.

Instead of NoScript, I would like to recommend a very user-friendly plugin called Adblock Plus. Adblock Plus cuts down on the popups and ads without hassling me at all. Just use Firefox to browse to the Adblock Plus website, hit the green “Install Adblock Plus” button, and when Firefox restarts, accept the default Adblock Plus subscription setting. The subscription provides a blacklist which eliminates the need for Adblock Plus to prompt you to block content.

Safe Internet Browsing with NoScript (Original Posting Follows)

If you use Firefox, there is a great Firefox add-on called NoScript which makes internet browsing much safer with your cooperation.

NoScript prevents executable content (such as Javascript, Java, and Flash) from running on a web page unless you give it permission to. Executable content are used for stuff like showing video on a web page and are misused to infect your computer with viruses and spyware.

Once you have NoScript installed, when you go to a website, you will see at the bottom of Firefox a line bar with the Options button on the right. If you trust the website (such as www.bankamerica.com), then click on the Options button and select “Allow bankamerica.com”. From then on, executable content on that website will always be allowed to run.

If the page doesn’t look right, you can also temporarily allow the executable content to run by clicking on the Options button and selecting “Temporarily allow <website_url>”. If you come back to the website later, the executable content will not be allowed to run.

NoScript can make browsing a lot safer, but it can be a hassle at the beginning because you have to give permission for each website. Unfortunately, some web pages host executable content from different websites so you may have to give permission to two or three websites before the web page shows up okay.

If you’re interested, just run Firefox, browse to NoScript – JavaScript/Java/Flash blocker for a safer Firefox experience! and click on the “Add to Firefox” green button.

Flex/Flash to STOMP to ActiveMQ

Internet 2 Comments

Recently, I wanted to look into writing a Flash client which uses the STOMP protocol to talk to an Apache ActiveMQ Server. I found this great blog, Flex chat application that uses Apache ActiveMQ and STOMP, that talks about creating a STOMP-based chat client using Flex. I tried to follow the blog and found that it was missing several installation steps and instructions on how to use the free Flex SDK. To save you the trouble, I’ve documented the missing steps below.

Note: I’ve never developed with Flash or Flex before but after some reading, I came to the realization that both were different ways of doing the same thing. Flash is an in-browser platform which uses the ActionScript language, similar to a Java Applet using the Java language. Flex could be considered as way to package ActionScript 3 (AS3) code, pre-built AS3 GUI libraries, and media files for compilation into a SWF file. This paragraph is probably totally inaccurate but it helps me keep things organized in my head.

First, download and unzip the latest Apache ActiveMQ Server to a directory like “c:\install\apache-activemq”.

  • Enable the STOMP support:
    • Open and edit “c:\install\apache-activemq\conf\activemq.xml”
    • Search for the text “<transportConnectors>”
    • Add the stomp connector definition under the existing openwire connector:
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>
  • Run the ActiveMQ Server with this command: “c:\install\apache-activemq\bin\activemq.bat”. The ActiveMQ Server will start listening on ports 61616 and 61613.

Second, download and install the latest Flash Security Policy Server to a directory like “c:\install\flash-policy-server”. The Flash Security Policy Server allow cross-domain STOMP connections to be made from the Flex chat client.

Note: Adobe added cross-domain security restrictions to Adobe Flash 9 players and later versions. This restriction prevents the Flash player from connecting to another server or to a different port on the same server (such as the STOMP port 61613) from which the Flash player’s hosting HTML page was served. To allow the Flash player to talk to the different STOMP port 61613, we have to run a flash security policy server on the same hosting server with a configuration allowing the action.

  • Allow Flash clients to talk to the server’s Stomp port:
    • Open and edit “c:\install\flash-policy-server\resources\default_policy.xml”
    • Search for text “allow-access-from”
    • Under the allow access statement for port 8080, add a second line for the stomp port 61613:
    <allow-access-from domain="*" to-ports="8080" secure="false"/>
    <allow-access-from domain="*" to-ports="61613" secure="false"/>
  • Run the policy server with the command: “c:\install\flash-policy-server\start-policy-server.bat”. The policy server will listen on port 843.

Third, download and unzip the latest Adobe Flex SDK to a directory like “c:\install\flex-sdk”.

  • Add the Flex SDK bin directory to your path environmental variable:
    • Right-click on “My Computers” and select “Properties”. A dialog window will appear.
    • Click on “Advanced” tab and hit the “Environment Variables” button. A smaller dialog window will appear.
    • Double-click on the “Path” variable in either list boxes. An even smaller dialog window will appear.
    • Go to the “Variable value” edit field and append “;c:\install\flex-sdk\bin” to the end.
    • Hit OK, OK, OK.
  • Alternative, you can just run the following in the command prompt window before compiling with Flex: “set PATH=%PATH%;c:\install\flex-sdk\bin”

Fourth, download and unzip the STOMP Chat client source to a directory like “c:\projects\stompchat”.

  • Launch the Window command prompt application by going to Start menu, select “Run…”, type in “cmd”, and hit the OK button.
  • Go to the stompchat directory: “cd \projects\stompchat”
  • Compile the STOMP chat client using the Flex SDK compiler:
    mxmlc.exe -source-path=.\ .\StompChat.mxml -output .\StompChat.swf
  • Drag and drop the generated StompChat.swf file into two browser windows (the latest Firefox or IE will work). Login with any name and start chatting back and forth.

Congratulations! Hopefully everything worked for you.

If it didn’t, here are some debugging steps:

  • Manually connect to the ActiveMQ STOMP service to make sure it is actually running by following this Stomp Tutorial.
  • If you have the Java SDK installed, you can use JConsole to look at the ActiveMQ queue statistics.
    • Run “jconsole.exe” from the Java SDK bin directory.
    • Select “Local Process” and “run.jar start”. Click on Connect.
    • Click on “BMeans” tab
    • Expand “org.apache.activemq”, “localhost”, “Topic”, and “CHAT.DEMO” which is the queue name used by the STOMP chat client (if you open StompChat.mxml, you will see it defined as the topic variable)
    • Expand “Attributes” and select “QueueSize”. The QueueSize count should keep increasing as chat messages are received by ActiveMQ server. You will have to hit the Refresh button to update the count.

FYI, Integrating Flex and RabbitMQ using STOMP is another Flex STOMP example that sends an image file instead of just text chat messages. Here are the Flex SDK compilation commands for the example STOMP Image Share source:

mxmlc.exe -source-path=.\src\ -library-path+=.\libs\Stomp.swc .\src\ImageSender.mxml -output .\bin\ImageSender.swf
mxmlc.exe -source-path=.\src\ -library-path+=.\libs\Stomp.swc .\src\ImageReceiver.mxml -output .\bin\ImageReceiver.swf

Javascript to JSON to PHP (and back)

Internet No Comments

I was working on a little project that involved having a javascript client talk to a PHP backend using the JSON format. Of course, the first thing I did was to google for a simple example of this. Unfortunately, the info was scattered across several sites so it required some detective work to stitch together all the different data to get a working example.

To hopefully save you the time, I will provide a working example of how to get Javascript to talk to PHP using JSON. I will follow the time-honored tradition of providing a Hello World example. Even though it is very boring, it does demonstrate the bare essentials of the code.

Below is the Hello World PHP server script (let us call it “hello.php”). It parses a JSON-formatted post body and responds in kind.

<?php

// Retrieve the request body
// The request body is expected to look like:
// {
//   "firstName" : "John",
//   "lastName" : "Doe"
// }
$reqBodyJSON = @file_get_contents('php://input');
$reqObj = json_decode($reqBodyJSON);

// Retrieve the first and last name
$firstName = $reqObj->firstName;
$lastName = $reqObj->lastName;

// Construct our json response which will be an array
// of two possible replies
$response = array(
   "friend" => "Hi, ".$firstName."!  I'm glad to see you!",
   "foe" => "Goodbye, Mr. ".$lastName."!  Go away, please!"
);

// Output json response header and body
header('Content-type: application/json');
echo json_encode($response);

?>

Below is the Hello World HTML and Javascript client (let us call it “hello.html”). It will call the PHP server and display one of the two returned responses (selected randomly). The client uses a lightweight javascript framework called Prototype to facilitate the Ajax call to the server; we will need the “prototype.js” to be placed on the server for retrieval by the javascript client.

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Hello World!</title>

<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">

function sayHello() {
  // Retrieve the values from the form
  var first = document.getElementById("firstName").value;
  var last = document.getElementById("lastName").value;

  // Construct request object
  var reqObj = {
    firstName : first,
    lastName : last
  };

  // Call the server
  new Ajax.Request('hello.php', {
    method : 'post',
    contentType : 'application/json',
    postBody : Object.toJSON(reqObj),
    requestHeaders : {Accept: 'application/json'},
    onSuccess : function (response) {
      // Get the response object
      var respObj = response.responseJSON;
      // Make our response random
      var isFoe = Math.floor(Math.random()*2+1); // 1 or 2
      var replyText;
      if (isFoe == 1) {
        replyText = respObj.foe;
      } else {
        replyText = respObj.friend;
      }
      document.getElementById("reply").value = replyText;
    },
    onFailure : function() {
      alert('Ajax call failed');
    }
  });
};

</script>
</head>

<body>
<h3>Hello World!</h3>

Please input your first and last name:
<form>
  First Name: <input id="firstName" type="textbox" value="George"><br>
  Last Name: <input id="lastName" type="textbox" value="Washington"><br>
  <input type="button" value="Say Hello" onclick="sayHello()">
  <br><br>
  Response: <input id="reply" type="textbox" readonly size="50"
             value="Press button for response!">
</form>
</body>
</html>

I hope that this example will help you in your explorations of web programming.

« Previous Entries