Skip to content

Instantly share code, notes, and snippets.

View gahrae's full-sized avatar

Gareth gahrae

  • Newmarket, NH, USA
View GitHub Profile
@gahrae
gahrae / GET_ARRAY
Created August 17, 2025 19:30
Excel lambda function to get array data (default is top-down, but can get left-to-right, or both, e.g. 2D array).
=LAMBDA(cell, [seek_down], [seek_right],
LET(
MAX_COLS, 16384,
MAX_ROWS, 1048576,
sd, IF(ISOMITTED(seek_down), TRUE, seek_down),
sr, IF(ISOMITTED(seek_right), FALSE, seek_right),
start_row, ROW(cell),
start_col, COLUMN(cell),
IF(
ISBLANK(cell),
@gahrae
gahrae / case_1983_kilgore_texas_kfc.pl
Created August 2, 2025 16:46
Prolog program on the 1983 KFC murders
% Kentucky Fried Chicken Murders - Kilgore, Texas (1983)
% Comprehensive Prolog Knowledge Base for Case Analysis
%
% SOURCES:
% - Transcript from YouTube video: https://www.youtube.com/watch?v=_81kTZ0MxjI
% - Wikipedia: https://en.wikipedia.org/wiki/Kentucky_Fried_Chicken_murders
% ============================================================================
% CASE OVERVIEW
% ============================================================================
@gahrae
gahrae / storyer.story
Last active July 29, 2025 14:36
Prototype data for interactive prolog story creation
{
"title": "Storyer",
"content": "Once upon a time, in a land far, far away, lived a brave knight named <span class=\"annotated-text\" data-prolog-fact=\"hero(sir_reginald).\">Sir Reginald</span>. He was known throughout the kingdom for his courage and his unwavering commitment to justice. One day, a fearsome dragon, <span class=\"annotated-text\" data-prolog-fact=\"villain(ignis).\">Ignis</span>, descended upon the peaceful village of <span class=\"annotated-text\" data-prolog-fact=\"location(oakhaven).\">Oakhaven</span>, demanding tribute. The villagers, terrified, turned to Sir Reginald for help.\n\nSir Reginald, without hesitation, donned his shining armor and sharpened his trusty sword. He knew the <span class=\"annotated-text\" data-prolog-fact=\"travels_to(sir_reginald, dragons_peak).\">journey to Ignis's lair, nestled deep within the treacherous Dragon's Peak</span>, would be perilous. Along the way, he encountered a wise old wizard, <span class=\"annotated-text\" data-prolog-fact=\"helper(elara).
@gahrae
gahrae / riverside_murder.als
Last active July 28, 2025 15:09
Riverside Murder in the Alloy programming language
// Where to download Alloy: https://alloytools.org/download.html
// Run within Alloy: java -jar org.alloytools.alloy.dist.jar
// The Riverside Diner Murder Mystery
// Recreated from Prolog to Alloy
// Define the people involved in the investigation
abstract sig Person {}
one sig Elena, David, James, Lisa, Tom extends Person {}
@gahrae
gahrae / riverside_murder.pl
Created July 27, 2025 00:38
solve the riverside murder with prolog
% Read article at
% https://medium.com/@gareth.stretton/the-riverside-diner-murder-a-logic-programming-investigation-b8ea0f54bae6
% Original facts remain the same
missing_knife(elena).
missing_knife(david).
matching_tires(james).
matching_tires(lisa).
matching_tires(david).
@gahrae
gahrae / PrologInterpreter.java
Created July 25, 2025 14:00
Demo minimal Prolog interpreter for finding 'Hunting Buddies' program
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class PrologInterpreter {
// Represents a Prolog term (fact or rule component)
public static class Term {
String predicate;
List<String> arguments;
@gahrae
gahrae / HuntingBuddies.java
Created July 25, 2025 13:37
Convert Prolog program to Java
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class HuntingBuddies {
// Person class with attributes
public static class Person {
private String name;
private boolean hasJob;
DOI 1:1
“When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another...”
DOI 1:2
“...a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.”
DOI 2:1
“We hold these truths to be self-evident, that all men are created equal...”
DOI 2:2
-- Purpose: Debug a single Java class from within LazyVim
-- Overview of steps:
-- 1. Update ~/.config/nvim/lua/config/lazy.lua to enable the 'Java Extra'
-- 2. Add new plugin config at ~/.config/nvim/plugins/debug_java.lua
-- 3. Test: Add break point, hit <leader>dA, Observe debugging in action.
-- Notes:
-- 1. Works for a single Java file, larger projects likely will need other steps or configuration
-- 2. Solution was found on Reddit, see reference 1.
-- References:
-- 1) Reddit: https://www.reddit.com/r/neovim/comments/subfv1/help_setting_up_debugger_for_java/
@gahrae
gahrae / telekasten.lua
Created December 10, 2023 01:35
LazyVim 'plugin configuration file' for Telekasten with extra functions to yank a link to a specific heading, line, or with a description.
-- Purpose:
-- 1. Demonstrate configuring Telekasten with LazyVim 'plugin configuration' file.
-- 2. Add ability to create links to ...
-- - a heading under the cursor
-- - a specific line under the cursor (using a 'block reference')
-- - the file with a description entered at a prompt
-- 3. Demonstrate having a main vault and seperate one(s) for work
-- Usage: (look for 'TODO')
-- 1. Save as ~/.config/nvim/plugins/telekasten.lua
-- 2. Create directories for vault(s)