Thursday, December 5, 2013

Didn't Get The Job? Do This...

Thank you for letting me know you made a decision. I'm really happy you have found the right candidate for the job. The interviewing process with you was very inspiring and I meant what I said about wanting to work for your company. So, I was wondering if you could advise me on what I can do to be proactive and stay on your radar screen for any future opportunities?"

Tuesday, November 26, 2013

books to read

david and goliath
Miracle of Mindfulness by Thich Nhat Hanh

Saturday, October 19, 2013

clocking Intel i7 720QM ( poor performance fixed )

Recently i was facing problems with performance of my Lenovo W510 laptop. I was able to fix it and here is what i discovered.

1) I was using a low power adapter rather than the higher powered one which came along with the laptop. This have effect on the performance so use a higher power power adapter.
2) In the power options on my Windows Seven OS i changed my power profile to one of Maximum performance.
3) Finally use a utility like ThrottleStop to boost the CPU .

Make sure to uncheck the BD PROCHOT check box.

Thursday, October 3, 2013

Starting tomcat6: Error code 4

[root@vm-scim-dev logs]# service tomcat6 restart
Stopping tomcat6:                                          [  OK  ]
Starting tomcat6: Error code 4                             [FAILED]

I was able to solve this error by providing some disk space as the disk space was full causing this error.

Tuesday, September 24, 2013

Java thread wait notify alternate text print


import java.util.concurrent.locks.Lock;

public class Threads {

    private Object lock= new Object();
    private boolean flag = false;
    private Runnable thread1 ;
    private Runnable thread2 ;
    public static void main(String[] args) throws InterruptedException {
        Threads threads  = new Threads();
        threads.thread1 = MyRunnable();
        threads.thread2 = MyRunnableT();
        Thread thread1 = new Thread(threads.thread1);
        Thread thread2 = new Thread(threads.thread2);
        try {
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
        System.out.println("thread 1 joined");
    class MyRunnable implements Runnable {

        public void run() {
            for (int i =0 ;i<10;i++){
                System.out.println("I have the lock" + Thread.currentThread().getName());
                try {
                    {// if flag == false you wait for it to be true
                        // do whatever you want
                        //s et flag to false
                        flag = false;
                    else {
                        // flag is true so do whatever you want and then set it to false
                        // do what ever you want 
                        flag= true;
                    } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
    class MyRunnableT implements Runnable {

        public void run() {
            for (int i =0 ;i<10;i++){
                System.out.println("I have the lock" + Thread.currentThread().getName());
                        // do what ever you want and then set the flag to true
                        // and then notify the other thread.
                        flag = false;
                    else {
                        // if flag is true you wait for it to be false
                        // then do whatever you want and then set it to true
                        try {
                            // do whatever you want
                            flag = false;
                        } catch (Exception e) {
                            // TODO Auto-generated catch block

Tuesday, September 17, 2013

'ascii' codec can't encode character u'\u2019' in position 16: ordinal not in range(128)

Likely, the problem is that you parsed it okay, and now you're trying to print the contents of the XML and you can't because theres some foreign Unicode characters. Try to encode your unicode string as ascii first:
unicodeData.encode('ascii', 'ignore')

HTTP Request with headers in Python

#!/usr/bin/env python

import requests
import xml.etree.ElementTree as ET

headers = {'key':'value'}

r = requests.get('',auth=('username', 'password'),headers=headers)

print r.text

root = ET.fromstring ( r.text.encode('ascii','ignore'))

for xyz in  root.findall('POPULARITY_RECORD'):
        neoUrl = xyz.find('FIELD_VALUE').text
        print neoUrl
        httpstatus_neo = requests.get(neoUrl)
        print httpstatus_neo.status_code
# print r.text

Reading XML in python

#!/usr/bin/env python

import xml.etree.ElementTree as ET
import httplib
import urllib2
tree = ET.parse('popularity_response.xml')
root = tree.getroot()
print root
for popularity_record in root.findall('POPULARITY_RECORD'):
 print popularity_record.find('FIELD_VALUE').text
 try : 
  response =     urllib2.urlopen(popularity_record.find('FIELD_VALUE').text)
  print response.code
 except urllib2.URLError as e :
  print e

Tuesday, September 3, 2013

Configuring Oracle for Python

Configuring Oracle for Python
Python code for testing ORacle DB COnnectivity

# assuming python and pip are already installed
# installing the instantclient is usually where problems happen
# download the following files from oracle
# oracle-instantclient11.2-basic-
# oracle-instantclient11.2-devel-
# oracle-instantclient11.2-sqlplus-
# install the rpms
rpm -ivh oracle-instantclient11.2-basic-
rpm -ivh oracle-instantclient11.2-sqlplus-
rpm -ivh oracle-instantclient11.2-devel-
# the sqlplus package isn't specifically needed, but is usually useful for testing and command line sql connections
# configure oracle env (modify exact path based on version of rpm you download)
vim /etc/profile.d/oracle
export TNS_ADMIN
# copy/create your tnsnames.ora file
touch /etc/oracle/tnsnames.ora
# symlink headers to ORACLE_HOME to avoid "cannot locate Oracle include files" error
mkdir /usr/lib/oracle/11.2/client64/lib/sdk
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include
# done. Install cx_Oracle
pip install cx_Oracle
import os
import cx_Oracle
import csv
# Network drive somewhere
output=csv.writer(FILE, dialect='excel')
# You can set these in system variables but just in case you didnt
os.putenv('ORACLE_HOME', '/oracle/product/10.2.0/db_1')
os.putenv('LD_LIBRARY_PATH', '/oracle/product/10.2.0/db_1/lib')
connection = cx_Oracle.connect('userid/password@99.999.9.99:PORT/SID')
cursor = connection.cursor()
for row in cursor: