Sunday, October 26, 2014

Get original hash code of a Object after overriding the equals and hash code methods

When we writing programs, there are some which we override the hash code and the equals method of a object in java. But sometimes, when debugging purposes, we always needs to get the original hash code of a object. This is where we can use interesting method to takeout the actual hash code of the object.

System.identityHashCode(object)

Sunday, October 19, 2014

How to change the logging pattern of Nginx

Some time you may needs to filter out requests and responses coming to Nginx with more details wich requires specify customize log level in Nginx. Assume you may needs to find out the JSESSIONID of a request coming to the Nginx. Here is the way to have the customize log with Nginx.

Specify following logging format in the nginx.conf and refer it in the access log.

log_format   main '$remote_addr - $remote_user [$time_local]''"$request" $status $body_bytes_sent''"$http_referer" "$http_user_agent" - "$http_cookie"';


access_log /var/log/nginx/access.log main;

You will see out put similar to follow.

10.100.5.81 - - [29/Sep/2014:15:44:06 +0530]  "GET /gad_test/index.jsp HTTP/1.1" 200 147 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36" - "JSESSIONID=A2EADE2B419119B8D6184D2B403EC1F1; menuPanel=visible; menuPanelType=main; MSG14119741284050.4971712792784695=true; MSG14119785293260.851528721338783=true; MSG14119793691950.3470202483511987=true; MSG14119793844710.6098322352974117=true; requestedURI=\x22../../carbon/webapp-mgt/upload.jsp?region=region1&item=webapps_add\x22; current-breadcrumb=manage_menu%2Cwebapps_menu%2Cwebapps_list_menu%23webapp-list+webapp_info.jsp*; JSESSIONID=AB2D16E5754D07F20584BBC58119B466"
Also you can enable debug logs of Nginx as follow
error_log path_to_the_log_file debug;

Saturday, October 11, 2014

Find files which don't have a keyword

In our normal day to day activities, we often needs to search for files looking for some keyword. But when you need to search for files which don't have a specific keyword in linux. Below I gave the answer for it. This search for java files which don't have the keyword WARRANTIES. -L flag in grep gives this functionality.

grep -rL "WARRANTIES" --include=*.java  *

Monday, September 2, 2013

11th Week at OpenMRS

This week I mostly work with query view which allows manager to filter out record with given constraints. So after this feature, functionality wise module  works finished.I have small UX improvements as suggest by my mentor. Hope to finish up small UX changes in up coming weeks with documentation about the project.Please find query view UI below.


Monday, August 26, 2013

10th week at OpenMRS

This week has been a busy week for me.But I have managed to finish up the change key views in my module.Main functionality of these views is to enable manager to change the key associated with a integrity check.Through my module, default keys are assigned.But later if manager need to changes a key, it can be achieve via this views. I'm now currently working on custom query view implementations.Please find change key view snapshots below.
Key List
Change Key

Friday, August 23, 2013

Linux: Kill a process listening to a port

Some times we need to kill processes listening to a some port.More often address already in use messages occur due to some process already listening to a given port.

Method 1:
If you want to use backtick not regular tick

sudo kill 'sudo lsof -t -i:port' 

Eg: sudo kill 'sudo lsof -t -i:9000' //Kill process listnining to port 9000


Method 2: 
Some times above method doesn't work then you can use $() for command interpolation

sudo kill $(sudo lsof -t -i:port)

Eg: kill $(sudo lsof -t -i:9000) //Kill process listnining to port 9000

Sunday, August 18, 2013

9th Week at OpenMRS

During this week I have work on views for adding workflow stages and generating keys for integrity checks. For a integrity check, it's required to have a unique key for identify the each integrity check separately. I implemented this feature during this week.Another feature is that now manager is able to adding and customizing existing workflow stages in the module. Next week I'm planning to work on querying number of checks by set of constrains. See attached image to see the new views.

Integrity Check Key
Add workflow stages