Previous month:
August 2007
Next month:
October 2007

September 2007

Amazon S3 Webservice: The best storage deal on the planet

AmazonS3 Since I have several widgets from different sites which have images served from different websites I was worried about the download time and decided to look for CDN (Content Delivery Network) service. The CDNs have distributed servers all over the world.

Amazon has this web service called S3 (Amazon Simple Storage Service) which is basically a paid CDN. But Its unbelievably cheap. The service supports REST and SOAP web services. Unlike other services there is no bulk purchase, you pay for what you use. If I wanted to host some files this service and had a big bandwidth connected to my home server, the electricity cost alone would be higher than this web service. If you store 20 Gigabytes of data and have a monthly traffic of 2GB then it will cost you 3.40U$. I have a few hundred megabytes of file to store and my traffic probably will be less than 10 cents a month. Pricing from Amazon is like this:

  • $0.15 per GB-Month of storage used
  • $0.18 per GB - first 10 TB / month data transfer out
  • $0.01 per 1,000 PUT or LIST requests
  • $0.01 per 10,000 GET and all other requests*

And the best thing is that, this is a fault tolerant, scaled, reliable, fast service at such a cheap price. I can host all my personal files here and still it would be better than hosting somewhere else. Amazon provides API with code samples for all major programming languages (C#, Java etc). Since these files are added, modified and fetched via API then how do I host my images, movies etc there without writing code? Well, the answer to that is pretty simple, create a bucket (like a folder) and put your files in there and make them public and then you can access them with http gets (read on for how to do that). The Amazon web services logo image used at this blog post is served from the Amazon S3 service.

Nice, but what else can I do with it?
You can even use the S3 service to as a web storage with JungleDisk (see the Amazon traffic rate at their site) and use it as a web hard drive, but the software costs 20 U$, so it is several times more expensive than my 1 years of traffic at Amazon S3. I am not going use it. Instead ...

I stumbled onto this Firefox extension which is like a file transfer utility to S3. You can find the extension here and also read this article at coding horror.

What do I plan to do with this service
I am planning to write a free program for Amazon S3 service which probably will kick JungleDisk out of business and store my files there. Since I have started regular office hours in office recently and stopped bringing work home, I think can manage to write this at home after work. But as I have so many unfinished pet projects to finish ... lets see when I get time for this.


Hack .NET Framework : Use private classes to fulfill your need

Lutz Roeder's Reflector is the most useful .NET utility ever built. It has helped me many times in the past to browse through compiled code and use it correctly. Since it decompiles the code and shows the code inside, it is actually better than help files or any other form of documentation on any assembly. If you use the Reflector then you can find that .NET framework itself has many private utility classes built into it which are used by the public classes but as a developer we cannot use it. Reflector will let you find a lot of those classes which can be instantiated and used via Reflection.

Lets take the example of System.Security.Util is a private namespace in mscorlib which has a class called Hex. This class can encode and decode hexadecimal string. Since it is a reusable class we should use it when required rather than writing a new class. See the Hex class below in Reflector

Reflector_hiddenclass

Now this looks like a pretty useful class. But its private, how do we use it? In order to do so we can get hold of the private type via reflection like this:

    Type type = Type.GetType("System.Security.Util.Hex, mscorlib");

Then we need to get a hold of the method ( in this case the class is static so are its method ).

    MethodInfo
encodeHexString = type.GetMethod("EncodeHexString", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

We now have the method and all we need to do is to invoke it. Since the method is static it will not need any object as reference when invoked.

    List<object> parms = new List<object>();
    parms.Add( Encoding.ASCII.GetBytes("This is to be converted to hex"));

    string encoded = (string)encodeHexString.Invoke(null, parms.ToArray());

Here we have invoked the method of a private class in an assembly and got output from it. Ain't that nice!

In order to make things simpler you can write a wrapper class around and use it to instantiate and call the private classes or private  methods of any class.

This sample contains such a class and here is how easy it is to use it. In the next code block we are converting a string to hexadecimal format and then getting it back to original format using the private Hex class.

HiddenType wrapper = new HiddenType("System.Security.Util.Hex,mscorlib");

string originalString = "This is a string";

Console.WriteLine("Original string is \t: {0}", originalString);

byte[] bytes = Encoding.ASCII.GetBytes (originalString);

string encodedString = (string) wrapper.InvokeStaticFunction("EncodeHexString", bytes);

Console.WriteLine("Encoded string is \t: {0}", encodedString);

byte[] decodedBytes = (byte[]) wrapper.InvokeStaticFunction("DecodeHexString", encodedString);

string decodedString = Encoding.ASCII.GetString(decodedBytes);

Console.WriteLine("Decoded string is \t: {0}", decodedString);

The code sample can be downloaded below. Keep on reflecting ...

Download PrivateClassDemo.zip

Technorati Tags: , ,

kick it on DotNetKicks.com


Run multiple websites in Windows XP with IISAdmin.NET

The IIS in Windows XP does not let you add more than one site to the IIS. With IISAdmin.NET you can add multiple websites to your IIS in windows XP. However only one site can stay active at any time.

Iisadmin_2
This article at CodeProject uses Directory services to create a web site.
If you take a look at the image on the right you can see a screenshot of how to create a site using this tool. But the site must be started from this IISAdmin application.

This is very convenient for a ASP.NET developer who needs to work on multiple websites at his own development environment and uses XP.

Iis

Once the site is created you will see multiple sites in your IIS like in the Image on the left and  it can be seen that only one site is running.


Related
Computer based companies provide internet marketing program. These companies provide many promotional programs and services including seo services. Other than these services they used to affiliate the organizations by providing web hosting service. As most of the people who are new to web design strategy feel uncomfortable in knowing different services. Then such people are provided by shared hosting services due to which they get much of experience of different web services. Some famous companies launch affiliate program which provide a platform for small firms for promotion. Few technologies like ip phones decrease the communication gap within these services and provide a cheap communication path for them.