Skip to content

Instantly share code, notes, and snippets.

View digitalWestie's full-sized avatar

Rory digitalWestie

View GitHub Profile
@digitalWestie
digitalWestie / compress-readme.md
Last active March 9, 2026 17:30
Context aware de-duplication

Context-aware line deduplication

Summary. Deduplicate lines across one or more input files while preserving structure: every unique line is kept; every duplicate line is kept only at its first occurrence; and for each unique line we keep up to N lines of context (the lines immediately before it). Blank or whitespace-only lines are never deduplicated. Output order is the same as input order. Useful for compressing multi-page HTML→markdown where repeated headers/nav would be removed by block dedup, but we still want one copy of shared content and local context around unique content.


Usage

node compress.js [options] file1 [file2 ...]
@digitalWestie
digitalWestie / outline-guide.md
Last active December 11, 2025 16:57
Analysing Civic Conversations with Sensemaking Tools (WIP)

Analysing Civic Conversations with Sensemaking Tools

1. Introduction

Provide an overview of the guide's scope. Help readers understand what the guide covers and how it relates to other resource e.g. the existing Jigsaw guide. The guide is about providing a way to structure an analysis project.

2. Tools and Capabilities

Familiarise readers with the available Sensemaker tools and how to access them through the Consul Democracy integration or directly using the sensemaker package. Help readers understand the basic differences between each tool.

@digitalWestie
digitalWestie / _README.md
Last active December 2, 2025 17:30
RRule strategy for Stimulus.js

RRule Builder for Rails

A Stimulus-based RRULE (iCalendar recurrence rule) builder component for Rails applications. This provides a user-friendly interface for creating recurring event schedules without requiring external dependencies like jQuery UI or React.

Overview

This RRule builder generates iCalendar-compliant RRULE strings that can be used with libraries like rrule (Ruby gem) or rrule.js (JavaScript) to calculate recurring event occurrences.

Features:

  • ✅ Pure Stimulus controller (no jQuery UI or React dependencies)
@digitalWestie
digitalWestie / turbo_association.md
Last active September 16, 2025 14:22
Turbo frame association pattern

Rails Turbo Frame Association Pattern (Updated)

A clean approach for managing many-to-many associations with search, add, and remove functionality using Turbo Frames in Rails. This updated version includes partial-based search results and bidirectional associations.

Overview

This pattern allows users to:

  • Search for items to associate
  • Add items to an association
  • Remove items from an association
@digitalWestie
digitalWestie / hamburger.html.erb
Created August 5, 2025 14:54
hamburger menu strategy for erb
<details class="relative [&>summary::-webkit-details-marker]:hidden [&>summary::marker]:hidden [&>summary]:list-none user-menu [&[open]>summary]:text-gray-600">
<summary class="cursor-pointer text-gray-400 border border-gray-400 rounded-full p-2" data-action="mouseenter->utility#openSummary toggle->utility#toggleSummaryStyle">
<%= user_icon("w-6 h-6 text-inherit") %>
</summary>
<div class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-50 border border-gray-200">
<%= link_to "View Profile", profile_path, class: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" %>
<%= link_to "Edit Profile", edit_profile_path, class: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" %>
<%= link_to "Settings", edit_user_registration_path, class: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" %>
<%= link_to "Sign out", destroy_user_session_path, data: { turbo_method: :delete }, class: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" %>
</div>
@digitalWestie
digitalWestie / AREADME.md
Last active December 20, 2024 18:05
Visualise your commits

gitvis - A git log visualiser in your terminal

image

@digitalWestie
digitalWestie / metadata.md
Created December 18, 2024 13:09
metadata options

In website headers you can link to your chosen licence, e.g. in the case of creative commons:

<link rel="license" href="http://creativecommons.org/licenses/by/4.0/" />

Likewise there's the Dublin core standard version:

@digitalWestie
digitalWestie / text-extract.md
Last active November 19, 2024 12:42
A strategy for recurisvely downloading a site and extracting the text to markdown.

Extracting text

Download site recursively

wget --mirror --convert-links --page-requisites --no-parent -P output_directory https://example.com

Options:

@digitalWestie
digitalWestie / _explainer.md
Last active January 19, 2024 13:05
Rails nested attributes view strategy

Putting related 0 to many resources within a form

For example, we have Paper and EvidenceItem models. We want to let the user add/remove/edit EvidenceItems while they are adding or editing Paper records.

The Paper model looks like this:

class Paper < ApplicationRecord

 has_many :evidence_items, dependent: :destroy
@digitalWestie
digitalWestie / cool_icons_bro.md
Last active February 17, 2026 02:44
Unicode Icon Cheatsheet