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 / Dictconfig example
Created December 11, 2017 14:22 — forked from kien-truong/Dictconfig example
Example log dictionary config in pure python
logconfig = {
"version": 1,
"disable_existing_loggers": 0,
"root": {
"level": "DEBUG",
"handlers": [
"console",
"file",
"debugfile"
]
@s-oravec
s-oravec / regexp-test.sql
Created November 10, 2017 10:14
regexp-test
with
-- NoFormat Start
regexp as (
select '^[[:blank:]=v]*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[a-zA-Z0-9\.-]*)?(\+[a-zA-Z0-9\.-]*)?[[:blank:]]*$' as expression from dual
),
sample as (
select '' test_value, '<null>,<null>,<null>,<null>,<null>' expected from dual union all
select '1.2.3' test_value, '1,2,3,<null>,<null>' expected from dual union all
select ' 1.2.3' test_value, '1,2,3,<null>,<null>' expected from dual union all
select ' 1.2.3 ' test_value, '1,2,3,<null>,<null>' expected from dual union all
CREATE OR REPLACE PROCEDURE clob2file
(
clob_in IN CLOB,
directory_name IN VARCHAR2,
file_name IN VARCHAR2
) IS
-- this is safe value less then 6400 as recommended by utl_file comments, rounded to multiple of 1024
lc_amount CONSTANT INTEGER := 6144;
l_file utl_file.file_type;
l_blob_buffer BLOB;
@s-oravec
s-oravec / gist:b1364601a7b54915ea62b38ebbeb6b3c
Created October 26, 2016 20:09 — forked from six8/gist:1732686
Javascript dependency graph resolution
// Dependency resolution, adapted from https://gist.github.com/1232505/f16308bc14966c8d003c2686b1c258ec41303c1f
function resolve(graph) {
var sorted = [], // sorted list of IDs ( returned value )
visited = {}; // hash: id of already visited node => true
// 2. topological sort
Object.keys(graph).forEach(function visit(name, ancestors) {
if (!Array.isArray(ancestors)) ancestors = [];
ancestors.push(name);
visited[name] = true;
DECLARE
l_exception EXCEPTION;
lc_max_tries CONSTANT PLS_INTEGER := 3;
---
l_unsuccessful_tries PLS_INTEGER := 2;
BEGIN
<<some_loop>>
FOR iterator IN 1 .. lc_max_tries LOOP
BEGIN
dbms_output.put_line('try #' || iterator);
@s-oravec
s-oravec / plsql-format-string-utility-function
Last active August 26, 2016 22:34
I suck at regexps ...
FUNCTION formatString
(
p_string IN VARCHAR2,
p_placeholder1 IN VARCHAR2 DEFAULT NULL,
p_placeholder2 IN VARCHAR2 DEFAULT NULL,
p_placeholder3 IN VARCHAR2 DEFAULT NULL,
p_placeholder4 IN VARCHAR2 DEFAULT NULL,
p_placeholder5 IN VARCHAR2 DEFAULT NULL,
p_placeholder6 IN VARCHAR2 DEFAULT NULL,
p_placeholder7 IN VARCHAR2 DEFAULT NULL,
@s-oravec
s-oravec / idea-db-navigator-sqlcl-run-script
Created August 25, 2016 14:56
Shell script for running scripts using sqlCL from IntelliJ IDEA DB Navigator plugin
#!/bin/bash
# License: MIT (https://opensource.org/licenses/MIT)
# 2016 Stefan Oravec
# from http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
@s-oravec
s-oravec / export_graphics_on_canvases_to_pngs
Last active August 29, 2015 14:08
Export all graphics on each canvas of Omni Graffle document to separate png file (= one file per canvas)
set saveFolder to (choose folder) as string
tell application "OmniGraffle"
set theDocument to front document
set area type of the current export settings to all graphics
repeat with thisCanvas in canvases of theDocument
set canvas of front window to thisCanvas
save theDocument as "png" in file (saveFolder & name of thisCanvas & ".png")