mardi 25 juin 2013

Wicket: Get Request Parameter from URL

In case you want to retrieve a value from the URL  , you can simply do it with Wicket 1.5  with one line of code :

StringValue game = RequestCycle.get().getRequest().getRequestParameters().getParameterValue("game");

there is also a several  paramters you can retrieve from URL like : 
  1. getClientUrl()
  2. getOriginalUrl()
  3. getUrl()
keep it simple,keep it clean  :)

Wicket PageParameters example

In Wicket 1.5 , you can use “PageParameters” class to store parameters values and pass it to another page. this is how you can do it :
first you should set your page parameters before redirection to be able then to receipt them in destination page

  @Override
  protected void onClick() {
 
   PageParameters pageParameters = new PageParameters();
   pageParameters.add("game", "Tombe Raider");
   setResponsePage(game.class, pageParameters);
 
  }

the next step is to capture these parameters into a method of destination page as follow :
String gameValue = pageParameters.get("game").toString();

that all :) !

Freeing up a TCP/IP port



Usually when using tomcat server the following exception will be handled :

Several ports (8005, 8080, 8009, 8443) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).



To resolve this exception you need to free the TCP/IP ports that are already on 'LISTEN' state.
you'll have to kill all processes that are listening on that port. The easiest way to do that would be to use the fuser(1) command. For example, to see all of the processes listening for http requests on port 8080 (run as root or use sudo):


netstat -ln | grep ':8080 ' | grep 'LISTEN'



If you want to kill them, then just add the -k option.


fuser -k 8080/tcp
fuser -k 8443/tcp
fuser -k 8005/tcp
fuser -k 8009/tcp

dimanche 23 juin 2013

How to git ignore files that are already tracked

for all people who use  eclipse , they always don't want to track some kind of files like (.properties,.metadata ...) that are automatically created by eclipse .
also the other problem is that git will not ignore a file that was already tracked before a rule was added to the file  .gitignore to ignore it 

So what is the Solution ?

In such a case , you should follow these two steps :
    1. files must be un-tracked, usually with 
      git rm --cached filename
    2. now they do not show up as "changed" but still show as untracked files in git status , so add some  exclude rules into .git/info/exclude  file in your repository
       
In case of Eclipse ,  do these two steps  to completely remove files and repositories from being tracked :
  1. execute this script after git add . :
    git rm --cached *.pydevproject
    git rm --cached *.project
    git rm --cached *.metadata
    git rm --cached */bin/**
    git rm --cached */tmp/**
    git rm --cached *.tmp
    git rm --cached *.bak
    git rm --cached *.swp
    git rm --cached *~.nib
    git rm --cached *local.properties
    git rm --cached *.classpath
    git rm --cached *.settings/*
    git rm --cached *.loadpath
    git rm --cached *org.eclipse.wst.common.component
    git rm --cached *org.eclipse.wst.common.project.facet.core.xml
    git rm --cached *.properties
    git rm --cached *.orig
    git rm --cached *.classpath
    git rm --cached *.xml
    git rm --cached *.jar
    git rm --cached *.class
    

  2. add this code to .git/info/exclude  file in your repository
    # git ls-files --others --exclude-from=.git/info/exclude
    # Lines that start with '#' are comments.
    # For a project mostly in C, the following would be a good set of
    # exclude patterns (uncomment them if you want to use them):
    # *.[oa]
    # *~
    
    #Eclipse#
    ###################
     
    *.pydevproject
    *.project
    *.metadata
    */bin/*
    */bin/
    */tmp/**
    *.tmp
    *.bak
    *.swp
    *~.nib
    *local.properties
    *.classpath
    *.settings/*
    *.settings/
    *.loadpath
    *org.eclipse.wst.common.component
    *org.eclipse.wst.common.project.facet.core.xml
    *.properties
    *.orig
    *.classpath
    *.xml
    
    # Package Files #
    ##################
    *.jar
    *.war
    *.ear
    
    # Compiled source #
    ###################
    *.com
    *.class
    *.dll
    *.exe
    *.o
    *.so
    
    # Packages #
    ############
    # it's better to unpack these files and commit the raw source
    # git has its own built in compression methods
    *.7z
    *.dmg
    *.gz
    *.iso
    *.jar
    *.rar
    *.tar
    *.zip
    
    # Logs and databases #
    ######################
    *.log
    *.sqlite
    
    # OS generated files #
    ######################
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    Icon?
    ehthumbs.db
    Thumbs.db
    
These rules are not committed with the repository so they are not shared with others. This method can be used for locally-generated files that you don't expect other users to generate, like files created by your editor.

for more informations visit the official github site.



I hope that this sample tutorial can help someone else :)

vendredi 21 juin 2013

How to install amd drivers on Debian ubuntu


Some People can have problems after installing amd drivers and after viewing the specific error log file we see this error :

    "one or more tools for installation cannot be found on the system. install the required tools before installing the fglrx driver. Optionally, run the installer with --force option to install without the tools. Forcing install will disable AMD hardware acceleration and may make your system unstable. Not recommended. see log for details."


So to fix this error you just need the headers for your kernel. Run the following to install them:
sudo apt-get install linux-headers-$(uname -r)

after these step , you are able now to install your amd driver . 
I hope this can help you :)

jeudi 20 juin 2013

How install LaTex with Apt-Get (Debian)


Get Request parameters with Wicket 1.5.x




To get the current request parameters (for example in Ajax behavior processing) in Apache Wicket 1.4:
    String parameterValue = RequestCycle.get().getRequest().getParameter(parameterName);
In 1.5 you have a better control where the parameter comes from:
   // GET request
   StringValue parameterValue = RequestCycle.get().getRequest().getQueryParameters().getParameterValue(parameterName);

   // POST request
   StringValue parameterValue = RequestCycle.get().getRequest().getPostParameters().getParameterValue(parameterName);

Or if you don't care about the method:
   StringValue parameterValue = RequestCycle.get().getRequest().getRequestParameters().getParameterValue(parameterName);