Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Tuesday, September 1, 2009

Fix your USB Flash Drives

Most of time due to viruses and disk errors USB flash drives or USB pen drives become unusable. If you try to open them, format them or scan them for viruses on Windows; system won't let you do so.
There is a very easier fix on the other side of the river. i.e. using Linux.

WARNING: This procedure will format your flash drive. I'm not responsible for any damages or loss that may cause you. Use this guide at your own risk.


All you need is Linux installed machine or bootable Live Linux CD.
Goto console mode. (Go to the terminal mode)
Type following command to find out your flash drive node,

sudo dmesg | tail -20

Then you will get a list like

....
usb-storage: device scan complete
sd 3:0:0:0: [sdb] 12345678 512-byte hardware sectors: (320 GB/298 GiB)
sd 3:0:0:0: [sdb] Write Protect is off
sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 3:0:0:0: [sdb] Assuming drive cache: write through
sd 3:0:0:0: [sdb] Assuming drive cache: write through
....

Then sdb is your flash drive.

Use following commands to fix your flash drive.

sudo fdisk /dev/sdc

You must change /dev/sdc appropriately.

Then you will get following message and prompt.

The number of cylinders for this disk is set to 14593.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):


You may type p to list current partition table.

Then enter d and delete available partitions.
If you have only a single partition entering d will delete it.
Other wise you may have to enter the partition id.

After deleting all the partitions, enter n to create new partition.

Command (m for help): n
Command action
e extended
p primary partition (1-4)

Now enter p then 1.
Then enter twice.

p
Partition number (1-4): 1
First cylinder (1-7644, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-7644, default 7644):
Using default value 7644

Command (m for help):

Now enter w to write table to disk and exit.
Now you will be able to format the USB flash drive and reuse it again.












Tuesday, March 31, 2009

.NET/IIS URL Rewriting using URL Rewriter

You can easily rewrite URLs on .NET/IIS using free open source program called URL Rewriter.
If you don't know what is URL rewriting is, it is simply the mechanism which give out search engine friendly URL like example.com/products/psp instead of example.com/products.aspx?product=psp
Whats actually happening is, there is only products.aspx file exists and it takes query sting product.
But by using URL rewriting, it passes the psp as the query string to the products.aspx file.
So what user see is example.com/products/psp but (s)he is actually looking at the example.com/products.aspx?product=psp.

So Interested? ;-)
If so this is how it will be done,

<configsections>
<section name="rewriter" requirepermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
<configsections>

<system.web>
<httpmodules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" />
<httpmodules>
</system.web>

<rewriter>
<rewrite url="/products/(.+)" to="/products.aspx?tag=$1" />
</rewriter>

  • Now if you test this on Visual Studio, you will see that URL rewriting is working.
  • But, If you deploy this on ISS it will not work.
  • The trick is,
  • Right Click on the web site on ISS manager.
  • Goto the "Home Directory" tab.
  • Select configurations.
  • Select .asax extension.
  • Click "Edit" button.
  • Copy the executable path and click the "Cancel" button.
  • Now click on the "Insert" button.
  • Paste the previously copied executable path on the text box.
  • Make sure that "Verify that file exists" is unchecked.
  • Click Ok
  • Close the web site properties dialog.
  • And thats it. ;-)
You can use reguler expressions, IF clause, UNLESS clause etc. URL handling. You can find out lot about it from URL Rewriter Refence.