Lets share love

How ? copy url of this blog and share in your social network :) simple

Lets share love

How ? copy url of this blog and share in your social network :) simple

Sunday, September 14, 2014

You have a birthday cake and have exactly 3 cuts to cut it into 8 equal pieces. How do you do it?

The answer: stack the pieces

The “correct” answer is to cut the cake in quarters (4 pieces) using 2 of the cuts – one horizontally down the center of the cake and the other vertically down the center of the cake. This will leave you with 4 pieces (or slices) of cake. Then, you can take all 4 pieces and arrange them in a stack that is 4 pieces high. Finally, you can just cut that stack of 4 pieces in half – using your third and final cut – and then you will end up with 8 pieces of cake!
You might think of this as sort of a trick question, since moving the pieces is something “out of the box” – but somebody asking this question is probably looking for that kind of out of the box thinking.

## copied :) 

Thursday, September 11, 2014

how to zip a folder


have you ever wondered how to zip a folder . many just wonder :p try this :) 


Tuesday, September 9, 2014

Spring security logout

put this anywhere :)

<form name="submitForm" method="POST" action="${createLink(controller: 'logout')}">
<input type="hidden" name="" value="">
<a HREF="javascript:document.submitForm.submit()">Logout</a>
</form>

The webpage has redirect loop . Grails Spring Security Core RC4 error

Here while installing and implementing new Spring Security Core RC4 i faced following problems:


and in console 

In console you will see that it will not find SecRoleSecUser table and webpage will get looped :

 If you are using requestmap to handle your access level you have to place following
code in bootstrap.groovy

 new Requestmap(url: '/home', configAttribute: 'ROLE_ADMIN').save()
        new Requestmap(url: '/*', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();
        new Requestmap(url: '/logout/**', configAttribute: 'IS_AUTHENTICATED_REMEMBERED,IS_AUTHENTICATED_FULLY').save();
        new Requestmap(url: '/login/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
        new Requestmap(url: '/index/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();


how to change default home page in grails

class UrlMappings {

static mappings = {
        "/$controller/$action?/$id?(.$format)?"{
            constraints {
                // apply constraints here
            }
        }
        "/login/$action?"(controller: "login")
        "/logout/$action?"(controller: "logout")

        "/"
                {
                    controller = "Home"
                }
        "500"(view:'/error')
}
}


the main difference is the orange shadowed line :) 

Monday, September 8, 2014

how to change port to run grails app

put this line in buildconfig.groovy

grails.server.port.http = 8888

8888 is the port that u want grails app to run on

note:

0 to 9999

There are total 65535 ports in a computer, in which 1024 ports are well known ports.

Wednesday, September 3, 2014

Heap size and Perm size

The GC document on Sun's site showed the Perm generation to be part of the Heap size. It seems that the Perm size is

different from the Heap size.The total memory used by the JVM process will be = Memory used by the JVM for internal management + memory allocated in native code + memory allocated for the permanent space.
This is the memory that U see in Task-Manager in Windows or 'top' on Solaris.

A quick definition of the "permanent generation":

"The permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These

reflective objects are allocated directly into the permanent generation, and it is sized independently from the other

generations."

In other words, this is where class definitions go (and this explains why you may get the message OutOfMemoryError:

PermGen space if an application loads a large number of classes and/or on redeployment).



Java's  Heap Size

Java has a couple of settings that help control how much memory it uses:

-Xmx sets the maximum memory heap size
-Xms sets the minimum memory heap size.

Keep -Xms Small

For a server with a 'small' amount of memory, then we recommend that -Xms is kept as small as possible.  e.g. -Xms 16m.

Some  set this higher, but that can lead to issues.  e.g. the command that restarts tomcat runs a java process.

That Java process picks up the same -Xms setting as the actual Tomcat process.  So you will effectively be using two times

-Xms when doing a restart.  If you set -Xms too high, then you may run out of memory.

Don't Let -Xmx Be Too Low

When setting the -Xmx setting you should consider a few things...  -Xmx has to be enough for you to run your app.  If it is set too low then you may get Java OutOfMemory exceptions (even when there is sufficient spare memory on the server).

If your application is throwing an OutOfMemoryError then it could be because the PermSize is full, rather than the heap size. HERE IS ANOTHER POST TO SOLVE THIS PROBLEM


How do I properly set the permgen size?

Two ways to solve perm gen (out of memory ) problem.

1.

 You have to change the values in the CATALINA_OPTS option defined in the Tomcat Catalina start file. To increase the

PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.

Linux :
Open Catalina.sh file placed in the "bin" directory. You have to apply the changes to this line

CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"

Windows:

Open the "Catalina.bat" file placed in the "bin" directory

set CATALINA_OPTS=-server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m


2.
You can use any text editor to create the file. Make sure that it is syntactically a valid Window batch script. Most of

the time, you would just set environment variables in this file.

For example:

set JAVA_HOME=C:\path\to\java\home
set CATALINA_OPTS=-Xmx2G -Xss256k

As a note, you only want to use the setenv.bat file if you are running Tomcat from the console (something that is done rarely). In most cases, you'll be running as a Windows Service. If you are running as a Windows Service then you don't want to use setenv.bat. Instead, you'll want to use the Tomcat GUI application to make configuration changes.

NOTE:
but it must be said that if you have a fundamental memory leak in your app, it probably doesn't matter how large you set the heap - you'll still run out off memory

Tuesday, September 2, 2014

Khudi ko kar buland itna ke har taqder se pehle Khuda bande se ye poche bata teri raza kia hai


Khudi ko kar buland itna ke har taqder se pehle
Khuda bande se ye poche bata teri raza kia hai

Monday, September 1, 2014

How to change password of mysql in xampp

You will need this many times :)

1. First of all open the control panel of xampp and click on config of Apache . You will find config.inc.php file of phpmyadmin.  this will open you a txt file. Then search for password. 

this will open you a txt file. Then search for password. 


2.now open command prompt and write as following :



then you have to execute following query