Remote Management By JConsole


Getting trouble while connecting jconsole with remote process

Here is how to achieve it

As described here http://docs.oracle.com/javase/tutorial/jmx/remote/jconsole.html is not enough

sometimes one more java system property needs to be set which is
java.rmi.server.hostname=

for example in case of Apache Tomcat
follow this
1) Export JAVA_OPTS
export JAVA_OPTS='-Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.13'

2) Restart application

3) now from the jconsole connect to 192.168.1.13:9999 by providing credentials

Note : Firewall should be configured to allow these connections (or simply for the time stop iptables services (in linux))

Ref : http://stackoverflow.com/questions/1263991/connecting-remote-tomcat-jmx-instance-using-jconsole

Mondrian [MDX] accessing Member PROPERTIES

I was trying to access the properties of Dimension in my MDX schema, but the way it is mentioned in the Mondrian documentation was not working in 3.5.8 version. Then we got in trouble and wasted lot of time in figuring out that, how to access properties in Mondrian.

Here is how it worked for me

SELECT
{[Measures].[Total Sales Count]} ON COLUMNS,
[Store].[Store Id].MEMBERS DIMENSION PROPERTIES [Store].[Store Id].[Name] ON ROWS
FROM [Sales]

Where [Name] is the property of the level [Store Id]

Hope if you are searching for this, it may help you.

Including Custom Library Into Maven

This can be achieved in just simple 2 steps

1. Install file in maven local repository

mvn install:install-file -Dfile=/path/jarfile.jar -DgroupId=com.company -DartifactId=module-util -Dversion=1.0.0 -Dpackaging=jar

2. Add the entry in the pom.xml.

Find all active IP Address in LAN

Run following script in terminal
-------------------------------

for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done


Note : 192.168.1.* is the local IP range for modem, It can be different for your machine.

GitHub : Download commit as patch

I was searching for this, to directly download commits as patches
And here is how it works

Say there is commit
https://github.com/pentaho/mondrian/commit/5b5dbac3bd430ee9600e3d4db13aada06564c230

and you want to get it as patch, then just simply add ".patch" at the last of the url and download it via wget or browser.
https://github.com/pentaho/mondrian/commit/5b5dbac3bd430ee9600e3d4db13aada06564c230.patch


That's All

Show all queries running in PostgreSQL database

Sometimes its useful to check what all queries are running in the database when debugging.
Using tcpdump command we can do this.
So for postgresql just execute this command in terminal

sudo tcpdump -i lo -s0 -nl -w- dst port postgres | strings -n8

This will show all queries running in database.

Youtube video setting play time position in link

Want your YouTube link to have specified play position
Try this
at the end of the YouTube video url just append the time (#t=1h17m33s), you want start from
say for example
for video
http://www.youtube.com/watch?v=9ei-rbULWoA

if you want this video to start from 1 hour 17 minutes and 33 seconds then the final link will be
http://www.youtube.com/watch?v=9ei-rbULWoA#t=1h17m33s

you can use only minutes or seconds any combination like
http://www.youtube.com/watch?v=9ei-rbULWoA#t=57m

Creating Local SVN Repository (Home Repository)


Hi, I wanted to create a Local (Home) Repository for my project to keep track of all changes which I was doing, So for that I created Local Repository from a existing project.

Here are the steps, how I created it.
Go to your home directory or where you want to put your repository
cd /home/demo/svnrepo

Creating Repository for Project myproj
svnadmin create myproj

The repository is in revision 0, so import the existing project into repository
svn import /root/myproj/ file:///home/demo/svnrepo/myproj/trunk -m "Initial import of myproj"
                 [Project Path]                 [Repository Path]

Checkout myproj Locally
svn co file:///home/demo/svnrepo/myproj/trunk /root/development/myproj

Checkout myproj Remotely
svn co svn+ssh://root@/home/demo/svnrepo/myproj/trunk /root/development/myproj

For detailed reading click here
Related Article Set Up An SVN Repository In 7 Simple Steps

Resuming Failed Download Using RSYNC


Situation : 
I have to download some big file from your server. but I don't have access to login in server system.
But using VPN you are able to downlaod some big file.

I tried downloading the big file from the server.
#wget http://10.0.0.1/mypath/mybigfile /root/myfiles/mybigfile
But most of the time the download was not completing, and If I try it using rsync it will ask for password which I was not having, so con't download using rysnc.
So I had to restart it from the beginning (and most probably it fails again, because of some n/w issue)

But now I am able to resume the failed download and continue my task.

Here are the steps
We have other system (say 10.0.0.2) which is local to server and I have credentials for that system.
So first of all I login to 10.0.0.2 and download the bigfile there
#wget http://10.0.0.1/mypath/mybigfile /root/workspace/mybigfile
As the system is local to server, downloading the file there is fast, it takes less than 1 minute.

So afer downloading the file on 10.0.0.2, I resume it using rsync.
rsync --rsync-path=/usr/bin/rsync --partial --progress --rsh=ssh root@10.0.0.2:/root/workspace/mybigfile /root/myfiles/mybigfile
It will ask for the password, supply it, and the downlaod will resume

Project Lombok for Java


Project Lombok is a very good for keeping your class clean.
Use Annotation for most of the common things like getter/setter, equals, hashCode, toString etc.
If you gonna start a project from scratch, just give it a try.
learn more at Lombok Features
Watch video