This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
some_lock = threading.lock() | |
with some_lock: | |
# Do something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat ~/.bashrc | |
# config while working with git-sdk-Windows | |
export HOME=/home | |
export PATH=/usr/bin:$PATH | |
alias python=/usr/bin/python2 | |
export WORKON_HOME="$HOME/.virtualenvs" | |
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2 | |
source /usr/bin/virtualenvwrapper.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inline substitution based on condtion using regexp match processing all lines in a given file<filename> | |
# Note: Don't know why this wasn't working in git bash but worked when used Console2 + git bash | |
perl -pn -i'.bkup' -e 's/toreplace/replacewith/ if /regex/' filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from suds.client import Client | |
from suds.sax.element import Element | |
url = "file:///home/jitendra/obs/wsdl.jsp.xml" | |
client = Client(url) | |
token = "xxxxxxxxxxxxxxxxxxxxxxxx" | |
print client | |
LoginResult = client.service.login("userId", "pwd"+token) | |
#Specifies the server URL as the target for subsequent service requests. The login server supports only login calls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
filecount = 0 | |
for d in os.listdir("."): # the current directory / | |
filecount += len(os.listdir("./"+d)) | |
print filecount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cx_Oracle | |
CONN_STR = """(DESCRIPTION= | |
(ADDRESS=(PROTOCOL=tcp)(HOST=%s)(PORT=%s)) | |
(CONNECT_DATA=(SID=%s)))""" | |
CONN_STR = CONN_STR % (host, port, sid) | |
conn = cx_Oracle.connect(user, pwd, CONN_STR, threaded=True) # can connect using multi threads | |
conn.autocommit = True # will always use because could not figure out the place for explicit commit | |
""" | |
if not hasattr(self, "conn"): | |
self.conn = conn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# search elements of one list in another list without nested loops | |
tosearch = ['x','z',10] | |
tobesearched = ['x','y',1,2,3] | |
found = [item | |
for item in tosearch | |
for item2 in tobesearched if item == item2] | |
print found |