Skip to content

Instantly share code, notes, and snippets.

View s-oravec's full-sized avatar
👾
!!

Štefan Oravec s-oravec

👾
!!
View GitHub Profile
@s-oravec
s-oravec / json-merge.sql
Last active October 22, 2020 20:30
JSON Merge in 18c PLSQL
declare
type json_path_map_type is table of boolean index by varchar2 (4000);
no_preserved_paths json_path_map_type;
subtype array_merge_type is pls_integer range 0 .. 1;
array_merge_replace constant array_merge_type := 0;
array_merge_append constant array_merge_type := 1;
type merge_options_type is record (
preserved_paths json_path_map_type default no_preserved_paths,
array_merge array_merge_type default array_merge_replace,
declare
l_src json_object_t := new json_object_t('{"a":{"b":"c","d":"x"},"b":[1,"x",false],"c":"d","d":10,"e":true,"f":[{"a":"b0","c":"d0"},{"a":"b1","e":"f1"},{"a":"b2","c":"d2","e":"f2"}]}');
l_do_trace boolean;
procedure trace(
p1 in varchar2,
p2 in varchar2 default null,
p3 in varchar2 default null
) is
begin
if l_do_trace then
1. Setup a project
2. Add groovy SDK support:
https://www.bonusbits.com/wiki/HowTo:Add_Groovy_SDK_to_IntelliJ_IDEA
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
@s-oravec
s-oravec / pipeline.gdsl
Created December 20, 2019 16:04 — forked from ranma2913/pipeline.gdsl
GDSL supporting pipeline declarative
//The global script scope
def ctx = context(scope: scriptScope())
//What things can be on the script scope
contributor(ctx) {
method(name: 'pipeline', type: 'Object', params: [body: Closure])
method(name: 'build', type: 'Object', params: [job: 'java.lang.String'], doc: 'Build a job')
method(name: 'build', type: 'Object', namedParams: [parameter(name: 'job', type: 'java.lang.String'), parameter(name: 'parameters', type: 'Map'), parameter(name: 'propagate', type: 'boolean'), parameter(name: 'quietPeriod', type: 'java.lang.Integer'), parameter(name: 'wait', type: 'boolean'),], doc: 'Build a job')
method(name: 'echo', type: 'Object', params: [message: 'java.lang.String'], doc: 'Print Message')
method(name: 'emailextrecipients', type: 'Object', params: [recipientProviders: 'Map'], doc: 'Extended Email Recipients')
@s-oravec
s-oravec / returning-bulk-collect-into.sql
Created October 9, 2018 15:23
returning bulk collect into
drop table x ;
drop type integer_tab_type;
create table x (id integer primary key, v varchar2(10));
create type integer_tab_type as table of integer;
insert into x values (1, 'a');
insert into x values (2, 'b');
commit;
@s-oravec
s-oravec / strip-literals-from-sql.sql
Created June 19, 2018 08:18
Strip literals from SQL
-- text literal
select sql_text, regexp_replace(sql_text, '''.*?''', '?') from v$sql where regexp_like(sql_text, '''.*?''');
-- numeric literal
select sql_text, regexp_replace(sql_text, '([^a-zA-Z_$#0-9]+?)([0-9.]*[0-9]+)', '\1?') from v$sql where regexp_like(sql_text, '[0-9]+');
-- all literals
select sql_text, regexp_replace(regexp_replace(sql_text, '''.*?''', '?'), '([^a-zA-Z_$#0-9]+?)([0-9.]*[0-9]+)', '\1?') from v$sql where sql_id = '9ng8wuk77s0jf';
@s-oravec
s-oravec / exchange-partitions-but-keep-stats.sql
Last active June 5, 2018 16:15
exchange partitions but keep stats (exp tab.partition.stats > tab.partition <-> tmp tab > imp tab.partition.stats)
rem # copy stats back after partition exchange
rem
rem ## exp tab.partition.stats > tab.partition <-> tmp tab > imp tab.partition.stats
rem
clear
prompt > copy stats back after partition exchange
prompt
@s-oravec
s-oravec / calendar-events-to-timesheet.scpt
Last active June 5, 2018 11:08
Calendar events to timesheet AppleScript
on newNumbersFromEventInfos(calendarNames, selectedYearMonth, theEventInfos)
-- get max col count
set colCount to 0
repeat with rowIndex from 1 to length of theEventInfos
if colCount < length of item rowIndex of theEventInfos then
set colCount to length of item rowIndex of theEventInfos
end if
end repeat
--
tell application "Numbers"
declare
l_handle_filter integer;
l_handle_remap integer;
l_handle_transform integer;
begin
-- create filter handle and filter objects to transform
l_handle_filter := dbms_metadata.open('TABLE', version => 'LATEST');
dbms_metadata.set_filter(l_handle_filter, 'SCHEMA', user);
dbms_metadata.set_filter(l_handle_filter, 'NAME', 'ETL_PROCESS');
-- create transform handle
@s-oravec
s-oravec / gmt-vs-cet.sql
Created May 28, 2018 16:57
GMT vs. CET TimeZone
-- GMT vs. CET
with dates as
(select from_tz(cast(trunc(sysdate, 'YYYY') + level as timestamp), 'GMT') as gmt from dual connect by level <= 365),
tzs as
(select gmt, gmt at time zone 'CET' as cet from dates)
select to_date(to_char(gmt, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') as gmt,
to_date(to_char(cet, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') as cet
from tzs;