Skip to content

Instantly share code, notes, and snippets.

View diraneyya's full-sized avatar

Orwa Diraneyya diraneyya

View GitHub Profile
@diraneyya
diraneyya / lesson_plan.md
Last active August 16, 2025 18:18
Triggers to prevent insertions, updates, and/or deletions on a table in PostgreSQL

Introduction

In relational databases, it is possible to request that the database engine executes a function when an event is about to take place within a table. The events that can trigger such a function are INSERT, UPDATE and DELETE.

In the case of triggers called before these operations, database engines give us an additional power: the power to intervene, and possibly prevent the operation from taking place.

This is the core concept of this lesson.

Trigger Syntax in SQL

@diraneyya
diraneyya / README.md
Last active September 1, 2025 16:03
IGNORE NULL in first_value/last_value in PostgreSQL

Ignoring NULLs in PostgreSQL with first_value/last_value

In the SQL snippet below, you see custom aggregates that are similar to first_value/last_value but which ignore NULL values, making them more useful in my opinion.

-- "s" stands for state, "v" stands for value, "sf" stands for state (transition) function
-- since these are defined as 'strict', "s" is the previous, while "v" is the next, non-null
-- value in the defined window.

create or replace function sf_first_value_ignore_nulls(s anyelement, v anyelement)

Dog Head Wound Care Instructions - Ghana

What to Buy at the Pharmacy

Ask for these exact names (all common in Ghana):

  1. Dettol Antiseptic Liquid (brown liquid in bottle - around 40-50 cedis for 250ml)
    • Also called "Dettol Liquid"
    • Most pharmacies have this
function numBusesToDestination(
routes: number[][],
source: number,
target: number
): number {
// 1 <= routes.length (n) <= 500.
// 1 <= routes[i].length (m) <= 10^5
// construct a hashmap for stops | O(m x n)
@diraneyya
diraneyya / proxmosh.sh
Last active October 3, 2025 10:30
A jump script for the mobile shell (Mosh) when used to connect to Proxmox containers/VMs via its root PVE node
#!/usr/bin/env bash
# The public IP address or the Dynamic DNS hostname of the
# proxmox host, which can be resolved to a public IP address
PROXMOX_HOST=host.dyndns.org
# A single TCP port that is used for initiating a connection
PROXMOX_TCP_PORT=2222
# A range of UDP ports that can be used for each Mosh session
PROXMOX_UDP_PORTS=60001:60008