Monday, June 23, 2014

Using screen in Linux.

Saving shell sesions using screen



  1. To start a new session using screen 'screen'
  2. To create new terminal with in screen 'ctrl + a, c'
  3. To switch between terminals in a screen use 'ctrl + a, n' for next, 'ctrl + a, p' for previous.
  4. To detach a screen and return to regular terminal 'ctrl + a, d'
  5. List all the screen sessions 'screen -ls'
  6. Connecting to a detached screen. 'screen -r <screen-name>'
  7. If a session is active and you don't have access to it, try detaching it first and reconnecting.

Thursday, November 7, 2013

Sequences in Oracle.

A Sequences in oracle are always operated in a Atomic operation. (Its very imp to be this way)

How to alter a sequence by advancing it by specified account

DECLARE
temp NUMBER := 0;
BEGIN
FOR idx IN 1..80000 LOOP
select seq.nextval into temp from dual;
END LOOP;
END;
/

Why do you need to do this?
The above statement requires only DML permissions, where as an ALTER statement requires DDL permissions.

Monday, July 22, 2013

Speed Reading

Most people read word by word, and often say the words to themselves using the voices in their heads. Why do we do this? I fully blame kindergarten reading programs, which force children to read out loud both in class and at home. Who thought of this? Anyway, that is not at all the most effective way to read, in terms of both speed and comprehension. Therefore, the first thing you need to do is eliminate the voice inside your head. This took me at least 1 hour to do. Read with your eyes. ONLY. Whatever you do don't use the voice inside your head. As you learn to do this part go ahead and read word by word and go over the lines with your finger. Just work on eliminating the voice. Why? You cannot say words nearly as fast as you can comprehend them, believe it or not. Don't limit your reading speed to your speaking speed. This process really sucks, by the way. If you really believe that the voice in your mind is your enemy, you will probably be extremely frustrated for the first half hour of your journey. You may get better, then get a snack, then come back to continue your training and realize you are back where you started. Feelings of hopelessness will arise. Be a man/woman, and push on. 

A tip for those who are having trouble not subvocalizing is to hold your breath as you read. As Sean O'Connor pointed out, we breathe out as we read, even when we do so silently, since we're used to speaking the words aloud. A lot of the time, you even notice yourself making movements with your mouth, though it's closed. Hold your breath as you begin trying to eliminate subvocalization. Breathe in when you need to. (Don't force discomfort or anything) Once you feel that you've effectively eliminated that voice, try to return to normal breathing. Remember to use breath-holding as a crutch whenever you are having trouble. It has no noticeable effect on your speed or comprehension, and it helps immensely when you are having a rough time. 

Once you are able to pretty much eliminate the voice inside your head, you have unlocked a huge amount of potential in terms of how fast you can now read. Since you're reading with your eyes, try reading two or three words at a time, and then move up once you get comfortable. Trust me, if you don't skip the voice elimination step, you will make progress fast. After a couple days I was reading pages out of an assigned novel within 15-20 seconds, the book wasThe Guide, and with full comprehension. I am not exaggerating. This is when I got really in the zone of course. Not having the initial tunnel vision can be frustrating but after about 10 minutes you get it down and you fly through pages. I was reading about a line at a time. One tip I have that helped me read more words at a time is to think about opening your eyes REALLY WIDE. Actively try to take in as many words at a time as you can and try to move along the lines as fast as you can while doing this. You'll build your own rhythm eventually.

Hopefully this helps someone. It really helped me. I was able to crush estimated hour-long reading assignments in 10 minutes or less. I'm out practice right now, but I want to get back into it this summer so I can complete the books listed on the answer wiki for Books: What are some potentially life-changing books?

P.S. Here's a link (thanks Mike Stenhouse) that teaches you a lot of about speed-reading technique. The explanation it gives encompasses a lot of what I've said, and I found it pretty useful in cleaning up how I read and in increasing my reading ability generally: Scientific Speed Reading: How to Read 300% Faster in 20 Minutes



copied from post on quora..

Tuesday, June 11, 2013

Unit testing in java

1. Make sure to write each tests completely independent of other.
2. Don't depend on the order of execution of the tests and it is not guarenteed.
3. Use mocks for external classes and test logic for only one class at a time.
4. And always verify the mocks to validate execution behavior with expected results.
5. Divide the steps in a test into setup, test, verify sections so that its easy to read.

when using spring-context.xml for spring applications.

@DirtiesContext is useful when it is necessary to re-initialize the auto-wiring of beans so that we make use of fresh copies of beans on each test.
This annotation will make sure that after the test, the new objects are created and injected.

Friday, June 7, 2013

Eclipse setup - useful plugins

Download the latest version of eclipse.
Install the following plugins

1. FindBugs - Static code analysis tool for possible bugs or performance.
2. CheckStyle - Java coding standand suggestions and violation detector
3. Cobertura - Unit test code coverage tool. shows line and branch coverage
4. Eclipse Color themes - Better (may be not) backgroup theme for editors
5. Git - Source Control. this is a must.

And this is the end of the list. feel free to suggest any better tools.

Thursday, May 16, 2013

Mocking a Static Method


import the following:

import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;


Add the following annotations to the class:

@RunWith(PowerMockRunner.class)
@PrepareForTest(Static_Class.class)

public class ClassNameTest

And mock the class with the following Code.

                PowerMock.mockStatic(Static_Class.class);
        expect(
                StaticClass.Static_Method(params)
                .andReturn(mockObject);
        PowerMock.expectLastCall().atLeastOnce();
        PowerMock.replayAll();

Wednesday, May 8, 2013

Use of @Override annotation JDK 1.5 vs JDK 1.6


The JDK version 1.5 doesn't require the Implementing class for an Interface to use @Override annotation for the implemented methods.

Usually when eclipse has the settings to run on JDK 1.6, it adds @Override annotation, as JDK 1.6 allows the use of @Override annotation even for implemented methods from an interface.

Its documented well here.

http://stackoverflow.com/questions/2335655/why-is-javac-failing-on-override-annotation