Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Thomas P. Fuller thospfuller

🎯
Focusing
View GitHub Profile
@thospfuller
thospfuller / PGNotificationListenerInPostGreSQLDatabaseExample.groovy
Last active Jul 21, 2020
An example implementation of the com.impossibl.postgres.api.jdbc.PGNotificationListener specification.
View PGNotificationListenerInPostGreSQLDatabaseExample.groovy
@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 / H2EventListenerExample.groovy
Last active Jul 21, 2020
An example implementation of the org.h2.api.DatabaseEventListener specification.
View H2EventListenerExample.groovy
@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 / DatabaseChangeListenerInOracleDatabaseSQLExample.sql
Created Jul 24, 2020
An example of the preconditions required in order to run the DatabaseChangeListenerInOracleDatabaseExample.groovy script.
View DatabaseChangeListenerInOracleDatabaseSQLExample.sql
--
-- 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 Jul 25, 2020
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.
View DatabaseChangeListenerInOracleDatabaseSQLExample.sh
#
# 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
#
View DatabaseChangeListenerInOracleDatabaseExample.groovy
@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 / gist:6484f9a682a5f3ad84a190206b4937f8
Last active Aug 7, 2020
An example of the table_change trigger and notify_change function required to run the PGNotificationListenerInPostGreSQLDatabaseExample.groovy script.
View gist:6484f9a682a5f3ad84a190206b4937f8
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.
--
@thospfuller
thospfuller / uploadFile.js
Created Aug 12, 2020
An example Node script which uploads a file to AWS S3.
View uploadFile.js
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 Aug 25, 2020
An example node.js script which creates a single EC2 t2.micro instance with two [cost allocation] tags assigned: costCenter and department.
View AWSCreateEC2InstanceWithTag.js
/**
* 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 Sep 2, 2020
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.
View options-ssl-apache.conf
#
# Test with:
#
# https://www.immuniweb.com/ssl/
#
# Change applied to:
#
# /etc/letsencrypt/options-ssl-apache.conf
#
SSLProtocol +TLSv1.3
@thospfuller
thospfuller / question-five-deployment.yaml
Last active Nov 17, 2020
Practice Exam for Certified Kubernetes Application Developer (CKAD) Certification Question 5 Deployment Yaml
View question-five-deployment.yaml
# See question 5 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: apps/v1
kind: Deployment