Skip to content

Instantly share code, notes, and snippets.

#Create a new mysql server instance (a docker container).
#On Mac OS
#Data will be stored in the directory /Users/johndoe/Dockerdata/mysqldata
docker run --name newmysql -v /Users/johndoe/Dockerdata/mysqldata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysqlpassword -d mysql
#Get IP address of Docker Container 39baf42be8d4
docker inspect --format '{{ .NetworkSettings.IPAddress }}' 39baf42be8d4
@tsundara
tsundara / oracle_columns_comma_sep.sql
Last active January 24, 2017 21:19
Oracle - Get Oracle column names separated by comma
--Straighforward table_name and corresponding column names
SELECT table_name, LISTAGG(column_name, ',') WITHIN GROUP (ORDER BY column_name) as COLUMNS
FROM user_tab_cols
group by table_name
@tsundara
tsundara / oracle_to_logstash.conf
Last active January 24, 2017 21:00
Oracle to Logstash - Sample
#A sample config file for exporting data from Oracle to ElasticSearch
#Note the capital J in "Java" for jdbc_driver_class
input {
jdbc {
jdbc_connection_string => "jdbc:oracle:thin:@oraclehost:1522/ORASID"
jdbc_user => "oracle_user"
jdbc_password => "oracle_password"
jdbc_driver_library => "/home/tsundara/elk/logstash-2.3.4/lib/jdbc_libs/ojdbc6.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
@tsundara
tsundara / Selenium_Python_Login_Test.py
Last active January 26, 2017 00:37
Selenium Python Login Test on Chrome
# This gist shows how to perform Browser testing using Selenium Webdrier & Python
#Ensure that you have downloaded ChromeDriver.exe and placed it in some directory,say C:/binaries
#Also make sure C:/binaries is set in your windows %PATH%. For testing, you can use the below set command :
#set PATH=C:/binaries;%PATH%
from selenium import webdriver
browser = webdriver.Chrome()
#If a blank Chrome window opens up, you are good to proceed with next steps
browser.get('http://website:8000/Login')
username = browser.find_element_by_id("loginname")
password = browser.find_element_by_id("passwd")
@tsundara
tsundara / pgsql_commands.sql
Created January 29, 2017 06:53
Postgres Commands
#Export data to csv
\copy usertable to 'filename.csv' csv header
@tsundara
tsundara / sublime_commandline.md
Last active January 30, 2017 01:52
Launch sublime from Mac OS terminal (subl command)

###Opening Sublime from Mac OS terminal/command line

  • Open the $HOME/.bash_profile file on vim or nano.
  • Add the following 2 lines at the bottom. Save it.

export PATH=$PATH:"/Applications/Sublime Text.app/Contents/SharedSupport/bin"
  • Close the current terminal. Open a new terminal and enter the below command(or you can enter : source $HOME./bash_profile).
@tsundara
tsundara / OpenRefine_GREL.sh
Last active January 31, 2017 19:50
OpenRefine GREL common expressions
#Concatenate Cells
cells["col1"].value + " " + cells["col2"].value
cells["ORG_STREET"].value + " " + cells["ORG_CITY"].value + " " + cells["ORG_PROVINCE"].value + " " + cells["ORG_COUNTRY"].value + " " + cells["ORG_ZIP"].value
@tsundara
tsundara / Oracle function to set decimal number precision.sql
Last active July 21, 2017 14:30
Oracle function to set decimal number precision
select to_number(to_char(dbms_random.value(1,999), '000.0')) num from dual
select * from MYTABLE
where MYCOLUMN like (
select '%'||to_number(to_char(dbms_random.value(1,999), '000'))||'%' num from dual
)
order by MYCOLUMN
@tsundara
tsundara / pycsvtotabletomail
Last active July 23, 2020 07:44
Convert csv file content to html table and then to smtp email
#Purpose : Takes a csv and sends an email in html table format
#usage : python pycsvtotabletomail.py mytable.csv
import pandas as pd
import sys
csvfile=sys.argv[1]
df=pd.read_csv(csvfile)
htmltable=df.to_html(index=False)
htmltable=htmltable.replace('border="1"','border="1" style="border-collapse:collapse"')