Skip to content

Instantly share code, notes, and snippets.

@oraculix
oraculix / log_server_errors_tg.sql
Created April 15, 2014 13:22
Trigger to catch and log SQL errors in Oracle in the background
-- See http://wp.me/pojaY-8G (German)
DROP TABLE servererror_log
/
CREATE TABLE servererror_log (
error_datetime TIMESTAMP,
, error_user VARCHAR2(30)
, error_stack VARCHAR2(2000)
, error_backtrace VARCHAR2(4000)
, captured_sql VARCHAR2(4000))
/
@oraculix
oraculix / sql_monitor.sql
Last active August 29, 2015 14:05
Snippets for manual execution of Oracle's SQL MONITOR
---------------
-- SQL-Monitor
---------------
-- Welche Reports stehen zur Verfügung?
-- Ggf. auf INST_ID oder SQL_ID einschränken.
select DBMS_SQLTUNE.REPORT_SQL_MONITOR_LIST(
INST_ID => NULL
, active_since_date => sysdate-1/48
, report_level => 'BASIC'
-- , SQL_ID => 'dqbzzupk4xuz5'
@oraculix
oraculix / 50-u2f.rules
Last active March 22, 2017 17:58
Enable HyperFIDO U2F Key on Linux
# /etc/udev/rules.d/50-u2f.rules
# HyperFIDO U2F Key
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2ccf", ATTRS{idProduct}=="0880", OWNER="root", GROUP="plugdev", MODE:="0660"
@oraculix
oraculix / screen.md
Last active September 9, 2021 17:26 — forked from fredrick/screen.md
GNU Screen Cheat Sheet

GNU Screen Cheat Sheet

Basics

Hotkey Description
ctrl-a c cre­ate new win­dow
ctrl-a A set win­dow name
ctrl-a w show all win­dows
ctrl-a \ switch to win­dow n
@oraculix
oraculix / md.sql
Created January 12, 2023 15:24
How to format your Oracle SQL*Plus output for Markdown
-- How to format your Oracle SQL*Plus output for Markdown:
SET COLSEP '|'
select * from USER_SYS_PRIVS order by PRIVILEGE;
@oraculix
oraculix / gen_incr_sequences.sql
Created January 25, 2023 12:39
Increase Oracle sequences by a percentage
/* gen_incr_sequences.sql
* Generates SQL script to increase Oracle sequences.
*
* For use in migration scenarios, e.g. with DMS or GoldenGate,
* when access to the source database is difficult.
* Run this
* - either as the target schema owner
* - or as an admin user (edit list of schema_owner first)
* , then run the generated script "incr_sequences.sql" during cutover
* on the target.
@oraculix
oraculix / regex_search.sql
Last active January 25, 2023 12:57
Regular expression search in Oracle PL/SQL source code
-- Find first occurence of NEXTVAL case-insensitive and deliver the line of occurrence and the lines around it.
WITH found AS (
SELECT owner, name, type, line FROM all_source
WHERE owner = 'GSMADMIN_INTERNAL'
AND regexp_instr(text, 'NEXTVAL',1,1,0,'i') > 0
)
SELECT a.*
FROM all_source a, found
WHERE a.owner = found.owner
AND a.name = found.name
@oraculix
oraculix / Readme.md
Created March 10, 2023 15:49
Find the largest LOB in an Oracle schema

Find the largest LOB in an Oracle schema

This is meant for DMS migration tasks using "Limited LOB Mode", where you need to set the LobMaxSize parameter.

  • Run either as the schema owner or,
  • For multiple schemas or if you're not the schema owner:
    • Adapt the line "AND OWNER = USER" to the list of schemas to be queried
  • Run script as admin user.

Windows on AWS EC2: Install software with Chocolatey package manager

Why

When you create a new EC2 instance, you usually would like to install some software on top of the OS during the creation process. But unlike Linux, Windows doesn't come a package manager like yum or apt. Chocolatey is such a package manager that can either be used for free with community-made packages or as an enterprise solution with a custom repository.

How

To install and manage software automatically on instance launch, paste the code below into the UserData field. This will install Chocolatey package manager first. Then you can install software packages from Chocolatey's community repository as shown below via choco install -y .

@oraculix
oraculix / obsidian-git-sync.sh
Last active June 11, 2024 11:58
Git sync script for Obsidian Vaults on Android using Termux
#!/data/data/com.termux/files/usr/bin/sh
touch ~/obsidian-git-sync-timestamp
while IFS= read VAULT; do
echo _____________________________________________________________
echo ${VAULT}
cd ~/storage/shared/Documents/Obsidian/${VAULT}
git config --global pack.windowMemory "100m"
git config --global pack.packSizeLimit "100m"
git config --global pack.threads "1"
git pull --rebase