Author Archives: cyberaka

About cyberaka

I am an experienced Senior Solution Architect with proven history of designing robust and highly available Java based solutions. I am skilled in architecting designing and developing scalable, highly available, fault tolerant and concurrent systems which can serve high volume traffic. I have hands on experience in designing RESTful MicroServices architecture using Spring Boot, Spring Cloud, MongoDB, Java 8, Redis and Kafka. I like TDD (JUnit), BDD (Cucumber) and DDD based development as required for my projects. I have used AWS primarily for cloud based deployment and I like developing cloud enabled POC as a hobby in my spare time. I have deigned and developed CI/CD pipeline using Jenkins and leveraged Docker, Kubernetes for containerizing and deploying some of my applications. I am highly experienced in creating high performing technical teams from scratch. As an ex-entrepreneur I am very much involved in the business side of the IT industry. I love interacting with clients to understand their requirements and get the job done.

Integrating Jenkins (Debian) with BitBucket

The Jenkins CI server can be integrated with BitBucket by using the concept of deployment keys. In BitBucket go to Settings > Deployment Keys. Add a new public key. Make sure you are adding an openssh compatible public key otherwise the key won’t be accepted. Once this is done you need to test the read-only cloning capability using this approach.

ssh-agent (ssh-add /home/user1/ssh_keys/my_private_key; git clone git@bitbucket.org:my_user/my_project.git)

This command basically attempts to make a clone from the BitBucket server using the private key you specified as ‘my_private_key’. Since we are using the ssh-agent command to wrap the other two commands the key is loaded, the clone command is executed and then immediately the key is unloaded. If your cloning process failed you know that something is wrong. Remember you need the private key in openssh format as well.

If the above command gave you the cloned repository, go ahead and use this private key inside the Jenkins server.

Please do refer to BitBucket documentation link has more details on the exact steps.

Jenkins Configuration Issue

I was trying to setup Jenkins web app inside the Tomcat server and it continuously gave me this error:

SEVERE: Failed to initialize Jenkins
hudson.util.NoHomeDir

This I fixed by creating the folder ‘/usr/share/tomcat7/.jenkins’

mkdir /usr/share/tomcat7/.jenkins

On redeploying Jenkins I again noticed the following error.

WARNING: Failed to record boot attempts
java.io.FileNotFoundException: /usr/share/tomcat7/.jenkins/failed-boot-attempts.txt (Permission denied)

I fixed this issue by giving full access to this folder.

sudo chmod 777 /usr/share/tomcat7/.jenkins

I believe 777 is not a good approach in a production environment, but for development perspective it looks ok.

Completely removing packages in Debian Linux

I recently had to find out if a particular package was properly installed in my Debian Linux OS as something was broken. I used the following command to do that.

dpkg --get-selections | grep -v deinstall | grep oracle

This basically lists out all the packages which contain the text ‘oracle’ in them. Once I find out the exact package name I can actually decide to remove all packages containing them.

sudo apt-get purge oracle*
sudo apt-get autoremove oracle*

Showing a running clock in a linux shell

I was working with a scheduler and wanted to keep track of my server time. Continuous invocation of date command wouldn’t cut it. So a little search on net lead me to this link which basically sums up the following script. This script will show the current time on the top left corner of your terminal which is good enough for my usecase.


while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-11));echo -e "\e[31m`date +%r`\e[39m";tput rc;done &

I executed this code on a Cent OS system and it worked fine. I have tested this snippet in Debian as well and it worked like a charm. This won’t solve everybody’s problem but for specific situation where you just want to watch the clock of your server from a shell this is a good enough script.

Synergy for Multi-Computer Control

I have to work with Windows, Linux and Macbook environment and with time I have no issues working with all of these environments simultaneously. What used to irk me the most was the need to physically use multiple keyboards and mouse and control my Windows laptop and Macbook. Doing VNC / Remote Desktop into another computer didn’t cut it. So I found out about Synergy project long time ago. This is a free and open source keyboard/mouse sharing solution.

Basically the computer whose keyboard/mouse you want to use becomes the Synergy server and all other laptops / computer would become Synergy client. It is very easy to setup and once it is done I can use the keyboard / mouse of of my Macbook to control my windows laptop as well as Linux laptop simultaneously.

Detecting Java Processes listening on local ports

We can use the jps command that is part of JDK to find out which Java processes are running in the current user’s session. We can further find out which network ports have been opened by a particular java process.

Use the follwing command to list all java processes:
jps -l

If you want more details about a process you can execute the following command:
jps -v | findstr <process id>

The following variant of netstat command lists all the listening as well as established socket connection in a system:
netstat -ano

This command can be further used to find out what sockets are opened by a specific process
netstat -ano | findstr <process id>

Subversion Branch and Trunk Sync – Hands On

Subversion has got concept of branches and trunk. Usually the accepted approach is to keep the trunk stable and do all unstable work on the branch. I am going to document how you can create a branch from a workspace using the trunk of a subversion repository. Further I will show how to pull changes done on the branch back into the trunk and vice-versa.

Please replace the localhost:8443 with your subversion URL, the /svn/cjpcs_repo/trunk with your trunk folder and the /svn/cjpc_repo/branches/temp/abhinav with your intended branch folder.

First we create a branch from a workspace checked out to trunk. In this snippet we are creating a shallow copy of the trunk into a branch.
svn copy https://localhost:8443/svn/cjpc_repo/trunk https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav -m "Created a personal branch for abhinav"

In order to start using the branch we need to checkout the branch into a workspace. In this snippet are checking out the branch into the current folder.
svn checkout https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav .

Now you can make some changes on the branch workspace and commit it. Now we need to merge the changes done on branch into the trunk. So go to the trunk workspace and execute the following command. The first command updates the trunk. The second command pulls in all the changes from the branch into the current workspace. If the merge causes some conflicts you need to resolve it manually.
svn update
svn merge https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav

Now commit the merged changes into the trunk. The first command commits the merges done into the trunk and the second command basically confirms the merge.
svn commit -m "Merging changes from the branch"
svn log

That’s it. Your trunk is updated with the changes done on the branch. The same approach can be applied for updating the branch with all the changes on the trunk. The following short snippet summarizes the commands you should execute in your branch workspace to achieve a sync with trunk. If there are conflicts in the merge you need to resolve that manually.
svn update
svn merge https://localhost:8443/svn/cjpc_repo/trunk
svn commit -m "Merging changes from the trunk"

See hidden files in Mac OS Finder

I like to see all the files in the project folder where I am working. So it is inconvenient not being able to see “.gitignore” and “.git” inside the folder where I have git repository. On a brief lookup of the internet I found this article which proposes two approach of making hidden files visible in finder.

Approach #1: Using Terminal

To show hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

To turn off showing of hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Approach #2: Using an App
Funter is a small app which allows the user to toggle the hidden file visibility on and off at the click of a button which is quite convenient.

What I used?
I preferred the terminal approach as I am fairly comfortable with it and I didn’t want to add a new application into my mac’s start-up and menu bar.