Skip to content

Instantly share code, notes, and snippets.

View Dani3lSun's full-sized avatar
😎

Daniel Hochleitner Dani3lSun

😎
View GitHub Profile
@Dani3lSun
Dani3lSun / is_apex_session_cloned.sql
Last active June 4, 2019 12:38
Function to check if an Oracle APEX session got cloned
CREATE OR REPLACE FUNCTION is_apex_session_cloned RETURN BOOLEAN IS
--
l_referer VARCHAR2(4000);
l_referer_query_string VARCHAR2(4000);
l_session_before NUMBER;
l_bool BOOLEAN := FALSE;
-- cursor to find session id of referer (page before)
-- 3rd splitted part holds APEX session id
CURSOR l_cur_session_before IS
SELECT to_number(referer_tab.column_value) AS session_before
@Dani3lSun
Dani3lSun / get_binds.sql
Created January 23, 2019 14:34
Get Bind Variable Names of given SQL Statement in Oracle
CREATE OR REPLACE FUNCTION get_binds(p_sql_statement IN CLOB) RETURN apex_t_varchar2 AS
--
l_statement CLOB := p_sql_statement;
l_block_comment_start_pos PLS_INTEGER;
l_line_comment_start_pos PLS_INTEGER;
l_string_literal_start_pos PLS_INTEGER;
l_q_quote_char VARCHAR2(1);
l_closing_token VARCHAR2(2);
l_token_start_pos PLS_INTEGER;
l_token_end_pos PLS_INTEGER;
@Dani3lSun
Dani3lSun / gen_xe_space_percent.fnc
Created January 2, 2016 22:10
Returns the percentage usage of disk space of an Oracle XE 11g database that has 11GB max space available
CREATE OR REPLACE FUNCTION gen_xe_space_percent RETURN NUMBER IS
--
l_return NUMBER := 0;
l_xe_max_size NUMBER := 11811160064;
l_used_size NUMBER := 0;
--
CURSOR l_cur_dba_ts_size IS
SELECT a.tablespace_name ts,
a.file_id,
SUM(b.bytes) / COUNT(*) - SUM(a.bytes) used
@Dani3lSun
Dani3lSun / get_apex_temp_blob.prc
Last active January 2, 2016 21:57
Get BLOB / Filename / Mime_Type from apex_application_temp_files
CREATE OR REPLACE PROCEDURE get_apex_temp_file(i_item_value IN VARCHAR2,
o_blob OUT BLOB,
o_filename OUT VARCHAR,
o_mime_type OUT VARCHAR2) IS
--
l_workspace_id NUMBER;
l_app_id NUMBER;
--
CURSOR l_cur_apex_blob IS
SELECT atf.blob_content,
@Dani3lSun
Dani3lSun / apex_zip_add_file_clob.prc
Created January 2, 2016 21:50
Wrapper for APEX_ZIP.ADD_FILE for CLOB content
CREATE OR REPLACE PROCEDURE zip_add_file_clob(p_zipped_blob IN OUT NOCOPY BLOB,
p_name IN VARCHAR2,
p_content IN CLOB) AS
--
l_tmp BLOB;
l_dest_offset INTEGER := 1;
l_src_offset INTEGER := 1;
l_warning INTEGER;
l_lang_ctx INTEGER := dbms_lob.default_lang_ctx;
--
@Dani3lSun
Dani3lSun / apex_is_pageitem_rendered.fnc
Last active May 21, 2019 13:25
PL/SQL function to check if an APEX item is rendered or not
CREATE OR REPLACE FUNCTION is_pageitem_rendered(p_item_name IN VARCHAR2) RETURN BOOLEAN IS
--
l_bool BOOLEAN;
--
CURSOR l_cur_item IS
SELECT aapi.build_option_id,
aapi.condition_type_code,
aapi.condition_expression1,
aapi.condition_expression2,
aapi.authorization_scheme_id
@Dani3lSun
Dani3lSun / adblock_hosts.sh
Last active April 20, 2023 11:49
Mac OS X adblock shell script using system hosts file (Block ads system wide)
#!/bin/sh
#
# Mac OSX Adblocker Script for IPv4
# Description: Blocks ads using system hosts file /private/etc/hosts, Ad-Domains would be redirected to 0.0.0.0
# Author: Daniel Hochleitner
# Created: 10.09.2015
# Use: sudo ./adblock_hosts.sh
# Get original hosts file from /private/etc/hosts