Skip to content

Instantly share code, notes, and snippets.

View gusalbukrk's full-sized avatar

Gustavo Albuquerque gusalbukrk

View GitHub Profile
@gusalbukrk
gusalbukrk / TPT.sql
Last active August 7, 2023 17:47
#sql
-- model inheritance in database
-- table per type
-- https://stackoverflow.com/a/190306
CREATE TABLE users (
id SERIAL,
email VARCHAR(50) NOT NULL,
password VARCHAR(20) NOT NULL,
PRIMARY KEY (id)

SQL

Joins

Joining one-to-many relationship

  • if you perform an inner join between the two tables customer and order, the result will contain a row for each combination of customer and order
  • for instance, if you have 3 customers and each customer has 2 orders, the total number of rows in the result would be 6 (the same quantity of rows in the orders table)
  • in a one-to-many relationship, when you perform an inner join between the "one" table and the "many" table, the number of rows in the result will be equal to the number of rows in the "many" table
  • if you need to include the NULL values from the "one" table in a one-to-many relationship, you can use an outer left join
@gusalbukrk
gusalbukrk / README.md
Created June 20, 2023 14:56
#form #validation

Form validation

checkValidity(), validity states

<form>
  <input type="text" id="input" pattern="^[A-Z]*$" minlength="3">
</form>
<script>
  const input = document.getElementById('input');
@gusalbukrk
gusalbukrk / puppeteer.md
Last active June 5, 2023 01:48
#puppeteer

puppeteer

basic usage

import fs from 'fs';
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
@gusalbukrk
gusalbukrk / example.sql
Last active May 10, 2023 21:08
#plpgsql
DROP TABLE IF EXISTS primary_keys;
CREATE TABLE primary_keys (
table_name varchar(25) NOT NULL,
colnames text[] NOT NULL
);
-- https://www.enterprisedb.com/postgres-tutorials/how-use-event-triggers-postgresql
-- https://gist.github.com/Checksum/5942ad6a38e75d71e0a9c0912ac83601
CREATE OR REPLACE FUNCTION handle_CREATE_TABLE_fn()
RETURNS event_trigger
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1tnw45g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="12.0.0">
<bpmn:collaboration id="Collaboration_0ldzokh">
<bpmn:participant id="Participant_1y3ubez" name="Gestão da Manutenção" processRef="Process_0gglgjk" />
<bpmn:participant id="Participant_13d1tnq" name="Compras" processRef="Process_1j3kbkf" />
<bpmn:messageFlow id="Flow_14ayo9j" name="Requisitos de aquisição para manutenção" sourceRef="Activity_1cxz70v" targetRef="Participant_13d1tnq" />
</bpmn:collaboration>
<bpmn:process