Wednesday, November 27, 2019

Connecting Oracle with Python via cx_Oracle extension


Installation Prerequisites

  • Python 2.7, 3.5 or above
  • Oracle Client / Oracle Instant Client "Basic" or "Basic Light"
  • libaio / libaio1 package


Installation Reference



Sample Python Code

import cx_Oracle

# Make DSN address. Real values for host address, port and service name were replaced by '<>'.

dsn = cx_Oracle.makedsn('<host_address>', '<port>', service_name='<service_name>')

# Connect to DSN

orcl = cx_Oracle.connect(user='<username>', password='<password>', dsn=dsn)

# Get cursor

cursor = orcl.cursor()

# Execute SQL statement

cursor.execute('<SQL SELECT STATEMENT>')

# Fetch result

data = cursor.fetchone()

Thursday, November 21, 2019

Sending F10 in Ubuntu Terminal

By default, you just can't send F10 to Ubuntu Terminal's curses program. This is because F10 is being captured by Terminal.app already.

A quick workaround is to use "ESC 0" to simulate sending F10 inside Terminal.app.

Reference

Tuesday, November 19, 2019

Customized Dash (Launcher / Taskbar) Icon in Ubuntu

To customize application icon in Ubuntu:

  1. Create a .desktop file in ~/.local/share/applications/
    e.g. /home/user/share/applications/<application name>.desktop
  2. Add the following content to the desktop file
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=ApplicationName
GenericName=ApplicationName
Icon=/home/user/application-icon.png
Exec=/home/user/application/application-executable
Categories=Category;Subcategory
Done!

Sync multiple git repo at once

Use the following command in Linux will do the job:  ls -d RepoNames* | xargs -I{} git -C {} pull