Monday, December 12

How to make your computer fast

Well it doesn’t matter that you use Pentium 4 (1.2GHz) Processor.

You still can make your system reasonably fast.


Please note:

This article is for Windows XP.

It’s best to perform in the stage order.

The more deeper you go more small sacrifices you make for the only goal “Performance”, “Performance” and  “Performance”.



Following are the stages below:























Stage 1 : Uninstall unwanted softwares

1.      Open Control Panel -> Add or Remove Programs  

2.      Remove software that are not being used, by clicking Remove buttons



3.       Follow the ‘Next’ button, until the software is successfully uninstalled.



Stage 2 : Free more space in C Drive

1.      Delete unwanted files, only the ones you created, in C drive.

2.      Move all the files, only the ones you created, to some other drives.

Note: Don’t touch any system files or Windows folder or Program Files folder

3.       Whenever installing a program next time onwards, keep the destination folder as d:\Program Files\



Stage 3 : Cleanup the Disk


1.      Right-click on C Drive -> Properties



 


  2.      Click on “Disk Cleanup” button, and then wait for some time till it scans the drive.
 
3.      Mark Tick in all the checkbox to safely delete all unnecessary files, and then click ‘Ok’ button.




 

 


Stage 4 : Increase Virtual Memory

1.      Right-click on ‘My Computer’ -> Properties

2.      Select ‘Advanced’ tab -> Click ‘Settings’ under Performance Section.




 

3.      In ‘Performance Options’ Wizard -> ‘Advanced’ tab
4.      In ‘Virtual Memory’ section -> click on ‘Change’ button.







5.      In ‘Virtual Memory’, select C: drive
6.      Select ‘Custom Size’
7.      Enter Initial size (MB): 2046
8.      Enter Maximum size (MB): 3000 or 4092
9.      Click on ‘Set’ button and then on ‘Ok’ button.



 




Stage 5 : Scan and Clean for Viruses

1.      Full scan your computer using the antivirus.
2.      Delete the entire virus found.


Stage 6 : Disk Defragmenter

1.      Right-click on ‘My Computer’ -> Manage




 


2.      In right menu ‘Computer Management(Local)’ -> ‘Storage’ -> ‘Disk Defragmenter’

3.      Select one drive by drive

4.      Click on the ‘Defragment’ button, it may take some time to defragment the drive.



 






Stage 7 : Remove all applications load at start-up (except the really needed ones)

1.      Start -> Run
2.      Type msconfig and then click ‘Ok’ button.


3.      In ‘System Configuration Utility’ -> ‘Startup’ tab
4.      Unmark the tick on the checkbox of the applications that you installed and don’t use as the system starts.

Reason: When your system starts, all the softwares are sharing the memory at the startup till shutdown, even though it’s not used. So its better remove the applications to load at startup to increase the boot-time and system speed.

5.       Click ‘Ok’ and then ‘Restart’ button




 





Stage 8 : Set your system for “Performance” mode rather appearance.


1.      Right-click on ‘My Computer’ -> Properties

2.      Select ‘Advanced’ tab -> Click ‘Settings’ under Performance Section.



 
 

3.      In ‘Performance Options’ Wizard -> ‘Visual Effects’ tab

4.      Select  “Adjust for best performance” option and then click ‘Ok’ button.

 



Stage 9 : Upgrade your RAM to  minimum 2GB or more.

1.      Upgrade your system physical memory to minimum 2 GB or more.
2.      Check the FSB speed and type of your RAM, it can be found out using a software ‘CPU-Z’.
3.      Download ‘CPU-Z’.
4.      Buy a RAM that matches your FSB and DDR version.


Sunday, October 23

Aspect Oriented Programming ( AOP )


Why is AOP required?
We use Object-Oriented Programming (OOP), Functional-Oriented Programming (FOP) models basically to solve Concerns.

- Concerns like reusability of code in case of FOP.
- Concerns like data access, data integrity, data stability in case of OOP.

Even though we use many techniques in OOP to group and encapsulate the concerns into separate, independent entities by providing abstractions. But some concerns still defy these forms of implementation, and are called crosscutting concerns because they "cut across" multiple abstractions in a program.

Example: Logging

Logging is a crosscutting concern, because a logging strategy necessarily affects every logged part of the system. Logging thereby crosscuts all logged classes and methods.


Now Logging aspect is scattered or tangled as code, making it harder to understand and maintain. It is scattered by virtue of the function being spread over a number of unrelated functions that might use it, possibly in entirely unrelated systems, different source languages, etc. 


To change logging means the effect will be cascading to all the classes where logging is implemented. It would be a huge task to modify the places where the logging is called.



Simple Banking Scenario Example – Transfer money to another account
 
void transfer(Account fromAcc, Account toAcc, int amount , Logger logger)
throws Exception 
{
  logger.info("transferring money...");
 
  if (fromAcc.getBalance() < amount) 
  {
    logger.info("Insufficient Funds, sorry");
    throw new InsufficientFundsException();
  }
  fromAcc.withdraw(amount);
  toAcc.deposit(amount);
  logger.info("Successful transaction.");
 
}



Now consider what happens if we suddenly need to change the logging considerations for the application. In the program's current version, logging-related operations appear scattered across numerous methods, and such a change would require a major effort.



AOP’s Rescue Solution

AOP attempts to solve this problem by defining rules :


  1. To find the places where you need to change the code, and
  2. To suggest what new requirements or functionality you need to add.

These rules are called Aspects.

So now a class or jar file is created, loaded or at runtime, the new functionality that you declared is automatically inserted. The extent of the new implementation is how you have defined the aspect rules.



Example:


In the above logging example, I need to add the time when the logging was created.


@Aspect
public class LoggingAspect {
    @Before("call(void Logger.info(String)) && within(*)")
    public void findtime() {
        Logger.out.print(new java.util.Date());
    }
}

So here we have set the :

1st rule is to find the function [Logger.info()] to be modified.

2nd rule is to specify within which all packages [within(*)] the implementation should be done.

3rd rule is to specify what new functionality is to be replaced with [findtime()].

4th rule is to specify whether the new functionality is to be inserted before or after the code [@Before]. 

Now create a following XML config file in META-INF folder on the classpath.



<aspects>

    <aspect name="LoggingAspect"/>

</aspects>


Benefits

Now after each class is loaded in the server, if it pass the aspect conditions then the new functionality will be automatically inserted.

We can create a central place to change the cross cutting concerns. A change in one place is affected in all code.

Deployment in production server is easy as it requires no modification of production code and no or less downtime.

Thursday, September 1

Beware of the Cheap Tricks of Branded Retail Stores



• Stores are trying everything they can think of to disguise the fact that you're going to pay more for clothes.

• Some are using less fabric and calling it the new look. Others are adding cheap stitching and advertising it as a redesign. Chances are you're not going to think it's worth paying several dollars more for the shirt just to have them.

• Retailers are raising prices on merchandise an average of 10 percent in an effort to offset their rising costs for materials and labor. But merchants are worried whether the customers will buy at price hikes. So, retailers are making inexpensive tweaks—additional stitching, fake button holes, torn edges, fancy tags—to justify price increases. These tweaks can add only pennies to $1 to the cost of a garment, but retailers can charge $10 more for them.

 "Stores are making consumers believe they're getting more for their money."

• Spencer Elmen, owner of Cupid's Lingerie, which operates five stores in Arkansas, said he is seeing more items in his store that are even skimpier than usual, from underwear to mini dresses. He says that's because designers are finding clever ways to conceal the fact that they're clothes have less fabric.

 "They're just being more creative with less fabric," Elmen said.

• Another retailer Abercrombie & Fitch is advertising "Redesigned 2012" Jean Collections in its stores and on its website, touting that the jeans are "softer, with the perfect amount of stretch.". They're also mostly priced between $78 and $88, about $10 more than last year.
• The Wall Street Strategies retail analyst, examined the jeans and believes they are "thinner" and of "cheaper quality." and says “That extra stretch, could simply mean the retailer is saving costs by using less denim”.

See How Politicians are trying to make Anti-Corruption Bill ineffective

The Movement  was on its way before but the sudden spark for the Cause came because of Congress led Government failed to take effective action against  Rs17,000 crore Common Wealth Games scam.

 A citizen's forum called 'India Against Corruption' Movement was started on November 14, 2010 to fight against this government inaction.

Govt drafted a Lokball Bill on 2010 and on seeing the Govt drafted Bill, Santosh Hegde and Prashant Bhushan understood that govt was not interested in making a effective Anti-Corruption Bill, so they formed another Bill, Citizens Bill, or  Indian Peoples Bill,or known to all as  Jan Lokpal Bill.

See the difference between Jan Lokpal Bill  and Draft Lokpal Bill (2010)

Jan Lokpal Bill Draft Lokpal Bill (2010)
Lokpal will have powers to initiate suo motu action or receive complaints of corruption from the general public. Lokpal will have no power to initiate suo motu action or receive complaints of corruption from the general public. It can only probe complaints forwarded by the Speaker of the Lok Sabha or the Chairman of the Rajya Sabha.
Lokpal will have the power to initiate prosecution of anyone found guilty. Lokpal will only be an Advisory Body with a role limited to forwarding reports to a "Competent Authority".
Lokpal will have police powers as well as the ability to register FIRs. Lokpal will have no police powers and no ability to register an FIR or proceed with criminal investigations.
Lokpal and the anti corruption wing of the CBI will be one independent body. The CBI and Lokpal will be unconnected.
Punishments will be a minimum of 10 years and a maximum of up to life imprisonment. Punishment for corruption will be a minimum of 6 months and a maximum of up to 7 years.


After that we all know what happened and how Anna Hazare went to first Fast & Agitation – Phase 1 on April 7th  for govt to accept the Jan Lokpal Bill.




Indeed after lot of protest we know how govt setup a new committee to draft the bill and Look below table to see  how govt came with their version of the new bill on August,2011 as proposed against Jan Lokpal bill.

Issue The Jan Lokpal Bill Government's Lokpal Bill
Prime Minister PM can be investigated with permission of seven member Lokpal bench PM can be investigated by Lokpal after she/he vacates office.
Judiciary Can be investigated, though high level members may be investigated only with permission of a seven member Lokpal bench. Judiciary is exempt and will be covered by a separate "judicial accountability bill".
Conduct of MPs Can be investigated with permission of seven member Lokpal bench. Can be investigated, but their conduct within Parliament, such as voting, cannot be investigated.
Lower bureaucracy All public servants would be included. Only senior officers (Group A) will be covered.
Anti-corruption wing of the Central Bureau of Investigation (CBI) The Anti-corruption wing of the CBI will be merged into the Lokpal. The Anti-corruption wing of the CBI not be merged into the Lokpal.
Removal of Lokpal members and Chair Any person can bring a complaint to the Supreme Court, who can then recommend removal of any member to the President. Any "aggrieved party" can raise a complaint to the President, who will refer the matter to the CJI.
Removal of Lokpal staff and officers Complaints against Lokpal staff will be handled by independent boards set-up in each state, composed of retired bureaucrats, judges, and civil society members. Lokpal will conduct inquiries into its own behaviour.
Lokayukta Lokayukta and other local/state anti-corruption agency would remain in place. All state anti-corruption agencies would be closed and responsibilities taken over by centralised Lokpal.
Whistleblower protection Whistleblowers is a person who tells the court about illegal activities done by the corrupt personnel.

Whistleblowers are protected by Lokpal.




No protection granted to whistleblowers by Lokpal Mahima.
Punishment for corruption Lokpal can either directly impose penalties, or refer the matter to the courts. Penalties can include removal from office, imprisonment, and recovery of assets from those who benefited from the corruption. Lokpal can only refer matters to the courts, not take any direct punitive actions. Penalties remain equivalent to those in current law.
Investigatory powers Lokpal can obtain wiretaps ( to make a connection to a telegraph or telephone wire in order to obtain information secretly), issue rogatory letters, and recruit investigating officers. Cannot issue contempt orders. Lokpal can issue contempt orders, and has the ability to punish those in contempt. No authority to obtain wiretaps, issue rogatory letters, or recruit investigating officers.
False, frivolous and vexatious complaints Lokpal can issue fines for frivolous complaints (including frivolous complaints against Lokpal itself), with a maximum penalty of Rs 100,000. Court system will handle matters of frivolous complaints. Courts can give 2–5 years imprisonment and fines of Rs 25,000 to 200,000.
NGOs NGOs not within the scope due to their role in exposing corruption. NGOs are within the scope and can be investigated.








Friday, July 29

Files and images can be downloaded or uploaded using AJAX

To Download a file

var req = new XMLHttpRequest();
req.open('GET', 'file:///home/user/file.text', false); 
req.send(null);
if(req.status == 0)
  dump(req.responseText);
 
To Download Image (using binary)
function load_image(url) {
  var req = new XMLHttpRequest();
  req.open('GET', url, false);
  req.overrideMimeType('text/plain; charset=x-user-defined');
  req.send(null);
  if (req.status != 200) return '';
  return req.responseText;
}

To upload Image (using binary) 
var req = new XMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader("Content-Length", 741);
req.sendAsBinary(aBody);