Friday, March 31, 2017

Tips: Some common Git commands

- git status

- Revert deleting a file
git reset HEAD <file>

- Checking out
git checkout <branch_or_tag>

- Check the difference between the origin and the remote:
git diff origin/Nightly

- git add
- git add .
- git push origin <branch>
- git commit -a -m "message"
- git checkout <branch>
- git log
- git checkout -- .
- git pull origin
- git cherry-pick <commit_id>
- git reset HEAD~
- git log -p filename

- Hard reset
git reset --hard origin/Nightly

- Clean the untracked files/directories
git clean -f -d

- git fetch --all
- git reset --hard origin/master

Tips: Few common Docker commands and tutorials

- Install docker compose

- List all running containers
docker ps

- List all the running and non-running containers
docker ps -a

- List all images in repository
docker images
docker images -a

- Display the logs
docker logs <container_name>

- Display the current running containers
docker ps -q

- Stop all the running containers
docker stop $(docker ps -q)

- Remove the container
docker rm

- Remove the image
docker rmi

- Can't remove container while it's running. You should stop and then remove

- Docker tutorials

- Starting docker compose
docker-compose up -d

- Stopping docker compose
docker-compose down

Tip: Configure using Meld Diff Viewer for git diff and git difftool

Run the below two commands for configuring Git to use Meld Diff Viewer on Ubuntu Linux:
git config --global diff.tool meld
git config --global difftool.prompt false

Wednesday, July 6, 2016

Back Again, Weekly Readings - Week Ending 8 July 2016

It's been a long long time since I wrote a post here. A lot of changes and obstacles were around but I'm planning to get back to focusing on writing here again. I also have some plans that I'm currently working to present more useful subjects in a more interactive way like going for YouTube videos.
Well, let's warm up and start with sharing some useful readings as articles and books that I have recently checked and I believe they would spot on new subjects or discuss useful ones.

Wednesday, February 17, 2016

Java Code Geeks (JCG) Program

I have recently received an invitation to contribute to Java Code Geeks (JCG) and I accepted that. They currently attract over 900,000 unique visitors per month so this would be exciting to spread some words to the community through them. JCG has started pulling my articles from to and you can find them on my profile page on JCG:
For more about the JCG Program and a complete list of the contributors: 

Saturday, December 19, 2015

JavaOne 2015 Session: EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples by Gohar

I have recently watched my friend Ahmed Nabil Gohar's session at JavaOne 2015. It's really a clear and straight to the point session. I'm sharing with you the sessions details (inluding the YouTube + the presentation downloadable link) as mentioned in his post.
Session ID: CON7535
Session Title: EJB 3.2/JPA 2.1 Best Practice with life examples (Download Link)
Session Type: Conference Session
Session Abstract:
This session’s speaker, an architect, discusses lessons learned from using JPA and EJB to support a high-volume, high-performance applications. These best practices don't only involve JPA/EJB but also its integration with other Java EE 7 technologies. They also include coding best practices, testing and production practices. The presentation focuses primarily on some Key concepts such as persistence context, lazy loading, caching, flushing, dirty checking, transaction and connection demarcation. This is a fast-paced presentation with many code samples. Categories covered include configuration, JPA, concurrency, performance tuning, exception handling and many more.

Friday, December 18, 2015

Creating JSF/CDI Maven project on Eclipse

While I was working on a JSF and CDI example, I thought it would be useful to mention the steps required to create JSF and CDI Maven project. You can find the bellow steps to do so.
  • Eclipse Luna that's shipped with the M2E plugin by default. So no need to install the plugin yourself.
  • WildFlye 8.x.
1- Select from the main menu File->New->Other. Then select Maven->Maven Project.
2- Click the Next button and then check "Create a simple project (skip archetype selection)".
3- Write the Group Id and the Artifact Id then select Packaging as WAR.
4- Click the Finish button to create the project with the bellow structure displayed in the Navigator view.
5- As you can see there is no deployment descriptor file (web.xml) as there is no WEB-INF folder. Also by checking on the Project Facets (select the project then ALT+ENTER then choose from the left menu Project Facets), we can see that the version of the Dynamic Web Module is 2.5 and the JavaServer Faces is not selected. So it's time to do some configurations to our project.
6- Right click on the project name then Configure->Add JSF Capabilities. This will configure the project as JSF project and adds the WEB-INF with the web.xml and the faces-config.xml.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-name>Faces Servlet</servlet-name>
<?xml version="1.0" encoding="UTF-8"?>

7- Adding the necessary API's as dependencies to the pom.xml. Also, adding the maven-compiler-plugin with version 3.1. I have also pointed maven to use the Java compiler version 1.7. So here is the final pom.xml.
<project xmlns="" xmlns:xsi=""

 <name>JSFCDIMavenProject Maven Webapp</name>

8- Now right click on the project name then choose Maven->Update Project to update the project with the newly added configurations.
9- The deployment descriptor (web,xml) has version 2.5 and we are pointing to the servlet 3.1 in our dependency. So as per Java EE 7XML schema, the namespace is changed to be This is the final web.xml after applying that change.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="" xmlns:xsi=""
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-name>Faces Servlet</servlet-name>
10- Check again the Project Facets. You can change the Dynamic Web Module for the version 3.1 and the JavaServer Faces is checked with version 2.2 as per the version added in the dependencies.
11- The last configuration that is needed is enabling the CDI context. This could be done by creating an XML file named beans.xml and add it to the WEB-INF folder as the bellow one.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns=""

12- Finally adding the project to WildFly and then starting the server. You will see in the Console view that WildFly started a service for the CDI deployment to the application.
I have pushed this stub project to my GitHub and you can find it through the bellow URL.