Skip to content

Instantly share code, notes, and snippets.

View vmleon's full-sized avatar

Victor Martin vmleon

  • Oracle
  • Ireland
View GitHub Profile
@vmleon
vmleon / bash.sh
Created April 17, 2021 13:12
Flask Cheroot
pip install cherrypy
nohup python server.py 2>&1 > app.log &
@vmleon
vmleon / books.http
Last active February 16, 2021 15:55
SODA books visual code rest client example
@db_url=
@user=admin
@password=
# CREATE Books
PUT https://{{db_url}}/ords/admin/soda/latest/books
Authorization: Basic {{user}}:{{password}}
###
@vmleon
vmleon / oracle-db-redaction-cleanup.sql
Created January 28, 2021 16:22
Oracle DB Security Redaction: clean up
DROP USER APP CASCADE;
@vmleon
vmleon / oracle-db-redaction-enable.sql
Created January 28, 2021 16:21
Oracle DB Security Redaction: enable redaction on column
BEGIN
DBMS_REDACT.ADD_POLICY(
OBJECT_SCHEMA => 'APP',
OBJECT_NAME => 'USERS',
COLUMN_NAME => 'CARD_NUMBER',
POLICY_NAME => 'mask_user_card_nums',
FUNCTION_TYPE => DBMS_REDACT.PARTIAL,
FUNCTION_PARAMETERS => DBMS_REDACT.REDACT_CCN16_F12,
EXPRESSION => '1=1'
);
@vmleon
vmleon / oracle-db-redaction-create.sql
Created January 28, 2021 16:18
Oracle DB Security Redaction: create schema, table, insert items and enable ORDS
CREATE USER APP IDENTIFIED BY "Str0nP4ssw0rd!";
GRANT CONNECT, RESOURCE TO APP;
GRANT UNLIMITED TABLESPACE TO APP;
CREATE TABLE APP.USERS (
ID NUMBER
GENERATED BY DEFAULT ON NULL AS IDENTITY,
NAME VARCHAR2(25),
CARD_NUMBER VARCHAR2(25)
);
@vmleon
vmleon / spatial_warehouse_branches_big_query_example.sql
Created January 14, 2021 16:13
Oracle Spatial Example: Warehouses and Branches, big query
SELECT
BRANCH_NAME,
ROUND(SDO_NN_DISTANCE(1), 2) DISTANCE_KM
FROM
BRANCHES B,
WAREHOUSES W
WHERE W.WAREHOUSE_NAME = 'Odessa Warehouse'
AND SDO_NN(B.GEOMETRY, W.GEOMETRY, 'sdo_num_res=5 unit=km', 1) = 'TRUE'
ORDER BY DISTANCE_KM;
@vmleon
vmleon / spatial_warehouse_branches_index_example.sql
Last active January 14, 2021 16:30
Oracle Spatial Example: Warehouses and Branches, index statements
INSERT INTO USER_SDO_GEOM_METADATA VALUES ('WAREHOUSES', 'GEOMETRY',
SDO_DIM_ARRAY(
SDO_DIM_ELEMENT('x', -180, 180, 0.05),
SDO_DIM_ELEMENT('y', -90, 90, 0.05)
),
4326 -- Code for Latitude/Longitude coordinate
);
INSERT INTO USER_SDO_GEOM_METADATA VALUES ('BRANCHES', 'GEOMETRY',
SDO_DIM_ARRAY(
@vmleon
vmleon / spatial_warehouse_branches_alter_example.sql
Last active January 14, 2021 16:29
Oracle Spatial Example: Warehouses and Branches, alter statements
ALTER TABLE WAREHOUSES ADD (GEOMETRY SDO_GEOMETRY);
ALTER TABLE BRANCHES ADD (GEOMETRY SDO_GEOMETRY);
UPDATE WAREHOUSES SET
GEOMETRY = SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(LON, LAT, NULL), NULL, NULL);
UPDATE BRANCHES SET
GEOMETRY = SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(LON, LAT, NULL), NULL, NULL);
@vmleon
vmleon / spatial_warehouse_branches_clean_example.sql
Last active January 14, 2021 16:16
Oracle Spatial Example: Warehouses and Branches, clean statements
DROP TABLE BRANCHES;
DROP TABLE WAREHOUSES;
DELETE FROM USER_SDO_GEOM_METADATA;
@vmleon
vmleon / spatial_warehouse_branches_insert_example.sql
Last active January 14, 2021 16:27
Oracle Spatial Example: Warehouses and Branches, insert statements
CREATE TABLE WAREHOUSES (WAREHOUSE_NAME VARCHAR2(30), LAT NUMBER, LON NUMBER);
CREATE TABLE BRANCHES (BRANCH_NAME VARCHAR2(30),ZIPCODE VARCHAR2(5), LAT NUMBER, LON NUMBER, BRANCH_TYPE VARCHAR2(30));
INSERT INTO WAREHOUSES VALUES ('Amarillo Warehouse',35.532226,-101.557617);
INSERT INTO WAREHOUSES VALUES ('Odessa Warehouse',31.334871,-102.062988);
INSERT INTO WAREHOUSES VALUES ('San Antonio Warehouse',29.496987,-98.833007);
INSERT INTO WAREHOUSES VALUES ('Waco Warehouse',31.27855,-97.097167);
INSERT INTO BRANCHES VALUES('Marshall Branch','75672',32.50555,-94.35579,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Eagle Pass Branch','78852',28.6865,-100.47394,'RETAIL');
INSERT INTO BRANCHES VALUES('Cleburne Branch','76033',32.42166,-97.38356,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Paris Branch','75460',33.66771,-95.5678,'RETAIL');