Skip to content

Instantly share code, notes, and snippets.

View tom-seddon's full-sized avatar

Tom Seddon tom-seddon

View GitHub Profile
@tom-seddon
tom-seddon / Makefile
Created November 10, 2021 08:43
Makefile for model-b on Unix
# vim:foldmethod=marker
STD_CFLAGS:=
LDFLAGS:=-lstdc++
#########################################################################
#
# Configuration section
#
#
@tom-seddon
tom-seddon / detectnula.txt
Created September 6, 2020 21:44
Improved Video NuLA detection code
10REM>DETECTNULA
20MODE7
30VDU23,0,8,&30,0;0;0;
40*FX9
50*FX10
60*FX151,32,16
70*FX19
80E%=FNTM
90REM 34=&22,68=&44
100*FX151,34,68
@tom-seddon
tom-seddon / mach.org
Last active January 14, 2024 16:09
Random Mach notes

Random Mach notes

mach_thread_self increments ref count

Each call to mach_thread_self adds another MACH_PORT_RIGHT_SEND refcount. For each call to mach_thread_self, you need to call mach_port_deallocate on the result.

(This does not apply to mach_task_self.)

// -*- mode:c; c-file-style: "GNU" -*-
/* This file is to be #include'd into any file that uses it.
* Everything's static, so no problem.
*/
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/* TODO
@tom-seddon
tom-seddon / ido-goto-symbol.el
Last active June 30, 2018 10:38
ido/imenu mashup.
;; Interactively invoke ido-goto-symbol in a buffer that imenu understands.
(defun tom/get-imenu-alist ()
;; clean up old imenu data -- bit cheeky
(require 'imenu)
(imenu--menubar-select imenu--rescan-item)
(imenu--make-index-alist)
(let ((name-and-pos '()))
(cl-labels ((addsymbols (symbol-list)
(when (listp symbol-list)
@tom-seddon
tom-seddon / find-definition-of-elisp-symbol.el
Last active June 30, 2018 10:38
DWIM find-function kind of affair.
;; Interactively invoke tom/find-definition-of-elisp-symbol with point on an elisp symbol.
(defvar tom/find-definition-of-elisp-symbol-history '())
(defvar tom/find-definition-of-elisp-symbol-old-marker nil)
(defun tom/find-definition-of-elisp-symbol-add-marker ()
(when tom/find-definition-of-elisp-symbol-old-marker
(ring-insert find-tag-marker-ring tom/find-definition-of-elisp-symbol-old-marker)
(setq tom/find-definition-of-elisp-symbol-old-marker nil)))
@tom-seddon
tom-seddon / solidity.el
Created June 12, 2018 12:26
Scrappy, crappy Solidity mode for Emacs
(defun solidity-mode-make-imenu-generic-expression ()
(let* ((space "[[:space:]]+")
(maybe-space "[[:space:]]*")
(ident-group "\\([A-Za-z_][A-Za-z0-9_]*\\)")
(modifier (mapconcat 'identity
'("static" "native" "export" "ephemeral" "pinned"
"const" "property" "public" "protected" "private"
"abstract" "virtual" "override" "divergent")
"\\|"))
(modifiers (concat "\\(?:\\(?:" modifier "\\)" space "\\)*")))
@tom-seddon
tom-seddon / .c
Created May 15, 2018 00:06
b2 6502 simulator snippet
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Read/Absolute
//
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
static void T1_R_ABS(M6502 *);
static void T2_R_ABS(M6502 *);
@tom-seddon
tom-seddon / README.md
Last active April 29, 2018 22:48
Arrays in C

Growable arrays in C

I don't think there's any objectively good solution to this perennial annoyance, so this is just some random thing that tries to tick the specific boxes I want ticked: simple to look at in the debugger; few/no casts during use; easy interop with existing C arrays; OK performance in an unoptimised build.

How it works

@tom-seddon
tom-seddon / x11.cpp
Created April 16, 2017 18:22
Some Xlib junk, vaguely along the lines of GetWindowPlacement/SetWindowPlacement
#include <shared/system.h>
#include "x11.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xinerama.h>
#include <string.h>
#include <shared/log.h>
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////