Skip to content

Instantly share code, notes, and snippets.

View thospfuller's full-sized avatar
🎯
Focusing

Thomas P. Fuller thospfuller

🎯
Focusing
View GitHub Profile
@thospfuller
thospfuller / H2EventListenerExample.groovy
Last active July 21, 2020 17:54
An example implementation of the org.h2.api.DatabaseEventListener specification.
@GrabConfig(systemClassLoader=true)
@Grapes(
@Grab(group="com.h2database", module="h2", version="1.4.200")
)
import org.h2.api.DatabaseEventListener
import java.sql.SQLException
import java.sql.DriverManager
public class ExampleDatabaseEventListener implements DatabaseEventListener {
@thospfuller
thospfuller / PGNotificationListenerInPostGreSQLDatabaseExample.groovy
Last active July 21, 2020 17:53
An example implementation of the com.impossibl.postgres.api.jdbc.PGNotificationListener specification.
@Grapes(
@Grab(group='com.impossibl.pgjdbc-ng', module='pgjdbc-ng', version='0.8.4')
)
import com.impossibl.postgres.api.jdbc.PGConnection
import com.impossibl.postgres.api.jdbc.PGNotificationListener
import com.impossibl.postgres.jdbc.PGDataSource
PGDataSource dataSource = new PGDataSource();
dataSource.setHost("0.0.0.0")
dataSource.setPort(5432)
@thospfuller
thospfuller / gist:6484f9a682a5f3ad84a190206b4937f8
Last active August 7, 2020 15:17
An example of the table_change trigger and notify_change function required to run the PGNotificationListenerInPostGreSQLDatabaseExample.groovy script.
CREATE OR REPLACE FUNCTION notify_change() RETURNS TRIGGER AS $$
BEGIN
--
-- WARNING: Case is VERY IMPORTANT here! If we use 'exampleChannel' PG converts this to
-- examplechannel and no events will be received!!
--
-- UPDATE: [to be confirmed] Case can be handled in PostgreSQL by using double quotes.
--
-- In theory, if you had the following line as the listener, it would work in camelCase.
--
@GrabConfig(systemClassLoader=true)
//
// https://docs.oracle.com/cd/E11882_01/appdev.112/e13995/index.html?oracle/jdbc/dcn/DatabaseChangeRegistration.html
//
// https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc6
@Grapes(
@Grab(group='com.oracle.database.jdbc', module='ojdbc6', version='11.2.0.4')
)
import oracle.jdbc.dcn.DatabaseChangeListener
@thospfuller
thospfuller / DatabaseChangeListenerInOracleDatabaseSQLExample.sql
Created July 24, 2020 20:34
An example of the preconditions required in order to run the DatabaseChangeListenerInOracleDatabaseExample.groovy script.
--
-- This is required otherwise notifications won't be sent to the JDBC driver.
--
grant change notification to system;
commit;
CREATE TABLE example(
example_id NUMBER(10) PRIMARY KEY,
phrase VARCHAR2(120) NOT NULL
@thospfuller
thospfuller / DatabaseChangeListenerInOracleDatabaseSQLExample.sh
Last active July 25, 2020 13:49
An example of the command line (CLI) preconditions required in order to run the DatabaseChangeListenerInOracleDatabaseExample.groovy script. This example was running on a System76 machine with the Ubuntu operating system.
#
# In this example Docker is running on another machine so assume that I've ssh'd into that box and
# am running the following on the remote machine.
#
docker run -d -p 1521:1521 oracleinanutshell/oracle-xe-11g
docker exec -it [container id] /bin/sh
su
#
# Username: system, password: oracle
#
@thospfuller
thospfuller / uploadFile.js
Created August 12, 2020 03:45
An example Node script which uploads a file to AWS S3.
const fs = require('fs');
const AWS = require('aws-sdk');
const zlib = require('zlib');
const stream = require('stream');
AWS.config["credentials"] = new AWS.SharedIniFileCredentials({profile: 'some-test-profile'});
AWS.config["logger"] = console;
const s3Obj = new AWS.S3();
@thospfuller
thospfuller / AWSCreateEC2InstanceWithTag.js
Created August 25, 2020 20:23
An example node.js script which creates a single EC2 t2.micro instance with two [cost allocation] tags assigned: costCenter and department.
/**
* Precondition:
*
* - npm install aws-sdk
*/
const AWS = require('aws-sdk');
AWS.config["credentials"] = new AWS.SharedIniFileCredentials({profile: 'thospfuller-aws-cli'});
@thospfuller
thospfuller / options-ssl-apache.conf
Created September 2, 2020 19:00
This change will set TLS to version 1.3 and is applied in the Apache Let's Encrypt configuration file in Ubuntu as specified below.
#
# Test with:
#
# https://www.immuniweb.com/ssl/
#
# Change applied to:
#
# /etc/letsencrypt/options-ssl-apache.conf
#
SSLProtocol +TLSv1.3
@thospfuller
thospfuller / q1_dot_1_pod-a_configuration.yaml
Last active July 15, 2022 13:03
Practice Exam for Certified Kubernetes Application Developer (CKAD) Certification Question 1.1 Configuration Yaml
# See question 1.1 from the article entitled "Practice Exam for Certified Kubernetes Application Developer (CKAD) Certification".
#
# https://matthewpalmer.net/kubernetes-app-developer/articles/ckad-practice-exam.html
#
# Answered in the article entitled "Answers to Five Kubernetes CKAD Questions (2020)" here:
#
# https://thospfuller.com/2020/11/09/answers_to_five_kubernetes_ckad_questions_2020/
#
apiVersion: v1
kind: Pod