Skip to content
Jun 11 / Yaswanth

3 Years In ReadiMinds :)

Yes, I have completed 3 long Years with ReadiMinds yesterday. The best and fun part of working here has always been the friends.

Also, congratulations to Sagar Gadde and  Govind Ashrit (ReadiMinds RockStar)  who completed 5 and 3 years with ReadiMinds this week.

Will post more on my experiences with ReadiMinds later. Soon :shock:

Thanks to All.

May 21 / Yaswanth

Breaking Singleton

Singleton can be broken by using Reflection and the below code demonstrates the same.

Singleton Class

package com.test.singleton;

public class Singleton {

	private static Singleton singleton  = null;

	private Singleton() {
		System.out.println("Running Constructor......");
	}

	public static Singleton getInstance(){
		if(singleton==null)
			singleton  = new Singleton();
		return singleton;
	}

}

Test Class

package com.test.singleton;

import java.lang.reflect.Constructor;

public class SingletonBroken {

	public static void main(String[] args) throws Exception  {
		Singleton instance1 = Singleton.getInstance();
		Class singletonClass = Singleton.class;

		Constructor constructor = singletonClass.getDeclaredConstructor();
		constructor.setAccessible(true);

		Singleton instance2 = (Singleton) constructor.newInstance();
	}

}

Output :

Running Constructor……
Running Constructor……

Now we know that our Singleton Class is no more a Singleton :( . One may need to handle this. This can be avoided by denying the ReflectPermission to the program, but this will fail many API’s (Spring, Hibernate .. ) which requires reflection to work. Another way of avoiding this is to handle ourselves in the constructor so that the constructor throws exception if an instance already exists.

Modified Singleton Class – Throws Exception

package com.test.singleton.exception;

public class Singleton {
private static Singleton singleton  = null;

	private Singleton() throws Exception {
		if(singleton!=null)
			throw new IllegalAccessException("Instance Already Exists !");
		System.out.println("Running Constructor......");
	}

	public static Singleton getInstance() throws Exception{
		if(singleton==null)
			singleton  = new Singleton();
		return singleton;
	}
}

Output :

Running Constructor......
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at com.test.singleton.exception.SingletonTest.main(SingletonTest.java:16)
Caused by: java.lang.IllegalAccessException: Instance Already Exists !
	at com.test.singleton.exception.Singleton.(Singleton.java:8)
	... 5 more

Now our application throws error if the constructor is invoked more than once.
Objenesis will even bypass the constructor code. so all the above things will not work.

Nov 26 / Yaswanth

Talks Hans Rosling: Asia’s rise — how and when

Hans Rosling was a young guest student in India when he first realized that Asia had all the capacities to reclaim its place as the world’s dominant economic force. At TEDIndia, he graphs global economic growth since 1858 and predicts the exact date that India and China will outstrip the US.

Link to the Original Post : http://www.ted.com/talks/hans_rosling_asia_s_rise_how_and_when.html

Apr 17 / Yaswanth

Enable / Disable Task Manager

There is a registry hack to enable or disable Task Manager.

Hive: HKEY_CURRENT_USER
Key: Software\Microsoft\Windows\CurrentVersion\Policies\System
Name: DisableTaskMgr
Type: REG_DWORD
Value: 1=Enable this key, that is DISABLE TaskManager
Value: 0=Disable this key, that is Don’t Disable, Enable TaskManager.

If you are an Administrator you can consider  using Group Policy Editor. For that,

  • Click Start
  • Click Run
  • Enter gpedit.msc in the Open box and click OK
  • In the Group Policy settings window
    • Select User Configuration
    • Select Administrative Templates
    • Select System
    • Select Ctrl+Alt+Delete options
    • Select Remove Task Manager
    • Double-click the Remove Task Manager option

Since the policy is Remove Task Manager, by disabling the policy, you are enabling the Task Manager.

FYI: You can run registry editor with command regedit.

Dec 31 / Yaswanth

Happy New Year !!

May this New Year bring newly found prosperity, love, happiness and delight in your life !!

Enjoy !!

Nov 12 / Yaswanth

A Cool Trick – Change your PC Processor

This trick is really cool !

Goto START>RUN>type REGEDIT

Then goto HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor

On right hand side double click on processorNameString and write what ever you want.

Now check for the modified information in Computer Properties.

Sep 28 / Yaswanth

How an Mechatronics – Engineer will commit suicide????

Hi Friends the picture i am posting here is from the mail which i received some time back from one of my friend. (I really Enjoyed this , Hope you also like this !).

You can see how intelligent is the Mechatronics Engineer in committing suicide(Of course i am !).

Mechatronics - Engineer commit suicide????

Cheers !!

Sep 26 / Yaswanth

Place Windows Kernel into RAM – Registry Hacks to Speed Up XP

It’s a given that anything that runs in RAM will be faster than an item that
has to access the hard drive and virtual memory. Rather than have the kernel
that is the foundation of XP using the slower Paging Executive functions,
use this hack to create and set the DisablePagingExecutive DWORD to a
value of 1.
Perform this hack only if the system has 256MB or more of
installed RAM!
Edit the Registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
Control\Session Manager\Memory Management\DisablePagingExecutive to 1 to
disable paging and have the kernel run in RAM (set the value to 0 to undo
this hack). Exit the Registry and reboot.
Sep 19 / Yaswanth

An extension failed to initialize. Can’t open file extend.dat

Today out of the blue, when loading office 2003 on an xp machine, an error message appeared with the text:

“An extension failed to initialize. Can’t open file: extend.dat. The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click Properties to check your permissions for the folder. You don’t have appropriate permissions to perform this operation.”

Being me an administrator it seemed more complicated than a permission problem. What is the extend.dat file? It is a file used to cache extensions built for outlook. The problem with the file could be fixed by either deleting it or renaming it.

If hidden files and folders are not visible you will have to set your explorer window to view those types of files. If you know how to show hidden files skip “Viewing Hidden Files”.

Viewing Hidden Files: To view folders and files that are hidden, from my computer, click tools and then folder options. Click the view tab at the top of the window. Scroll down to the option Hidden files and folders. Click the option that says show hidden files and folders. Then click OK.

The Fix: Make sure outlook is closed and not running. If you are viewing hidden files and folders, use windows explorer to go to documents and settings, then the folder of the user with the error. Next click Local Settings, then Application Data, then Microsoft, and finally click and go into the outlook folder. There is where you will find extend.dat. Now from here rename the file from extend.dat to extendOld. Restart outlook and send someone an email.

Tip : To do this in my style just type the below line at your command prompt but make sure you close outlook first

del “%userprofile%\local settings\application data\microsoft\outlook\extend.dat”

Aug 24 / Yaswanth

Secure your system :: Ctrl + c

Using “Ctrl+c” to copy sensitive data when you are connected to net is stored in clipboard and is accessible from the net by a combination of JavaScript’s and ASP.

It’s better to avoid keeping sensitive data (like credit card numbers, bank login/passwords, PIN, date of births, etc.) in the clipboard while surfing the web.

Meanwhile using some simple steps you can disable a third person accessing your sensitive data

Follow the below given steps.

1. In Internet Explorer, go to Tools -> Internet Options -> Security

2. Click on Custom Level

3. In the security settings, click to disable the “Allow Paste Operations via Script .”(In IE6 or lesser versions) or “Allow Programmatic clipboard Access”(In IE7,IE8). That will keep your clipboard contents private