How to change the default location of My Documents

In Windows O.S. My Documents resides at C:\Documents and Settings\username by default and whatever you download would go there by default. Ex: gtalk shared files, gmail documents, songs , pictures etc (unless and until you have not specified the alternate path for downloads).
Nobody wants to go deep inside to open a file. At least I never choose my documents for my downloaded stuffs storage purpose.

Uncategorized

How to change the default location of “Program Files”

Have you ever given thought that why all the applications in Windows O.S. getting installed at default location “C:\Program Files” ?
Can’t it be according to our choice?

Yes it can be. And I have two reasons to change it default location anyway (either you feel its necessity or not but it’s good to install application at other location instead of “C:\Program Files”).

Why we need to change the default location of Installed application?
Reason is very simple:
1.       If you are a computer geek like me 😛 or you belong to a profession where you need to install many large sized applications like CAD apps, MS Office, Adobe Photoshop, Dreamweaver, Visual Studio, media players, games etc. Once you will feel that C drive (By default O.S gets installed in this drive only) is not sufficient for installing applications because of growing size of “program files directory” which may slow down your system. So its better to install applications in other drive rather than C

2.       Windows O.S is how much promising with its robustness, how much its virus free, you people know it very well. It may crash because of any silly mistakes that we may do like opening virus contained files, using thumb drive (pen drive) and many more. By that time all installed application will also go in vain and you need to install everything from the beginning. Why not to install applications in other location, so that it may not get affected even O.S gets crashed?

How we could do it?
We could do it by two ways:

1.       While installing application, it will ask for location where it will install it. At that time itself we can provide some other location. For example: D:\Program Files (if Program files folder is not there then create it first and locate it while installing applications).

Through this way you can install software according to your choice of drives. Say all media apps should get installed in D drive and all web tools should get installed in F drive.

2.       We could change the default location permanently using registry editor.

a.       Click on start->run (windows XP) and type regedit, sand then press enter. (Shortcut key for run command is windows key + R)

b.      Look for “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion”

c.       When you will click on Currentversion, You will see a value named ProgramFilesDir  at the right side of that window. By default its value is “C:\Program Files”

d.      Double click on that value and change the default location wherever you wish to install your application from now onwards. Ex: “D:\Program Files”

Minimal things to know about map function in Perl

  Perl is such a nice language that even a beginner can write the fully working code by using simpler things available in Perl.  More you know about Perl  more crazy you will be about it. Its very famous for one liner stuffs and even it has many functions which can minimize our code, run time and our work too!

Map function in Perl is a nice example for it. You can replace you whole foreach code with map in a single line.

  • Perl’s  map functions evaluates expression or a set of block for each element of an array and returns another new array.
  • Each array element is get stored in $_ (local lexical), then it evaluates according to expression or block and pass it to new list of arrays.
  • As hash is nothing but an associative array so you can apply map on that also ex:  %hashVal = map  { lc($_)=>$_  }  @array;   (block example ) or %hashval  = map  + ( lc($_)=>$_ ) ,@array;    (expression example)
  • I just found few different way to write same map function: All will do the same thing , Its just use of regular expression and to differentiate block and expression things.
  • # Method 1 @ucnames = map( ( join " ",  map (ucfirst lc , split)  ) ,@names);
    print "\n########## Printing Values of \@ucnames using map Method 1 ############\n";
    print Dumper(@ucnames);
  • #Method 2 @ucnames = map { join " ",  map {ucfirst lc} split  } @names;
    print "\n########## Printing Values of \@ucnames using map Method 2 ############\n";
    print Dumper(@ucnames);
  • #Method 3 @ucnames = map { join " ", map { s/^(.)(.*)$/uc($1) . lc($2)/e; $_ } split } @names;
    print "\n########## Printing Values of \@ucnames using map Method 3 ############\n";
    print Dumper(@ucnames);
  • Another example :
    Suppose we have an array whose elements are double quoted and we need to remove that. map function could be very useful in this case
     my @out = map { s/"//g; $_ } @arr;

Note: Block does not need comma but expression needs coma explicitly see the examples using { block } and (expression). In simple ,it is

  • map { block } @array or
  • map {expression}, @array or
  • map + { block } , @array (will be treated as expression so comm. Is needed after } )or
  • map (expression , @array)

For fully working code on map function please visit this link For more details on map click here

Minimal Introduction to Perl

 Welcome to Perlistan world! I have been using Perl (Perl 5.10 specifically) from last 1 year and I am really fond of this programming language. There are hell lots of features exist for Perl but I have written only few which I felt is important and interesting for beginners.

Introduction
Perl (Practical Extraction & Report Language) is the Swiss Army knife for  scripting languages(rather call it programming language): powerful and adaptable. It was first developed by Larry Wall, a linguist working as a systems administrator for NASA in the late 1980s, as a way to make report processing easier.

Since then, it has moved into a large number of roles: automating system administration, acting as glue between different computer systems; and, of course, being one of the most popular languages for CGI programming on the Web.

Why did Perl become so popular when the Web came along?
There may be at least two most important  reasons:

First, most of what is being done on the Web happens with text, and is best done with a language that's designed for text processing. More importantly, Perl was appreciably better than the alternatives at the time when people needed something to use. C is complex and can produce security problems (especially with untrusted data), Tcl can be awkward and Python didn't really have a foothold.

Second: It also didn't hurt that Perl is a friendly language. It plays well with your personal programming style. The Perl slogan is “There's more than one way to do it,'' The growth of Internet also complemented Perl. The initial attempt at providing dynamic content was through CGI (even now CGI is used extensively), and Perl's remarkable text handling features made it a quick fit. CGI programming is now synonymous with Perl programming.

CPAN – Comprehensive Perl Archive Network, was set up to share Perl code. Perl supports modules and chances are that for 99% of the programming requirements, there is already a tested module in CPAN (for the remaining 1%, write modules and contribute to CPAN!). Using modules really mask the complexities of adhering to pre-defined standards and frees you to concentrate on your tasks – no point in re-inventing the wheel. Now, you have modules which handles graphics, CGI etc… You can also embed Perl code in your C/C++ programs. A very popular embedded Perl architecture is mod_perl for Apache web server.

Lets dive little bit deeper

Data manipulation
Perl can handle strings, dates, binary data, database connectivity, streams, sockets and many more. This ability to manipulate multiple data types help immensely in data conversion (and by the way, it is much faster than PL/SQL!). Perl also has provision for lists (or arrays) and for hashes (associative arrays). Perl also supports references, which are similar to the pointers in C. Lists, hashes and references together make it possible to define and manipulate powerful custom-defined data-types.

Portability Most of the Perl code will run without any change in Unix or Windows or Macintosh. Typical changes you might have to make include specifying file paths and use of low-level OS specific functions.

CGI CGI.pm. Period. Almost all CGI programs written today are using the CGI.pm module from CPAN. Even before this was written, people used to use Perl extensively for CGI programming. CGI.pm made the process streamlined and easy, even for beginners. The graphics library GD is used extensively in producing dynamic web charts. Ever since Kernighan and Ritchie came out with C programming language, people have started learning almost any programming language with the obligatory "Hello World" program. Let us do the same!

Hello World!

Here is the basic perl program that we'll use to get started.

[perl] #! /usr/bin/perl
# prints Hello world.
use strict;
use warnings;
print 'Hello world.';                # Print a message [/perl]

#!  is called sh-bang (she bang 😉 ). Always let it be your first line of code in your program.  Write the location of executable perl here. Always try to write use strict and use warnings in your program. It will minimize error and you will be following standard coding rules !

Comments Perl treats any thing from a hash # to the end of line as a comment. Block comments are not possible. So, if you want to have a block of comments, you must ensure that each line starts with #.

Statements Everything other than comments are Perl statements, which must end with a semicolon, like the last line above. Unlike C, you need not put a wrapping character \ for long statements. A Perl statement always ends with a semicolon.

Running Perl Write a small  program using a text editor, and save it. The first line of the program is a typical shell construct, which will make the shell start the interpreter and feed the remaining lines of the file as an input to the interpreter. After you've entered and saved the program make sure the file is executable by using the command

[perl]
chmod u+x perlfile
[/perl]

at the UNIX prompt, where perlfile  is the filename of the program (of course with .pl or .pm extension mostly). Now, to run the program, just type any of the following at the prompt.

[perl]
perl perlfile
[/perl]

If something goes wrong then you may get error messages, or you may get nothing. You can always run the program with warnings using the command

[perl]
perl -w progname
[/perl]

at the prompt. This will display warnings and other (hopefully) helpful messages before it tries to execute the program. To run the program with a debugger use the command

[perl]
perl -d progname
[/perl]

When the file is executed Perl first compiles it and then executes that compiled version. Unlike many other interpreted languages, Perl scripts are compiled first, helping you to catch most of errors before program actually starts executing. In this context, the -w switch is very helpful. It will warn you about unused variables, suspicious statements etc.

Minimal Introduction to JavaScript variables

JavaScriptJavaScript variables are used to hold values or expressions. A variable name can be as short like  x, or a more descriptive name, like carname.  Declaring variables is an integral part of any programming language. Developers declare variables to reserve address space in the computer's memory so that they can use it further as in fucntion or anywhere down the program. Variable can be Global or lexical. Always remember not to declare the same variable name at global place and if its being used by only one fucntion or only at one place declare it inside that block only.

 

Rules for JavaScript variable names and declaration:

  • Variable names are case sensitive (y and Y are two different variables). It should be followed throughout the code to avoid declaring two different variables with different cases. This also avoids syntax errors when running the code in the user's browser.
  • Always use  camel casing while declaring variable. ex: var alienCoders = "http://www.aliencoders.org"
  • Variable names must begin with a letter or the underscore character. ex: 123goAhead is wron
  • JavaScript variable can be created or declared by using reserved keyword "var". ex: var x=100; var carName="Mercedes Benz";
  • If you redeclare a JavaScript variable, it will not lose its original value unless and until you changed its value. var x=5; var x; After execution of these statements value of x will be still 5 only.
  • JavaScript is smart enough to understand the data type of variable just by its declared value. Ex: var x=5; (datatype is int) var y = "Me"; (string)
  • = is used for assignment and + is used for addition of two numbers or two strings. ex: var x=5; var y = 2+5 ; (o/p will be y =7) var place = "New "+"Delhi"; (o/p will be "New Delhi")

We will post about operators and data types very soon!

Uncategorized

5 Important rules to start with JavaScript

At first sight, JavaScript looks very simple language. But if you don't follow unobtrusive and OO pattern then you will treat it as one of the weird browser languages. But in today's world you can't make good websites without the help of JavaScript. Either you use Dojo, JQuery, ext js , moo tools or any JavaScript based plug-ins , you would require fair knowledge of JavaScript. Apart from keeping in mind while using  namespace, global and local variables. We should follow  these 5 simple rules (in no order and there can be many rules as per the programmer), we can improve JavaScript coding:

1. Do not make any assumptions about JavaScript features

Probably the most important feature of unobtrusive JavaScript is that you stop making assumptions:

  • You don't expect JavaScript to be available but make it a nice-to-have rather than a dependency
  • You don't expect browsers to support certain methods and have the correct properties but  test  them before you access them
  • You don't expect the correct HTML to be at your disposal, but check for it and do nothing when it is not available
  • You expect other scripts to try to interfere with your functionality and keep the scope of your scripts as secure as possible. use local variable and namespace properly

The first thing to consider before you even start planning your script is to look at the HTML code that you are going to enhance with scripting and see what you can use for your own purposes.

 2. Find your hooks and relationships (HTML, the base to build on)

Before you start your script look at the base that you build upon. If the HTML is unstructured , there is hardly any way to create a clever scripting solution

There are several things to consider in your HTML – hooks and relationships

 HTML Hooks

HTML hooks are first and foremost IDs, as these can be accessed with the fastest DOM method – getElementById. These are safe as IDs are unique in a valid HTML document (IE has a bug with name and ID, but good libraries work around that) and easy to test for.

Other hooks are HTML elements which can be read out with getElementsByTagName and CSS classes, which can not be read out with a native DOM method in most browsers (Mozilla will soon have one and Opera 9.5 already does though). However, there are a lot of helper methods that allow for a getElementsByClassName.

 HTML relationships

The other interesting thing about HTML is the relationships of your markup. Questions to ask yourself are:

  • How can I reach this element the easiest and with the least steps traversing the DOM?
  • What element do I need to alter to reach as many child elements that I need to change?
  • What attributes or information does a certain element have that I can use to link to another?

Traversing the DOM is expensive and can be slow, that is why it is a good idea to leave it to a technology that is already in use in browsers.

 3. Leave traversing to the experts (CSS, the faster DOM traveller)

It is pretty interesting that DOM scripting and traversing the DOM with its methods and properties (getElementsByTagName, nextSibling, previousSibling, parentNode and so on) appears as a confusing matter to a lot of people. It is interesting as we already do it with a different technology: CSS.

CSS is a technology that takes a CSS selector and traverses the DOM to access the desired elements and change their visual attributes. A rather complex JavaScript using DOM can be replaced with a single CSS selector:

var n = document.getElementById('nav');
if(n){
var as = n.getElementsByTagName('a');
if(as.length > 0){
for(var i=0;as[i];i++){
as[i].style.color = '#369'; as[i].style.textDecoration = 'none'; }
}
}

/* is the same as */

#nav a{ color:#369; text-decoration:none; }

 4. Understand Events (Event handling to initiate change)

Event handling is the next step to truly unobtrusive JavaScript. The point is not to make everything draggable and clickable or add inline handling. The point is to understand that Event Handling is true separation. We separate HTML, CSS and JavaScript but with Event Handling we go much further.

Elements in the document are there to wait for handlers to listen to a change happening to them. If that happens, the handlers retrieve a magical object (normally as a parameter called e) that tells them what happened to what and what can be done with it.

The really cool thing about most event handling is though that it does not only happen to the element you want to reach but also to all the elements above it in the DOM hierarchy (this does not apply to all events though – focus and blur don't do that). This allows you to assign one single event handler to for example a navigation list and use event handling's methods to reach what element was really involved. This technique is called event delegation and it has several benefits:

  • You only need to test if a single element exists, not each of them
  • You can dynamically add or remove new child elements without having to remove or add new handlers
  • You can react to the same event on different elements

The other thing to remember is that you can stop events from being reported to parent elements and you can override the default action HTML elements like links have. However, sometimes this is not a good idea, as browsers apply them for a reason. An example would be links pointing to in-page targets. Allowing for them to be followed makes sure that users can bookmark the state of your script.

 5. Work for the next developer (Making maintenance easier)

The last step to make your script truly unobtrusive is to give it another go-over when you finished and think about the next developer who has to take over from you once this went into production. Consider the following:

  • Are all the variable and function names logical and easy to understand?
  • Is the code logically structured? Can you "read" it from top to bottom?
  • Are the dependencies obvious?
  • Have you commented areas that might be confusing?

The most important bit is to understand that the HTML and CSS of a document is much more likely to change than the JavaScript (as these make up visual output). Therefore it is a great idea not to have any class and ID names or strings that will be shown to the end user buried somewhere in the code but separate it out into a configuration object instead.

myscript = function(){
   var config = {navigationID:'nav', visibleClass:'show'};
   var nav = document.getElementById(config.navigationID);
   function init(){
      show();
      if(nav.className === config.visibleClass){ reset(); } // do stuff
   }
   function show(){
     var c = nav.className; // do stuff
   }
   function reset(){
   // do stuff
   };
}();

That way maintainers know exactly where to change these without having to alter the rest of your code.

Source: http://icant.co.uk

Uncategorized

IT Security Threats for 2011 by McAfee

2011 will be much like 2010 when it comes to IT security threats, only more so.

“We are seeing an escalating threat landscape in 2011,” says Dmitri Alperovitch, threat research vice president at McAfee Labs, which Tuesday issued its annual threat predictions for the coming year.

In an interview with Information Security Media Group, Alperovitch explains the challenges these threat present and how individuals and organizations can address them. The threats McAfee Labs identifies for 2011 are:

5 essential Multimedia players for windows users

Whatever be your profession, it doesn’t matter how busy you are in your life. You will listen songs, watch movies for sure and computer plays an important role for such entertainment stuffs always.
You must be using any one of your favorite Multimedia player to play songs, watch movies, video tutorials, etc. So which player is your favorite one?  Mine is all time favorite KMplayer.
5 Multimedia players that I have are  (Ranks may differ person to person):
1. KMPlayer  

  1. First things its free and plays almost any video formats at its best. Takes very less space and runs audios/videos hassle free.
  2. Keyboard shortcuts make it very easy and comfortable to use. Its very user friendly too.
  3. The KMPlayer is a versatile media player which can cover various types of container format such as VCD, DVD, AVI, MKV, Ogg Theora, OGM, 3GP, MPEG-1/2/4, WMV, RealMedia, and QuickTime among others.
  4. It handles a wide range of subtitles and allows you to capture audio, video, and screenshots in many ways.
  5. Click here to download.   For more details about it, read our previous article on it.

2.   vlc logo VLC Multimedia Player

  1. It is also open source and latest VLC player also plays almost everything. But its not so user friendly like KMPlayer. After using it for few days, you may be habituated for it too.
  2. VLC comes with nearly every codec built in, so no need to update for codecs.
  3. It plays damaged files too! Which means Missing or broken pieces won’t stop VLC to play undamaged part of it.
  4. Its available for all Operating Systems which makes it most popular all over the computer users.
  5. You can download VLC Player from here.

3.  real player logo Real Player

  • a. If you use internet to watch videos, downloads audio/video files from youtube, apniisp etc then You might need Real Player too!
  • b. Very few players supports .rmvb.  It plays .flv, .mpeg, .avi and other various formats too
  • c. Real player is also available in all O.S. flavors and its available for free and for premius use too (paid one)
  • d. You can download videos, share through FB, youtube, twitter and can burn too!
  • e. For more details and to download this player Visit here

4.  wmp logo Windows Media Player

  • a. Most computer users would have windows Operating system by default and it contains WMP already. So people get used of it. WMP 11 is really cool and has really all features that other media players have.
  • b. A tree-style file directory makes it easy to find the music you want quickly, and a simple search box gets you where you want to go immediately.
  • c. A five-star rating system lets you rate your music, then organize it by rating, so it's easy to group your favorite songs
  • d. Download it for free from here

5.  bsplayer logo BS Player/Winamp/Jukebox

  1. I have used winamp, jukebox and BS Player too. BS Player is the newest one and winamp is all time favorite for listening audio songs.
  2. Winamp is available for android too. Its skin, and playing features can attract anyone to have it in their system.
  3. Download Winamp from here
  4. BSPLayer is very light, so don’t take much CPU space, downloads and saves subtitles automatically. Plays high resolution video smoothly. HD Laptop users should have it .
  5. Download BSPlayer from here.
Uncategorized

Top 10 Programming language of year 2010

It is always important for the IT people to know that:

1.       Which language is rising exponentially?

2.       Which language is in high demand?

3.        By having knowledge of which language we can grab more job opportunity?

4.       Which one is the highest paying language in your country?

And many more Just like ever year Tiobe has done complete survey and displayed the result for top 10 programming languages of 2010 and have compared from previous year.  Just have a look over it.

Internet Explorer is found vulnerable again

A vulnerability has been identified in Microsoft Internet Explorer, which could be exploited by remote attackers to take complete control of a vulnerable system. This issue is caused by a use-after-free error within the “mshtml.dll” library when processing a web page referencing a CSS (Cascading Style Sheets) file that includes various “@import” rules, which could allow remote attackers to execute arbitrary code via a specially crafted web page.