Skip to content

Instantly share code, notes, and snippets.

View JonathanTurnock's full-sized avatar

Jonathan Turnock JonathanTurnock

View GitHub Profile
@JonathanTurnock
JonathanTurnock / index.ts
Created December 24, 2025 16:09
Bun INK Fullscreen App
import { Box, render, Text, useStdout } from "ink";
import { useCallback, useEffect, useState } from "react";
import { debounceTime, filter, firstValueFrom, fromEvent, map } from "rxjs";
export function useScreenSize() {
const { stdout } = useStdout();
const getSize = useCallback(() => ({ height: stdout.rows, width: stdout.columns }), [stdout]);
const [size, setSize] = useState(getSize);
.graph text {
font-family: sans-serif;
stroke: white;
paint-order: stroke;
stroke-width: 3;
stroke-linecap: square;
}
@JonathanTurnock
JonathanTurnock / setup-lua-5_1.sh
Last active June 1, 2025 18:45
Setp LUA 5.1 Windows
#!/usr/bin/env bash
set -e
echo "🔧 Updating system..."
pacman -Syuu --noconfirm
echo "📦 Installing dependencies..."
pacman -S --noconfirm --needed mingw-w64-x86_64-lua51 mingw-w64-x86_64-gcc git make unzip zip tar gzip p7zip curl wget
@JonathanTurnock
JonathanTurnock / README.md
Created May 30, 2025 23:42
Error Handling in Lua: The Idiomatic Way

🛠 Error Handling in Lua: The Idiomatic Way

Lua is known for being lightweight, embeddable, and flexible—and its approach to error handling is no different. Whether you're writing a game script, a plugin, or a CLI tool, understanding how Lua handles errors is essential for writing clean, maintainable code.

In this article, we'll explore:

  • The basic mechanisms of error handling in Lua
  • When to use error() vs returning nil, err
  • Best practices for writing robust functions and libraries
@JonathanTurnock
JonathanTurnock / client.ts
Last active January 2, 2025 22:15
Miminal Typescript RPC
import { RpcClient } from "./rpc.ts"
import type { RpcAPI } from "./router.ts"
export const client = new RpcClient<RpcAPI>();
const foo = rpcClient.get("foo");
foo.getFoo().then(console.log)
@JonathanTurnock
JonathanTurnock / server.ts
Created January 20, 2024 12:19
Electron subprocess
import { randomUUID } from "node:crypto";
import * as os from "os";
import Aigle from "aigle";
import { UtilityProcess, utilityProcess } from "electron";
import { compact, flatten, values } from "lodash";
import { z } from "zod";
import { trpc } from "../trpc";
type ServerEntry = {
id: string;
@JonathanTurnock
JonathanTurnock / App.jsx
Created September 29, 2023 22:04
Mobx simple example
// App.js
import React from "react";
import { observer } from "mobx-react-lite";
import { counterStore } from "./store";
const App = observer(() => {
return (
<div>
<h1>{counterStore.count}</h1>
<button onClick={() => counterStore.increment()}>Increment</button>
@JonathanTurnock
JonathanTurnock / COORDS.md
Created August 7, 2023 09:29
Geo Coordinate Systems

1. Geographic Coordinates

The most recognized method to pinpoint a location. It uses:

  • Latitude (lat): Specifies how far north or south a point is from the Equator.
  • Longitude (lon): Details how far east or west a point is from the Prime Meridian.

2. Cartesian Coordinates

Often employed in computer graphics and mathematics:

  • 2D Cartesian:
    • x: Represents the horizontal axis (often east-west direction).
  • y: Represents the vertical axis (often north-south direction).
@JonathanTurnock
JonathanTurnock / Server.js
Last active July 5, 2023 01:28
Job Scheduler
const express = require('express');
const schedule = require('node-schedule');
const { addMinutes, isValid, parseISO } = require('date-fns');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json()); // for parsing application/json
const port = 3000;
@JonathanTurnock
JonathanTurnock / README.md
Created March 31, 2023 09:25
React Function Component - Live template

React Functional Component Template

Add this to webstorm under Editor > Live Templates

Add a variable

TM_FILENAME_BASE -> capitalize(camelCase(fileNameWithoutExtension()))