Skip to content

Instantly share code, notes, and snippets.

@mujahidk
mujahidk / sqlplus-connect.sh
Created January 30, 2019 22:09
Connecting to oracle sqlplus
sqlplus username/password@oracle-server:port/instance-name
@mujahidk
mujahidk / oracle-plsql-measure-time.sql
Created January 29, 2019 18:24
Oracle PL/SQL block to run a query multiple times and measure time.
SET TIMING ON
DECLARE
START_TIME PLS_INTEGER;
COUNT_ROW NUMBER;
BEGIN
FOR I IN 1..10 LOOP
START_TIME := DBMS_UTILITY.GET_TIME();
SELECT COUNT(*) INTO COUNT_ROW FROM (SELECT * FROM PERSON ORDER BY LASTNAME ASC) WHERE ROWNUM <= 50;
DBMS_OUTPUT.PUT_LINE('Selected ' || COUNT_ROW || ' in ' || (DBMS_UTILITY.GET_TIME() - START_TIME) || '/100 seconds');
@mujahidk
mujahidk / list-and-sum.sh
Created January 20, 2019 17:53
Shell, adding column of numbers to get the total
ll | awk '{total+=$5} END{print "Total: " total}'
@mujahidk
mujahidk / list-nfs-mounts.sh
Created November 12, 2018 17:12
Linux finding NFS mounts
mount -l -t nfs4
@mujahidk
mujahidk / Pandoc.sublime-build
Created September 24, 2018 16:33
Sublime - Markdown to Word build system using Pandoc.
{
"working_dir": "$file_path",
"cmd": [
"pandoc.exe",
"-o",
"${file_base_name}.docx",
"$file"
],
"selector": "text.html.markdown"
}
@mujahidk
mujahidk / oracle_regex_substr.sql
Created September 12, 2018 21:45
Oracle REGEXP_SUBSTR with sub expression
SELECT REGEXP_SUBSTR('http://www.example.au.com/services', 'https?://(www.)?(\w+).', 1, 1, 'i', 2/*Second sub expression result*/) AS DOMAIN_PART
FROM DUAL;
@mujahidk
mujahidk / copy-recursive-selected-file.sh
Created September 12, 2018 21:35
Recursively copy specific files to a mirror directory structure.
find . -name 'application.properties' -exec cp {} ~/new/mirror/directory/{} \;
@mujahidk
mujahidk / new-relic-application-list.js
Created August 30, 2018 19:05
Node script to get the application list from New Relic API.
var http = require('https')
var options = {
protocol: 'https:',
host: 'api.newrelic.com',
path: '/v2/applications.json',
headers: {
"X-Api-Key": 'you-new-relic-api-key'
}
}
@mujahidk
mujahidk / git-fetch.sh
Created August 20, 2018 19:16
Fetch all Git project repositories under a directory.
for d in ./*/ ; do
(
echo "Processing directory '$d'";
if [ -d "$d/.git" ]; then
cd "$d" && git fetch --all
else
echo " ** Not a Git repository!"
fi;
echo "Completed '$d'"
echo '-----------------------------'
@mujahidk
mujahidk / find-and-remove-older-files.sh
Created May 3, 2018 15:33
Find files older than 7 days and remove.
# WARNING! Make sure you are in right directory.
find -type f -mtime +7 -exec rm -f {} \;