Friday, December 18, 2009

Samurize Config For NextBus

NextBus is a pretty awesome service but it's a pain to load up the website everytime to look up the next arrival time. The site does have bookmarkable URLs and the pages do reload automatically. But if left open the page usually times out after a few reloads. And personally, I don't like leaving tabs open in the browser for too long, it just seem untidy and unnecessary, not to mention RAM usage.

I use Samurize to embed a lot on information in 'always-on-top' panels so that I can see things like the time in 2-3 cities, the current temperature and weather conditions in my city, CPU and RAM usage, currency rates etc, all in a glance. But I couldn't find a script or plug-in that would pull the data for NextBus and NextBus doesn't have an API or even an RSS feed. I finally had some time on my hands, now that the semester has come to an end and I put together a quick-and-dirty script (in VBScript) to get the next two arrival times for a bus.

Now, I didn't have the patience to write something to parse the whole page - it's pretty messy and there's no ids or names that would make working with the HTML easier. So for now, the script is a hack that takes advantage of the fact that the page contains a block of JavaScript that sets the title of the window to the next two arrival times. So reading that and getting the time was pretty easy and works for now, at least.

You can find more details at http://www.nogoodatcoding.com/projects/nextbus-scraper. There is also a sample Samurize config, distributed as a .sam package. Here's what you should see if you use it:


Sunday, November 8, 2009

jCIFS TransportException: Invalid payload size: 254

I was looking into jCIFS for adding shared network folder support for Folder2Feed. I had a snippet of code that I had tried out quite some time back which simply listed all shared folders on a particular machine and this had worked for my PC and for the Mac. However, when I tried to run this demo code against the Mac after a few weeks with a new release, I got the following exception:

jcifs.util.transport.TransportException
java.io.IOException: Invalid payload size: 254

I didn't really investigate this because of other commitments. But a friend of mine who was also checking it out finally figured out the problem. With the earlier releases, the property jcifs.smb.client.useExtendedSecurity defaulted to false. But with the newer releases, it defaults to true. Explicitly setting it to false fixes the problem.

Monday, April 27, 2009

Controlling Your Home Web Server Content Remotely Using Dropbox


I have a home server (using Tomcat) that I use for some stuff like sharing files with family and friends and getting feedback on some web-based stuff. Recently, I was creating the website for Folder2Feed (a Java app that generates feeds from folders) and I was tweaking some CSS bits after hours at office. I wanted to check with some friends about the look and these were my options:

  1. Send the files to each person using an IM client
  2. Cons:
    • The receiver would need to be competent enough to understand what to do with the files I was sending
    • I'd have to send the files to each person
    • The other person needs to be online at the time
    • Not every workplace allows IMs
    • Resuming broken downloads isn't usually possible
  3. Use VNC to connect to my home machine and then put the updated content in the web server folders
  4. Cons:
    • It's a slow and tedious process over VNC
    • Doing this over and over for small changes is a major pain
    • Not every workplace would be setup to use VNC
  5. Wait until I got home
  6. Cons:
    • I'd have to wait
    • I'd have to remember to take the files home with me (I always forget!)

All of these are pretty viable options but where's the geek cred? Alright, so VNC does have some but still, it's painful for regular use over a slow connection. I have been using Dropbox, which is an awesome service. It's free, painless to setup and so simple, even your most technophobic friends will be able to use it. So I figured that if I could setup a way to update my web server using Dropbox, I'd be in business. The easiest way to do that would be to move my web server installation into the Dropbox folder but that would be overkill. I didn't need the complete web server setup to be shared and synced, only one particular webapp I was running on it.

Now there's this concept of vHosts, wherein a single physical server can host multiple websites. For example nogoodatcoding.com and nogoodatcoding.org could both be on the same server but that would not be readily apparent to a visitor. Most modern web servers should support vHosts - Tomcat and Apache certainly do. The one that would probably be more commonly used is name-based and that is what is used in the instructions below.

So coming to the crux of this post - you can simply add a vHost to your web server and point it to a folder inside your Dropbox home and voila! You have complete control over the content you're hosting!

 I use DynDNS and NO-IP for my dynamic DNS needs and all I had to do there was add another hostname and point it to the same machine.
 

Here's how you can do it for Tomcat:
  1. Browse to $CATALINA_HOME/conf and edit server.xml.
  2. You'll find a block of code that defines the default vHost - localhost:
    <Host name="localhost"  appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    You can leave this untouched.
  3. Add another host, something like
    <Host name="myDynDNSHostNameForDropbox.dyndns.biz"  appBase="c:\\My Dropbox\\My vHost Content"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
  4. Restart the server and you should be good to go.

You can find more about configuring Tomcat for vHosts at the official website: Virtual Hosting and Tomcat

For doing the same with the Apache Web Server (version 2.2; for older ones you should locate the appropriate documentation and tutorials):
  1. Edit your httpd.conf and uncomment the line for virtual hosts:
    #Include conf/extra/httpd-vhosts.conf
  2. Edit conf/extra/httpd-vhosts.conf and set it to something like:
    NameVirtualHost *:80
    
    #This will maintain your current configuration for all names except the second vHost
    <VirtualHost *:80>
    ServerName localhost
    
    #This is the relative path to the htdocs directory
    DocumentRoot htdocs
    </VirtualHost>
    
    #This vHost will answer for requests to myDynDNSHostNameForDropbox.dyndns.biz
    <VirtualHost *:80>
    ServerName myDynDNSHostNameForDropbox.dyndns.biz
    
    #The absolute path to the directory for this hosts content
    DocumentRoot "c:\\My Dropbox\\My vHost Content"
    </VirtualHost>
    
    #This apparently is required for overriding the default security; otherwise you'll be denied access
    <Directory "c:\\My Dropbox\\My vHost Content">
    Order Deny,Allow
    Allow from all
    </Directory>
  3. Restart the server and you should be good to go.

I'm not really an Apache user, I tend to stick with Tomcat. I got this information from the offical Apache docs: Virtual Hosting with Apache, Name based virtual hosting with Apache and this great tutorial on Apache Virtual Hosting.

 It's pretty much the same technique for any webserver that supports vHosts and you should find the documentation for yours and check what needs to be done.
 

Once you've set this system up, you'll be able to simply modify files in your locally synced folders under Dropbox and the changes will be reflected in a few moments on your home webserver! You could use this to put up pretty much anything on your webserver - a photo you just clicked at work, a document you want to put up to share with a friend or even some collaborative work on one single webpage or anything else!

Friday, March 6, 2009

Linking PayMate To Your ABN AMRO Bank Account

I'd got a PayMate (not to be confused with Paymate, the Australian equivalent of PayPal) a year or so ago. I don't really use it very frequently except that I'd got a few free coupons so I'd bought stuff with those.

Recently, in my ABN AMRO netbanking account, I noticed a link that read Click here to register for payment service through Mobile 'PAYMATE' [sic]. This sounded interesting since, usually, I'd come across stuff on the online shopping sites that cost just a little bit more than my coupon was worth. Or there'd be extra charges for shipping. I figured that if I could associate my bank account with PayMate (for example, with PayPal, you can add additional sources but the money in your PayPal account gets used up first. So you never run out of funds, but you also don't end up with a trifling balance in your PayPal account), then I'd be able to tap into those funds for the remainder of any purchase requirement, over and above the coupon value.

I needed to confirm this of course, so I called up ABN AMRO's customer care helpline. Not a very good idea. Those people weren't clear on what PayMate was themselves and even when I tried to make them understand that I had been using PayMate for over a year and I knew what it was, they insisted on trying to explain the PayMate service to me. Sigh!

Now don't get me wrong, the representatives are usually pretty helpful and I do like ABN AMRO's service. Except in this case, they had no idea about it and had probably not been trained well enough on the topic. Anyway, I'd read somewhere that instead of venting your ire on some poor phone jockey, who probably wouldn't be able to do anything about it anyway, and spoiling your and his/her day, it's better to say 'thank you', put the phone down, and dial in again, hoping you get someone better equipped to help you.

I tried that but to no avail. The next day, I called up PayMate directly and, finally, someone was able to tell me how this thing would work. So here it is, what you've (hopefully) been reading this post for - how would you use your ABN AMRO account with your PayMate account? How will it work?

 If you don't know how PayMate works, you should read their FAQ first.
 

Your phone number is your PayMate id, of course. For every bank account (or other source of funds) linked to PayMate (they plan to add others later), you will get a new PIN. This is in addition to the PIN you may have for your original PayMate account (if you do have one). When you make an online transaction, the PIN you authorize the transaction with will determine which source of funds is utilized.

So there is no question of using up any one source first and then seamlessly switching over to the next preferred source. The source you pick must have sufficient funds.

Too bad. I was hoping for a PayPal like model, I'd probably have used PayMate more often then. They just might introduce this feature though so it's probably good to wait and watch.

Wednesday, February 25, 2009

Using A Virtual Credit Card WIth PayPal - Not Possible Anymore

When I bought my domain, almost two years ago, I didn't want to use my credit card (I'm paranoid that way :) ). I looked about a bit and I found out that PayPal would allow you to use 'virtual' cards that some banks offer. These are one-time usage cards that have some user-imposed limit. By using these cards, which will expire after use (or if unused within certain time-frame), you're safer when participating in online transactions since you don't expose your physical card details.

Anyway, I had an HDFC account and I'd signed up for the NetSafe cards facility. So I also signed up for PayPal and registered a virtual card. Now PayPal had (has?) this thing where your account needed to be verified. A certain amount of money ($1.95 at last check) is deducted from your card and the transaction details have a 4 digit pin (which appears immediately in the transaction details for the virtual card) which you then need to enter in a form in PayPal to prove that you indeed own the card and are not running some sort of scam. After this account verification, you were free to use your card for further transactions. Except that I registered a virtual card which was now invalid after the verification transaction. So I generated another card and added that to my PayPal account and I was good to go.

Yesterday, I was trying to buy a new domain name. I tried doing the same thing I'd done earlier but my transaction kept getting declined. On closer inspection, I saw that PayPal was now asking me to verify my card! This meant that every card you now add to your PayPal account needs to go through the verification process. Which spells doom for virtual card users since the card would be invalid after the verification transaction!

I'm not quite sure when or why this happened, I'm not a frequent user of PayPal; I only registered because GoDaddy, my registrar, had the option for payments via PayPal and PayPal could be used with virtual cards. Well, not anymore! Finally, I ended up registering my actual credit card (luckily for me, I'm also subscribed to alerts via SMS so I received my transaction code almost immediately, instead of having to wait for a couple of days for it to show up in my online transaction list) and using that to make my purchase.

Disclaimer: This information isn't an official announcement from any of the parties mentioned. It's what I figured out after trying out a few things with my account; make sure you've read up on whatever it is that you want to do with your virtual card and/or PayPal account.

 If you're a HDFC bank account holder and are having troubles with NetSafe, check out this well-written post with screenshots.
 

Thursday, February 19, 2009

Folder2Feed

If you've ever wanted to monitor a folder for changes but have realized that it's too tedious to remember to check the contents or to even figure out which files or folders are new then you could give Folder2Feed a try.

It's a Java application that can be configured to monitor a folder and generate a feed (RSS or Atom) of the newest files in that location. It's still work in progress but the basic command line interface version is out. I plan to add a GUI to it soon, work permitting, of course. There are also some other features that I think should be there and I'll be working on them. If you have any suggestions for features, consider leaving me a comment here or on the bug tracker (choose feature request under Type and if possible, leave your email id so I can get back to you if needed).

If you find any bugs, do report them, I'd like to make Folder2Feed better.

For any feedback, mail me at folder2feed[AT]nogoodatcoding[DOT]com (replace [AT] and [DOT] with the appropriate symbols).

 UPDATE [21 Feb 2009]: I've activated Trac for bug tracking, so the link has been changed.

Wednesday, February 11, 2009

Unhandled Win32 Exception Crashes Firefox After Installing Microsoft Visual Studio 2005 (Just In Time Debugger)

The other day I installed Visual Studio 2005 Pro on my machine at office. A little later, I started Firefox and got this error from the Visual Studio Just In Time Debugger:

An unhandled win32 exception occurred in firefox.exe

I Google'd it and I came across this page on the Firefox support forum. None of the suggestions really worked for me but here's what did:

  1. I started Firefox in safe mode
  2. In the dialog that came up, I chose to disable all add-ons (you could also Continue in Safe Mode to first check if Firefox does start up and then disable add-ons from there)
  3. I started Firefox in 'normal mode' and it worked.
  4. I then re-enabled each plugin, one by one, to determine exactly which one was causing the problem.
  5. In my case it turned out to be the QuickTest Professional 9.5 Plugin. These other plugins didn't seem to bother VS 2005:
    • DOM Inspector
    • Firebug
    • Free Download Mananger plugin
    • Google Toolbar for Firefox
    • IE Tab
    • Java Quick Starter
    • Live HTTP Headers
    • Modify Headers


The other suggestions in the forum said to disable the JIT debugger (doesn't really help, all it does is bring up a dialog saying that no debugger was found!), make a new profile/ reinstall ( I suspect that if this works, it's probably because all the plugins are removed ) and for a couple of people, the problem was with AVG Safe Search/ Search Shield.

So YMMV but this is what worked for me.