Skip to content

Instantly share code, notes, and snippets.

View dominicfraser's full-sized avatar

dominicfraser

  • Edinburgh, Scotland
View GitHub Profile
@dominicfraser
dominicfraser / docker_node_express_react_redux_postgres.md
Last active May 4, 2024 12:20
Dockerizing Node-Express-React-Redux-PostgreSQL Ap

Dockerizing Node-Express-React-Redux-PostgreSQL App

The full context of the code shown here can be viewed here

|-- package.json
|-- docker-compose.yml
|-- config.js
|-- table_tennis.sql
|-- zseeds.sql
@dominicfraser
dominicfraser / webpack_2_react_toolbox.md
Last active June 27, 2017 17:48
How to set up Webpack 2.6.1 for React-Toolbox

Webpack 2 setup for React-Toolbox

The full context of the code shown here can be viewed here

|-- client
    |-- package.json
    |-- postcss.config.js
    |-- webpack.config.js
@dominicfraser
dominicfraser / postgres_server_connection_setup.md
Last active July 9, 2017 19:42
Adding PostgreSQL to a Javascript server tied to a React client.

Connecting PostgreSQL to a Javascript server

The full context of the code shown here can be viewed here

|-- package.json
|-- config.js
|-- db
    |-- pgHelper.js
 |-- dbQueryHelper.js
@dominicfraser
dominicfraser / postgresql_udf_and_triggers.md
Last active May 25, 2017 08:21
Creating User Defined Functions and Triggers in PostgreSQL

UDF and Triggers in PostgreSQL

be aware that MySQL, SQL-Server, and SQLite all use different syntax, this is ONLY for PostgreSQL.

Why would you want to create a UDF that links to a Trigger? A trigger allows something to happen automatically, meaning once you have set it up you don't have to think about it again. The following example allows uses a 'games' table that takes p1_id, p2_id, p1_score, and p2_score. It has a winner_id column. This column could be populated via outside logic, but why should it be? It would be simpler, and avoid accidental error if the structure of the outside logic changed, if it was populated using an internal function, that happens whenever a new row is inserted.

The top of the .sql file looks like this:

DROP TABLE IF EXISTS games CASCADE;