Skip to content

Instantly share code, notes, and snippets.

View tshenolo's full-sized avatar
:octocat:
Building

Tshenolo Mos tshenolo

:octocat:
Building
View GitHub Profile
@tshenolo
tshenolo / send_email.sh
Created February 20, 2024 15:19
Bash function to send emails
# send_email "recipient@example.com" "Subject Here" "Email content here"
function send_email() {
local email_address=$1
local subject=$2
local content=$3
echo -e "$content" | mail -s "$subject" "$email_address"
}
@tshenolo
tshenolo / component_search.sql
Created December 12, 2023 01:48
peoplecode: sql: component search
---- Menu Look-up
SELECT SRCH.PORTAL_LABEL LABEL
, NVL(SRCH.PORTAL_URI_SEG2, ' ') COMPNOENT
, SRCH.PORTAL_OBJNAME
--L1.PORTAL_LABEL, L2.PORTAL_LABEL, L3.PORTAL_LABEL,
--L4.PORTAL_LABEL, L5.PORTAL_LABEL, L6.PORTAL_LABEL
,'Main Menu > ' || L1.PORTAL_LABEL || decode(L1.PORTAL_REFTYPE, 'F', ' > ')
|| L2.PORTAL_LABEL || DECODE(L2.PORTAL_REFTYPE, 'F', ' > ')
|| L3.PORTAL_LABEL || DECODE(L3.PORTAL_REFTYPE, 'F', ' > ')
|| L4.PORTAL_LABEL || DECODE(L4.PORTAL_REFTYPE, 'F', ' > ')
@tshenolo
tshenolo / sql_extractor.py
Created July 4, 2023 03:33
Python Script - Extract tables, columns, condition from SQL
import sqlparse
def extract_sql_info(sql_query):
# Parse the SQL query
parsed_query = sqlparse.parse(sql_query)[0]
# Extract table names
tables = []
for token in parsed_query.tokens:
if isinstance(token, sqlparse.sql.Identifier):
@tshenolo
tshenolo / chrome_plugin_resize_image.sh
Created July 4, 2023 03:30
Chrome Plugin Image resize
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <image_file>"
exit 1
fi
image_file="$1"
convert "$image_file" -resize 128x128 128.png
@tshenolo
tshenolo / xml_pretty.py
Created June 29, 2023 10:48
XMP Pretty
import xml.dom.minidom
def format_xml(input_file, output_file):
# Parse the input XML file
doc = xml.dom.minidom.parse(input_file)
# Pretty print the XML document
pretty_xml = doc.toprettyxml(indent=" ")
# Save the formatted XML to the output file
@tshenolo
tshenolo / csv_to_json.py
Created June 22, 2023 13:36
Convert CSV to Json #python
import csv
import json
def convert_csv_to_json(csv_file_path, json_file_path):
data = []
with open(csv_file_path, 'r') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
data.append(row)
@tshenolo
tshenolo / csv_to_markdown.py
Created June 22, 2023 13:35
Convert CSV to Markdown table #python
import csv
def convert_csv_to_markdown(csv_file_path, output_file_path):
table = []
with open(csv_file_path, 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
table.append(row)
@tshenolo
tshenolo / prevent_page_refresh.js
Created June 12, 2023 17:43
Prevent a page from jumping to the top (or refreshing) when a link is clicked.
$(function(){
$('a[href="#"]').click(function () {
return false
});
});
@tshenolo
tshenolo / clean_console_log.js
Created May 24, 2023 14:39
Omit file/line number with console.log
console.print = function (...args) {
queueMicrotask (console.log.bind (console, ...args));
}
@tshenolo
tshenolo / python_json_pretty.py
Created May 4, 2023 19:17
Python Json Pretty Print
import json
# Open the JSON file for reading
with open('input.json', 'r') as f:
# Load the JSON data into a Python dictionary
data = json.load(f)
# Open a new file for writing
with open('output.json', 'w') as f:
# Write the pretty printed JSON data to the output file