Usman Saleem Java HelloWorld
Powered By
AWS Cloud Computing
WildFly 1.0.0.Final - 1.2.8.Final
JavaServer(TM) Faces 2.2 API - 2.2.11
PostgreSQL 9.4.1
Uzi's Blog - Main
If you are using MSysGit on Windows and love to use git from command line, try it together with this excellent console emulator ConEmu-Maximus5.
mvn archetype:generate -DarchetypeArtifactId=wildfly-javaee7-webapp-archetype -DgroupId=mypackage.myapp -DartifactId=MyWebApp -DarchetypeGroupId=org.wildfly.archetype -DarchetypeVersion=8.2.0.Final
Following code snippet shows how to use Java Preference API with JFilechooser to make it remember last used directory location.

File file = new File("default.xml");
file = selectOutputFile(file);

private static File selectOutputFile(File outputFile) throws IOException {
        //load last selected location from preference
        Preferences prefs = Preferences.userRoot().node(MyClass.class.getName()); //or some other alias we wish to use

        JFileChooser fileChooser = new JFileChooser(prefs.get("LAST_USED_FOLDER", new File(".").getAbsolutePath()));
         //we want to filter xml files by default
        fileChooser.setFileFilter(new FileFilter() {
            public boolean accept(File f) {
                if (f.isDirectory()) {
                    return true;
                String s = f.getName();
                return s.endsWith(".xml");

            public String getDescription() {
                return "*.xml";

        fileChooser.setSelectedFile(outputFile); //can be omitted if required.

        int status = fileChooser.showSaveDialog(null); //or pass JFrame reference

        if (status == JFileChooser.APPROVE_OPTION) {
            outputFile = fileChooser.getSelectedFile();

            if (!outputFile.exists()) {
                outputFile.createNewFile(); //if we are going to write contents, otherwise, raise error or something
            //finally save the folder of selected file in preference
            prefs.put("LAST_USED_FOLDER", outputFile.getParent());
        } else if (status == JFileChooser.CANCEL_OPTION) {
            return null;

        return outputFile;
Following are some useful git setup commands.

Set up a global username to be used for all commits.

git config --global [your username]
Set up a global email to be used for all commits. Note that GitHub can associate multiple emails to your account. GitHub can aggregate statistics regarding your commits if you verify your email(s).
git config --global [your email] 
Set all branches to automatically rebase instead of merge. This produces a cleaner commit tree. This doesn't mean you must always rebase; it's just the way to go unless you have a good reason not to.
git config --global branch.autosetuprebase always	
Ensure that all new branches are set up to track its upstream branch.
git config --global branch.autosetupmerge true
Prevents Git from pushing changes in all matching local branches. It will only push changes in the branch you are currently in.
git config --global push.default current
Tell Git to not treat a file as having been modified if the only change is file mode executable bit. Useful for working on FAT/Windows systems.
git config --global core.filemode false
Improves git status performance considerably on Windows 7 x64
git config --global core.preloadindex true

If JBoss is running as a normal user on port 8080 and 8443 while iptables are set up to forward requests from 80 and 443 to 8080 and 8443 respectively, we may need to provide port redirection in wildfly/undertow configuration so that access to any restricted area automatically forwards to 443 instead of 8443.

From jboss-cli:

You can name socket-binding as per your needs, it doesn't has to be https-redirection.
Just finished moving my blog to Amazon EC2. At the moment, Amazon RDS is hosting the database (in PostgreSQL), while configured Wildfly 8.2 on a EC2 micro instance. This allows a more detailed control of deployment such as ability to serve domain on SSL.

A client recently requested that I get screened for IKM Java 6 test. A quick Google search revealed that their tests are "adaptive" in nature and as you proceed the questions become more and more difficult. Also adding to difficulty that there are more than 1 correct/possible answers and there is negative marking for answering a totally irrelevant option. Following is the snapshot of my result (forwarded by the client).

IKM Java Test

IntelliJ IDEA can be used as a git mergetool. If you have merge conflicts, launching git mergetool will launch IntelliJ IDEA. Following configurations are required in ~/.gitconfig . Update the path to idea.exe accordingly.


[mergetool "ideamerge"]
     cmd = C:/Program\\ Files\\ \\(x86\\)/JetBrains/IntelliJ\\ IDEA\\ 13.1.3/bin/idea.exe merge `cygpath -wa $LOCAL` `cygpath -wa $REMOTE` `cygpath -wa $BASE` `cygpath -wa $MERGED`
     tool = ideamerge


For MSysGit, we need to convert paths using our own script. Create ~/ as

#! /bin/sh                                                                
function wpath {                                                          
    if [ -z "$1" ]; then                                                  
        echo "$@"                                                         
        if [ -f "$1" ]; then                                              
            local dir=$(dirname "$1")                                     
            local fn=$(basename "$1")                                     
            echo "$(cd "$dir"; echo "$(pwd -W)/$fn")" | sed 's|/|\\|g';   
            if [ -d "$1" ]; then                                          
                echo "$(cd "$1"; pwd -W)" | sed 's|/|\\|g';               
                echo "$1" | sed 's|^/\(.\)/|\1:\\|g; s|/|\\|g';           
wpath "$@"                                                                
Then in your ~/.gitconfig

[mergetool "ideamerge"]
cmd = "/c/Program\\ Files\\ \\(x86\\)/JetBrains/IntelliJ\\ IDEA\\ Community\\ Edition\\ 15.0.2/bin/idea.exe" merge `~/ $LOCAL` `~/ $REMOTE` `~/ $BASE` `~/ $MERGED`
 tool = ideamerge

Gruveo is an excellent anonymous Flash/browser based very simple video\audio chat website). Due to some weird bug in Ubuntu 13.10 which doesn't allow to change camera settings on individual website (such as Gruveo) through Flash settings popup, following workaround can be used through Flash's global settings.

Visit Select monitor with the eye tab (5th from the left), scroll down and select required site,, and then click radio button "Always Allow" (see following screenshot). Restart the browser and refresh gruveo again. The video chat is now working.

Recently I switched from Fedora 18 to Ubuntu 13.10 on my personal Acer Aspire V5 laptop (a wrong decision when I bought it - anyways...). There are two annoying issues when using both Fedora and Ubuntu on this laptop

Skype Dark Video Screen issue

Skype works on both Fedora and Ubuntu, however, there is this darn issue of dark video screen. This can be fixed by using guvcview and/or from command line tool uvcdynctrl as discussed by this guy in detail.

To ease up calling uvcdynctrl, you can create a launcher and add it to the dash. Follow this link to create desktop launcher in Ubuntu.

Fn keys Screen Brightness issue

The second issue is that screen brightness doesn't work, neither Fn Brightness (blue Fn - left right keys) nor from System Settings ... Brightness & Lock.

To fix the issue for System Settings, we need to add acpi_backlight=vendor to kernel command line parameter as part of grub config. For Fedora follow similar approach for grub2, following approach works in Ubuntu. Update GRUB_CMDLINE_LINUX in /etc/default/grub then run update-grub and restart.

To make the Fn key work again, try fixing /etc/acpi/ and update KEYS_DIR to KEYS_DIR=/sys/class/backlight/intel_backlight. This will allow Fn scripts to call the correct scripts instead of default values (which doesn't work anymore after using acpi_backlight=vendor). Restart to test it.

P.S. Ubuntu seems to have become more user friendly than Fedora (shh...don't tell my former colleagues back at Red Hat ;-))