Thursday, April 23, 2009

Generate Public Key Token of a signed assembly

I had to google a little for this. Finally found some help. Listing it down here. I lost my bookmark. Thanks to the guys who found this out.

  1. In Visual Studio 2005, click Tools -> External Tools...
  2. Click Add and enter...
  • Title: GeneratePublicKeyToken
  • Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe (or search for sn.exe and add that path)
  • Arguments: -Tp "$(TargetPath)"
  • Uncheck all options, except Use Output window
A new entry is listed in the Tools menu titled GeneratePublicKeyToken



Build the dll once and the select this menu item from the Tools menu. You will have the blob and the Public Key Token in the Output Window



Improve your java code quality

Jivelint is a nice utilty to analyze the code that you have written.
Worth a look.

Its command line and one can switch on/off configuration options

Unzip an archive with Perl

I keep this template around to work with zipped archives. Helps...

use Cwd;
use File::Find;
use File::Basename;
use Archive::Zip;
use File::Copy;

$working = getcwd();
find(\&process,$working);
sub process(){
my(undef, undef, $ftype) = fileparse($_,qr"\..*");
if ( (-f $File::Find::name) & ($ftype eq "\.zip") ){
my $zipname = $File::Find::name;
my $dest = "$working"."/temp";
my $zip = Archive::Zip->new($zipname);
foreach my $member ($zip->members)
{
(my $extractName = $member->fileName) =~ s{.*/}{};
print $extractName;
#do some stuff here
}
unlink ($dest);
}
}

Perl to batch script

Convert a *.pl to a *.bat through the pl2bat feature.

1. Open cmd prompt
2. cd to the dir where the *.pl script lives

>pl2bat myscript.pl myscript.bat

Easier to send out .bat than .pl files

PPM through proxy server

Something that users(I :)) forget to do on a newly formatted box..

If the Perl Package Manager is not accessible through your proxy then you cannot download/install packages through the ppm. To get around this issue one needs to explicitly specify the proxy server address and the port to use.

Heres the How-To

1. Open cmd prompt
2. type in: SET HTTP_proxy=http://proxy_server:port

Now you should be able to access and install all packages from CPAN.