Skip to content

Instantly share code, notes, and snippets.

View cwhite92's full-sized avatar
👋

Chris White cwhite92

👋
View GitHub Profile
@cwhite92
cwhite92 / gist:f4710dbc0ce76e5b68a8
Last active August 29, 2015 14:08
Oracle tables
-- Create the base tables
CREATE TABLE products(
product_id NUMBER GENERATED ALWAYS AS IDENTITY CONSTRAINT products_product_id_pk PRIMARY KEY,
name VARCHAR2(50),
description CLOB,
price NUMBER(9, 2),
location MDSYS.SDO_GEOMETRY
)
CREATE TABLE images(
@cwhite92
cwhite92 / gist:bab0e1e9f5b4cb08a3b3
Last active August 29, 2015 14:08
Search query
DECLARE
-- This variable will hold our query string
l_query VARCHAR2(4000);
-- The lat/long values of the postcode input
l_lat VARCHAR2(100);
l_lng VARCHAR2(100);
BEGIN
-- Work out lat/long of input using Brian's procedure
IF :P1_POSTCODE IS NOT NULL THEN
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 343.22 (buildmeister@swio-display-x86-rhel47-05) Thu Sep 11 16:49:51 PDT 2014
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
@cwhite92
cwhite92 / gist:9f85a9449e72f84ff434
Last active August 29, 2015 14:09
upload_new_images procedure
CREATE OR REPLACE PROCEDURE upload_new_image (p_filename IN VARCHAR2, p_product_id IN NUMBER) IS
l_upload_size INTEGER;
l_upload_blob BLOB;
l_image_id NUMBER;
l_image ORDSYS.ORDImage;
BEGIN
-- Get the length, MIME type and the BLOB of the new image from the
-- upload table
-- apex_application_files is a synonym for WWV_FLOW_FILES
SELECT doc_size, blob_content
@cwhite92
cwhite92 / gist:63c1a834e64aa06eea51
Last active August 29, 2015 14:09
create_blob_thumbnail procedure
CREATE OR REPLACE PROCEDURE create_blob_thumbnail (p_image_id IN INTEGER) IS
l_orig ORDSYS.ORDImage;
l_thumb ORDSYS.ORDImage;
l_blob_thumb BLOB;
BEGIN
-- lock row
SELECT image
INTO l_orig
FROM images
WHERE image_id = p_image_id FOR UPDATE;
@cwhite92
cwhite92 / gist:0a71a348ebac0041cc17
Last active August 29, 2015 14:09
Google maps API lat/long trigger
CREATE OR REPLACE TRIGGER trg_products_location
BEFORE INSERT OR UPDATE OF postcode ON products FOR EACH ROW
DECLARE
l_lat VARCHAR2(100);
l_lng VARCHAR2(100);
BEGIN
brian.POSTCODE_TO_LAT_LNG_GM_API(:NEW.POSTCODE, l_lat, l_lng);
:NEW.LOCATION := SDO_GEOMETRY(2001, -- SDO_GTYPE
8307, -- SDO_SRID
@cwhite92
cwhite92 / gist:85ed457b4d68b285d688
Created December 5, 2014 15:53
Archive product SQL
UPDATE products
SET archived = 'Y'
WHERE product_id = :P2_PRODUCT_ID;
@cwhite92
cwhite92 / gist:48ad7fb5538280eff5ee
Created December 10, 2014 01:20
Upload new image select list conditional
SELECT NAME, P.PRODUCT_ID FROM PRODUCTS P
LEFT JOIN IMAGES I ON P.PRODUCT_ID = I.PRODUCT_ID
WHERE I.PRODUCT_ID IS NULL
AND ARCHIVED = 'N'
@cwhite92
cwhite92 / gist:b97f2679393074fb5090
Last active April 23, 2021 13:10
Force download of BLOB
// Create URL to download the blob file
var url = URL.createObjectURL(blob);
// Create hidden anchor and click it to initiate the download
a = document.createElement('a');
document.body.appendChild(a);
a.style = 'display: none';
a.href = url;
a.download = conn.metadata.filename;
a.click();
class CarbonTrait {
public function __get($property) {
if (in_array($property, $this->accessMutateDates)) {
return new Carbon(parent::__get($property));
}
return parent::__get($property);
}