Realtime Status updates using a Telegram Bot

󰃭 2024-10-02 | #automation #ci/cd #github #telegram

Or, How to Send Status Message from GitHub Actions to Telegram: A Guide

I occasionally find myself wanting a quick and easy way to send alerts and status message and a solution I keep coming back to is using a Telegram bot. Telegram is free to use, reliable and easy to setup. It only takes a few minutes to set up the a bot and fire of a test message using curl. From there you can start sending messages from just about anything that can make an HTTP request. (The same cannot be said for WhatsApp or Signal, which are considerably more complex to setup)

Continue reading 

Doubly Linked Lists

󰃭 2024-09-21 | #cs #data-structures #programming #python

Very occasionally I write articles or long form notes around some idea or piece of technology that I want to think more deeply about, this is one of those notes that I managed to organise into a post, this time exploring the time honoured double Linked List data structure.

doubly linked list is a data structure that contains a collection of nodes, each of which holds references to both the previous and next nodes in the list. In addition to these references, each node contains some data (or a reference to some data). The two references (or links) to the previous and next nodes are what give this data structure its name.

Continue reading 

Time Machine Backups Using Proxmox, Ubuntu and an External USB Drive

󰃭 2024-09-01 | #homelab #proxmox #timemachine #ubuntu

This guide assumes you already have a Proxmox host, at the time of writing v8.2 was current, which is what I used. It also assumes you have a basic Ubuntu 24.04 VM running on that host. If not, you should set that up first. The VM can be fairly minimal; for example, 8GB of storage and 1GB of RAM should more than suffice.

It also assumes you have a USB Storage device that you want to use for backing up macOS using Time Machine.

Continue reading 

pwsh64.sh - PowerShell amd64/x64 Docker Runner

󰃭 2024-08-07 | #docker #macos #powershell #programming

This post presents a bash script that allows you to run PowerShell commands and scripts in an x64 environment using Docker on Arm based systems. It’s particularly useful for those using Apple Silicon (or other ARM based systems) who need to run x64-only PowerShell tools.

Prerequisites

  • Docker installed and running on your system

Usage

  1. Save the script somewhere on your computer (and optionally add it to your $PATH)

  2. Make the script executable:

    Continue reading 

Graph DB with Postgres

󰃭 2024-07-10 | #cs #data-structures #database #postgres

The Big Idea

In this post we will leverage the power of PostgreSQL Common Table Expression to create a makeshift graph database. The goal is to represent nodes (things like stories, tags, etc.) and edges (connections between those things) using relational tables. This allows us to query and traverse the data as if we were working with a ‘real’ graph database.

  • entity_map: This table is like our directory of entity types. It maps different types of entities (e.g., stories, tags) to their respective tables. It tells us where to find the actual data for each type of entity.
  • nodes: Think of nodes as the individual items in your graph. For example, each story or tag is a node. Each node gets a unique ID, and it references an entry in the entity_map to tell us what type of entity it is (story, tag, etc.).
  • edges: These are the connections between nodes. For example, if a story is tagged with a particular tag, there’s an edge between the “story” node and the “tag” node. The parent_node_id and child_node_id represent that connection.

Example table schema

CREATE TABLE stories (
    id          uuid default uuid_generate_v4() PRIMARY KEY,
    title       TEXT NOT NULL,
    body        TEXT NOT NULL
);

CREATE TABLE tags (
    id          uuid default uuid_generate_v4() PRIMARY KEY,
    name        TEXT NOT NULL UNIQUE
);

-- entity types map to tables
-- will have tables for
-- stories & tags  etc
CREATE TABLE entity_map (
    -- singular entity type e.g. Story
    entity_type     TEXT NOT NULL,
    -- table that holds these entities e.g. 'stories'
    entity_table    TEXT NOT NULL,
    PRIMARY KEY (entity_type)
);

-- Nodes of our graph.
-- A row represents a node which represents a single entity
-- via a link through the entity_type and entity_id.
CREATE TABLE nodes (
    id              uuid default uuid_generate_v4() NOT NULL,
    entity_type     TEXT NOT NULL constraint nodes_entity_map_entity_type_fk references entity_map,
    entity_id       uuid NOT NULL,
    PRIMARY KEY (id)
);

CREATE UNIQUE INDEX nodes_entity_type_entity_id_uindex ON nodes(entity_type, entity_id);

-- Edges of a graph. Also known as vertex in graph theory
-- It represents the connections between nodes in a graph
CREATE table edges (
    parent_node_id   uuid NOT NULL,
    child_node_id    uuid NOT NULL,
    PRIMARY KEY (parent_node_id, child_node_id)
);

CREATE INDEX edges_child_node_id_parent_node_id_uindex ON edges(child_node_id, parent_node_id);

Querying with Recursive CTEs

We will use PostgreSQL’s Common Table Expressions (CTEs) to perform a recursive search through the graph. Here’s a quick breakdown of how this works:

Continue reading 