This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Autogenerated Documentation For Justfiles | |
# This was created to support this issue ticket https://github.com/casey/just/issues/2033#issuecomment-2278336973 | |
import json | |
import subprocess | |
from typing import Any | |
# just --dump --dump-format json --unstable | jq > test.json | |
json_output = subprocess.run( | |
["just", "--dump", "--dump-format", "json", "--unstable"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def escape_markdown_inline_code(value_string): | |
# Find the longest contiguous sequence of backticks in the string then | |
# wrap string with appropriate number of backticks required to escape it | |
max_backticks = max((len(match.group(0)) for match in re.finditer(r'`+', value_string)), default=0) | |
inline_code_marker = '`' * (max_backticks + 1) | |
# If the string starts or ends with a backtick, add a space at the beginning and end | |
if value_string.startswith('`') or value_string.endswith('`'): | |
value_string = f" {value_string} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: generate_markdown_toc "AS 3000-2018 Wiring Rules.pdf" 3 | |
generate_markdown_toc() { | |
local pdf_file="$1" | |
local max_level="$2" | |
pdftk "$pdf_file" dump_data | awk -v max_level="$max_level" '/BookmarkTitle:/ {gsub("BookmarkTitle: ", ""); title=$0} /BookmarkPageNumber:/ {gsub("BookmarkPageNumber: ", ""); page=$0} /BookmarkLevel:/ {gsub("BookmarkLevel: ", ""); level=$0; if (level <= max_level) printf("%s- [ ] %s (Page %s)\n", sprintf("%" level*2 "s", ""), title, page)}' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
char *strtok_escaped(char *str, const char *delim) { | |
// Tokenise a string from a single char deliminator | |
// (strtok can deal with a deliminator string but for my purpose of splitting a psv table I only need one char) | |
// (There are better ways to optimise this, but just wanted something to work for now) | |
// https://gist.github.com/mofosyne/81c94740c0f33259606afa823562914c | |
static char *last_token_end = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Llama.cpp Repackaging Script | |
# This script facilitates the repackaging and upgrading of llamafile archives generated by Llama.cpp. | |
# This is particularly useful for users with limited internet access, by preserving existing gguf and .arg settings while replacing the llamafile engine. | |
# | |
# Usage: llamafilerepack [-h] [-f] <old> <new> | |
# -h: Display usage information. | |
# -f: Skip Version Check. | |
# -v: Verbose Mode | |
# <old>: The name of the old llamafile archive to be upgraded. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# INITIALIZE MINIMAL AUTOTOOLS BASED C PROGRAM (Brian Khuu 2024) | |
# https://briankhuu.com/blog/2024/04/11/initialise-minimal-autotools-script/ | |
set -euo pipefail | |
# Function to display usage | |
show_usage() { | |
echo "Usage: $0 [PACKAGE_NAME]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# LLM Based Frontmatter updator for Jekyll and MkDocs | |
# By Brian Khuu (2023) | |
# This script is to assist users in filling in summaries, tags, categories and other relevant fields | |
# this is especially helpful for blog posts as it makes it easier to search for posts later on. | |
# You would need an OPENAI_API_KEY to use this script so make sure to include it in your ~/.bashrc startup script | |
import os | |
import re | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
creation date: <%tp.date.now()%> | |
date: <%tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")%> | |
tags: <%tp.date.now("GGGG-[W]WW-E", 0, tp.file.title, "YYYY-MM-DD")%>, <%tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")%> | |
alias: <%tp.date.now("dddd Do MMMM YYYY", 0, tp.file.title, "YYYY-MM-DD")%> | |
--- | |
# <%tp.date.now("dddd Do MMMM YYYY", 0, tp.file.title, "YYYY-MM-DD")%> | <%tp.date.now("[Week] W", 0, tp.file.title, "YYYY-MM-DD")%> | |
- ISO_8601: <%tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")%> | |
- ISO_week_date: <%tp.date.now("GGGG-[W]WW-E", 0, tp.file.title, "YYYY-MM-DD")%> | |
- [[Index#Quick reference]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Based on https://techviewleo.com/how-to-install-android-studio-on-debian/ | |
## You may need to update the url from https://developer.android.com/studio | |
DOWNLOAD_LINK=https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2022.3.1.19/android-studio-2022.3.1.19-linux.tar.gz | |
ZIPNAME=android-studio-2022.3.1.19-linux.tar.gz | |
## Get latest jdk | |
sudo apt-get update | |
sudo apt-get install default-jdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Automated application of WiFi Print Server: From a Raspberry Pi Zero W to Windows 10/11 By brighterfusion from instructables | |
# This helper script was written by Brian Khuu on 2023 for https://www.instructables.com/WiFi-Print-Server-From-a-Raspberry-Pi-Zero-W-to-Wi/ | |
# To run this shell script on gist (ref: https://gist.github.com/mob-sakai/174a32b95572e7d8fdbf8e6f43a528f6) | |
# Run this script via curl: | |
# bash <(curl -sL https://gist.githubusercontent.com/mofosyne/6baab7509ccd93f74d3fa225ea57d75d/raw/rpi_print_server_setup.bash) | |
# Run this script via wget: | |
# bash <(wget -o /dev/null -nv -O - https://gist.githubusercontent.com/mofosyne/6baab7509ccd93f74d3fa225ea57d75d/raw/rpi_print_server_setup.bash) |
NewerOlder