Sunday, January 13, 2013

Bank of America Master Card Points Reward Program Dollar and Points Ratio

Introduction and Background Information
This isn't really a problem, just something I thought was kind of amusing and I wanted to share with anyone who might be wondering about it or hell maybe you didn't even realize it. I have a Bank of America (BOA) Master Card (MC) with what is formerly known as the World Rewards Point Program which has recently been re-branded as the BOA Rewards Point Program. I also own a Visa with a Cash Rewards Program which I absolutely love because I get money back for buying stuff I have to buy anyhow which averages out to about $25 every 3 months. That's not bad. I haven't done the ratio on that yet (follow up article?), because I don't really care what the ratio is since like I aforementioned I would have had to purchase those items with or without the rewards program.

Stuff such as Gasoline which you get 3% back on, then 2% on food and 1% on anything that isn't the other two things. Well for those things that only qualify for 1% I use my MC instead because I like to separate out my purchases. So the Visa is for food and gasoline (odd pairing huh) and my MC is for anything that isn't food and/or gasoline. Helps me identify where my money is going pretty easily. I am more forgiving of the purchases on my Visa since I automatically know what they are rather than my MC which is for what can be considered non-essential items. Well I started racking up a bunch of points on my MC and I wanted to see what the payout was if I converted my points to cash which is actually an option or I could get stuff or gift cards which are kind of like cash. I noticed that the ratio of Points to Dollar (or Dollar to Points) were drastically different depending on how many points you have and what you are trying to obtain. In my case I am focusing only on cash or an Amazon Gift Card because I feel that Amazon is a pretty good place to spend money especially if you have Prime.

The Chart
Item Value Points Ratio ($/p) Ratio (p/$)
Cash $12.50 2,500 0.005 200
Cash $25.00 5,000 0.005 200
Cash $37.50 7,500 0.005 200
Amazon Gift Card $25.00 3,500 0.0071 140
Amazon Gift Card $50.00 6,500 0.0077 130
Cash $80.00 10,000 0.008 125
Cash $120.00 15,000 0.008 125
Cash $160.00 20,000 0.008 125
Amazon Gift Card $100.00 12,000 0.0083 120
Cash $250.00 25,000 0.01 100
Cash $350.00 35,000 0.01 100
Cash $500.00 50,000 0.01 100

This chart is sorted by the Dollars to Points Ratio (4th Column). I mixed in Cash and Amazon Gift Cards because those are the two most intriguing things to me. Amazon doesn't beat out cash, it is only worth it if you are going to cash in 12,000 points. Otherwise it is better to wait it out to until 25,000 points where you benefit the most and you get the highest dollar per point value of 0.01 dollars per point.

No I don't actually have a lot of time on my hands, I just thought this was pretty amusing and I wanted to point it out. So basically the idea here is the more points you have the better your conversion is from points to dollars because you hit a constant, a ceiling factor if you will, where it doesn't matter anymore. It is better to go for a point to cash conversion when you hit 25,000 points because your ratio doesn't get any better.

Thursday, January 10, 2013

Work Around to Opening up a Local Folder from an HTML Link

Introduction (solution below)
In general in web programming at one point you may need to or be asked to open up a local folder from a html link. This is something that used to work with older versions of IE, but just like everything in older versions of IE it was not a good idea just because you could do it. It was a huge security risk. Basically one can say that if your browser is able to access your file system without your consent by you clicking on anything, it is security risk. I remember once while I was browsing around on strange edges and corners of the internet, I clicked on a DoubleClick Ad Banner and it wrecked my weak computer by installing without asking me about 10 programs that hijacked my computer and my browser. I tried uninstalling all of them, but even after uninstalling the programs my computer was running very badly, so I ended up having to reformat because it was so bad. That is the best example I can give of a browser security risk and that happened in a old version of IE.

The Question
How do I open up a local folder from an HTML link on a web page? This question has been asked in many forms repeatedly on stackoverflow and other places on the net. I am using this question as my model:

The Answer
My co-worker and I were trying to figure out the best way to solve this and we went through a lot of trial and error until we found out that there were files ending in *.url that were very simplistic as opposed to *.lnk files which are binaries and not plain text! Don't bother trying to make a *.lnk (shortcut file) from the server side because this type of file requires shell access, you need the shell from the client side, not the server side in order to do this correctly.

My co-worker/friend contributed an answer to the question on Stack Overflow here.

Basic Steps
  1. Take the folder's path and put it into a URL file like so:
    I got this solution from here.
  2. Make the "folder path" available for download via a LinkButton or similar mechanism
  3. Before the user can download the file, IIS has to allow for the *.url MIME type otherwise IIS will return a 404 error.
    A. Open the IIS Manager and for your application/site in Features view locate the IIS section and find the feature called "MIME Types", open it.
    B. In the top right click the "Add..." link.
    C. In the modal window enter ".url" into the "File name extension" filed and enter “application/internet-shortcut” into the "MIME type" field.
    D. You will have to restart IIS in order for these settings to be applied. Do so by entering the following into CMD: "IISRESET /restart" - I got this solution from here from the last paragraph.
  4. The user has to open the file and it will open the specified folder (if it exists on their system)
Viola same effect. One more step for the user, but really the only way to get this to work right now that we could figure out.
The Code
Here is some starter code to help you get the idea.

//This is a hacked up excerpt from code I am using at work. This is from a Details View control.
//I am intercepting a click event from a Link Button in my control and processing it here.
protected void dv_ItemCommand(object sender, DetailsViewCommandEventArgs e)
 if (e.CommandName.ToLower() == "download")
  //Get the bytes from the string that will ultimately be the the file's content
  byte[] arrContent = System.Text.Encoding.UTF8.GetBytes("[InternetShortcut]\nURL=" + e.CommandArgument);

  //Let the user download the bytes using a different name
  Response.ClientFileDownload(arrContent, "ProductDirectory.url"); //This is a custom method I wrote defined below

/// Download a file to the client through their browser using the raw bytes of a file
/// the raw bytes of the requested file
/// (Optional) the name of the file being requested - if not provided a random file name is assigned with a "tmp" extension
public static void ClientFileDownload(this HttpResponse response, byte[] file, string fileName = null)
 if (file != null)
  if (string.IsNullOrEmpty(fileName))
   fileName = Path.GetRandomFileName();

  response.ContentType = "application/x-msdownload";
  response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
  throw new Exception("The provided file was null.");

My co-worker and I used all of the following resources to come up with an answer. So I am giving credit where credit is due, please check out the links if you have some time.

Monday, January 7, 2013

HTTP Error 503. The Service is unavailable.

This error reads:
Service Unavailable - HTTP Error 503. The service is unavailable.

I'd like to open up by saying what we are all thinking when this happens, "YEAH NO SHIT!" Okay, now that I got that out of the way on to the possible solution to this annoying problem. I'd like to add that I have seen this happen for any variety of reasons. I guess I can generalize the cause and say it is server trauma. Any major changes can cause something like this to happen. For example if you did a bare metal backup and restore of your server, this can happen.

A Possible Solution
I can't guarantee that this will fix your problem, but it is worth a shot right? When this happens first thing you want to do is add a simple file to your application's directory. 
  1. Create a file named "Test.htm"
  2. Edit the file to contain the word "hi" or add your name or phone number. The point is add something you can identify uniquely. 
  3. Browse to this file. Do so from the content view of your application in IIS7 right click the Test.htm file and select Browse from the context menu. 
This exercise tells us a few things. First it let's us know if IIS is responding at all, if you just get the same Error, then chances are it isn't your application. You can check the event viewer, but again chances are nothing will show up in there. Lastly check your application pool, if your application pool is stopped, then there is a problem with your application pool. You can try to tinker with it, or just blow it away and re-create it.

Before Deleting Your Application Pool
I strongly recommend taking screenshots of your application pool's configuration before removing it and trying to re-create it. Specifically you want to open up it's advanced settings and screen shot the entire window. Open up any collapsed regions and screen shot those too just in case.

Application Pool Identity Gotcha
Make absolutely sure to note which application pool identity you are using, especially if it is a custom account! Meaning, it is not the default identity, network, system etc... Meaning you are using a custom windows account as the identity that requires a specific domain, username and password. Make absolutely sure you have that information before deleting your application pool otherwise you might regret blowing it away early.

Basic Steps
  1. Move all dependent applications from the damaged application pool to a temporary application pool. If you don't do this you can't delete the damaged application pool. Create a dummy application pool if necessary, the settings don't matter until you are creating your new application pool.
  2. Screenshot all of the application pool's advanced settings, including any collapsed regions.
  3. Delete the offending application pool
  4. Create a new replacement application pool and name it what it was named before (you can change the name if you want, but for the sake of consistency, I would name it the same thing)
  5. Update the new application pool's advanced settings
  6. Move all of the dependent applications from the temporary application pool back to the replacement application pool.
  7. Try to access the file we created initially named "Test.htm", if that works try to access your application.
  8. Rejoice and get back to work. If that didn't work for you, then it is back to google for you :'(
Hope this helps anyone.