Thursday, April 24, 2014

Ubuntu to remove packages marked as 'deinstall'

To list left over configuration files and binaries for Ubuntu packages

dpkg --get-selections | grep -i deinstall

To completely remove packages including binaries and configuration files

dpkg --get-selections | grep -i deinstall | awk -F ' ' '{print $1}' | xargs sudo apt-get purge -y -

Wednesday, April 23, 2014

MongoDB Compound Unique Index with Spring Data

Adding compound, unique index with MongoDB can be done as follows:
db.collection.ensureIndex( { column-1 : 1, column-2 : 1 }, { unique : true } )
To achieve the same using Spring Data, use the following annotations:
        @CompoundIndex(name = "my_index_name",
                       unique = true,
                       def = "{'column-1' : 1, 'column-2' : 1}")

Inspecting network traffic with tcpdump

Some of the useful tcpdump commands to trouble shoot network issues:

List the interfaces

tcpdump -D

Get the traffic to specific host

tcpdump -i eth0 -vvv -A -l host host-to-check

To dump into a file

tcpdump -i eth0 -vvv -A -l host host-to-check -w file-to-dump

Read from a file

tcpdump -i eth0 -vvv -A -l -r file-to-read-from

Wednesday, November 20, 2013

SQLDeveloper wont start on Mavericks

After upgrading to Mavericks, the SQLDeveloper version wont start. The solution is to create a file named jdk containing one line /usr in the directory ~/.sqldeveloper.

Monday, November 18, 2013

Apache Load Balancing & Fail Over with mod_proxy

Apache mod_proxy and the extension mod_proxy_balancer can be used for load balancing and fail over. The following setup is used for two downstream Tomcat servers with a candidate web app deployed at the root.

httpd.conf (On Mac OS, Mavericks)

LoadModule proxy_module libexec/apache2/
LoadModule proxy_ajp_module libexec/apache2/
LoadModule proxy_balancer_module libexec/apache2/
ProxyRequests Off
<Proxy balancer://cluster>
    BalancerMember ajp://localhost:8009  loadfactor=1 ping=10
    BalancerMember ajp://localhost:18009 loadfactor=2 ping=10
ProxyPass          /status   !
ProxyPass          /balancer !
ProxyPass          /         balancer://cluster/
ProxyPassReverse   /         balancer://cluster/

ProxyStatus On
<Location /status>
    SetHandler server-status
    Order Deny,Allow
    Deny from all
    Allow from all

<Location /balancer>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny from all
    Allow from all

Friday, November 15, 2013

Mac OS username not in sudoers file

Recently run into this error when trying to run a command with sudo and got this error:

'username' not in sudoers file

The solution is to log in as a user with admin privilege and edit the /etc/sudoers file. Add the user whom you want to provide sudo privilege into this file as a separate line. For example, add the last line and replace the username with the your username.
# User privilege specification
root    ALL=(ALL) ALL
%admin  ALL=(ALL) ALL
username ALL=(ALL) ALL ---> Added