Skip to content

Instantly share code, notes, and snippets.

View jonbartlett's full-sized avatar

Jon Bartlett jonbartlett

  • Victoria, Australia
View GitHub Profile
@jonbartlett
jonbartlett / related_records.apex
Created December 11, 2022 22:36
SFDC - Find related records
@jonbartlett
jonbartlett / check_multi_byte_chars.sql
Created October 27, 2016 02:42
Trawl through an Oracle database for multi-byte characters
set serveroutput on;
DECLARE
sql_stmt VARCHAR2(32000);
char_cols_found boolean := false;
table_name varchar2(100);
row_count number;
PROCEDURE log (msg_txt in VARCHAR2)
@jonbartlett
jonbartlett / db2-proc-export.sql
Created October 24, 2016 22:41
Export DB2 Stored Procedures to a file. Useful for comparing stored procs in the DB and those in source control as IDE's tend to try and format the code.
EXPORT TO proc_export.txt OF DEL
MODIFIED BY NOCHARDEL lobsinfile lobsinsepfiles
SELECT TEXT
FROM SYSCAT.ROUTINES
WHERE TRIM(ROUTINESCHEMA) ='RDS'
AND ROUTINENAME ='IU_RDS_CLASS';
@jonbartlett
jonbartlett / write_count.sh
Created August 26, 2016 00:15
Monitor Progress (count of records) on a DB2 ETL Process
#! /bin/sh
for i in {1..1000}
do
db2 -tf write_count.sql
sleep 30s
done
@jonbartlett
jonbartlett / ScanOCR.md
Last active May 28, 2018 00:42
Scan and OCR Solution

What you'll need:

Solution:

  • EPSON Connect Cloud Scan setup to scan to PDF and place file in a Dropbox folder
  • Automator script to watch "Inbox" and invoke OCR Kit with "Run Shell Script" (set "Pass Input" = "as arguments")
now=$(date +"%Y%m%d")
@jonbartlett
jonbartlett / gitprompt.sh
Last active October 20, 2016 00:01
Add SVN status to bash-git-prompt
# Add the following function to gitprompt.sh
# via http://csnipp.com/s/191/-Git-and-SVN-Status-in-the-Bash-Prompt
function prompt_callback {
local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
[ "$REV" ] || return
[ "$(svn st)" ] && DIRTY=' *'
echo "(r$REV$DIRTY)"
return
@jonbartlett
jonbartlett / crontab
Created July 5, 2016 04:37
call a ruby script from crontab when using rbenv
/bin/bash -c 'export PATH="$HOME/.rbenv/bin:$PATH" ; eval "$(rbenv init -)" ; cd /home/vagrant/projects/tmux-status/ ; ruby -v
@jonbartlett
jonbartlett / db2_alter_tb_idempotent.ddl
Last active May 2, 2023 14:34
Create a DB2 Table in an idempotent manner
--
-- db2 -td@ -vf db2_alter_tb_idempotent.ddl
--
BEGIN
IF (EXISTS (SELECT 1
FROM SYSCAT.TABLES
WHERE TRIM(TABSCHEMA)||'.'||TRIM(TABNAME) = 'TEMP.TRANSACTIONS'))
THEN
--
@jonbartlett
jonbartlett / git-author-rewrite.sh
Last active May 24, 2016 01:14
Blanket update email for commits in a repo
#!/bin/sh
git filter-branch --env-filter '
CORRECT_EMAIL="mail@jaybe.net"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
' --tag-name-filter cat -- --branches --tags
@jonbartlett
jonbartlett / notify
Last active May 7, 2018 00:21
Notification script
#!/bin/bash
# Send a tmux, desktop, and audio notification after the completion
# of the given command when using tmux.
#
# Requires: tmux
# Recommended: espeak, libnotify
#
# modified version of https://gist.github.com/thewtex/4969741
#