Skip to content

Instantly share code, notes, and snippets.

View Alhadis's full-sized avatar

John Gardner Alhadis

  • South Yarra, Melbourne, Australia
  • 12:07 (UTC +10:00)
View GitHub Profile
@Alhadis
Alhadis / efirestool.c
Created April 9, 2021 21:25 — forked from stek29/efirestool.c
efirestool -- tool to work with APPL efires archives
#include <sys/types.h>
#include <unistd.h> // write
#include <fcntl.h> // open, close
#include <stdio.h> // fprintf
#include <string.h> // strerror, strdup, strchr
#include <stdlib.h> // free, EXIT_*
#include <sys/mman.h> // mmap, munmap
#include <sys/stat.h> // fstat
#include <errno.h> // errno
#include <dirent.h> // DIR, dirent, opendir, readdir
@Alhadis
Alhadis / fraction-fever.fea
Created August 31, 2020 15:50
Fraction Fever
# Source: http://web.archive.org/web/20130325033504/http://talleming.com/2009/10/01/fraction-fever-2/
@figures = [
zero
one
two
three
four
five
six
seven
@Alhadis
Alhadis / Makefile
Created May 1, 2020 15:21
Installing Snack for Tcl on macOS
DEST = $(HOME)/Library/Tcl
TCL = /System/Library/Frameworks/Tcl.framework
TK = /System/Library/Frameworks/Tk.framework
X = /Developer/SDKs/MacOSX10.6.sdk/usr/X11/include
all: ../unix/Makefile
cd ../unix && $(MAKE) && $(MAKE) install
../unix/Makefile:
cd ../unix && ./configure --disable-stubs --with-tcl=$(TCL) --with-tk=$(TK) CPPFLAGS=-I$(X)
@Alhadis
Alhadis / match.mjs
Created April 29, 2020 17:26
Balanced recursive match example
#!/usr/bin/env node
// Recursive match example
let input = `$(foo $(bar $(baz) qux) qul $(quz) 1) $(almost lisp`;
const matches = [];
const stack = [];
const {length} = input;
for(let i = 0; i < length; ++i){
let char = input[i];
@Alhadis
Alhadis / Makefile
Created March 28, 2020 05:04
Stupid compilation test
BIN = ../../var/bin
LIB = ../../var/lib
SRC-MAIN = print-status.mjs
SRC-QJS = qjs-entry.mjs
NAME = git-status
TMP = $(TMP-MAIN) $(TMP-QJS)
TMP-MAIN = $(LIB)/$(SRC-MAIN)
TMP-QJS = $(LIB)/$(SRC-QJS)
BUNDLE = $(LIB)/$(NAME).mjs
@Alhadis
Alhadis / ieee-754.mjs
Last active February 27, 2020 13:01
IEEE 734.mjs
#!/usr/bin/env node
export const qNaN = Symbol("qNaN");
export const sNaN = Symbol("sNaN");
/**
* Convert a binary floating-point representation to a number.
*
* Source: IEEE 754-2008, table 3.5 – “Binary interchange format parameters”
"use strict";
const {TextBuffer, TextEditor, Range, Point} = require("atom");
const ScreenLineBuilder = loadFromCore("text-buffer/lib/screen-line-builder");
const {emitText} = ScreenLineBuilder.prototype;
const exoticNewlines = "\r";
ScreenLineBuilder.prototype.emitText = function(...args){
const {buffer} = this.displayLayer;
const [char] = args;
@Alhadis
Alhadis / config.json
Created June 18, 2019 19:30
JSDoc helpers
{
"source": {
"includePattern": "\\.+(mjs|js(on|x)?)$"
}
}
@Alhadis
Alhadis / index.html
Created May 29, 2019 12:29
select-file.js
<!DOCTYPE html>
<html lang="en-AU">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="initial-scale=1, minimum-scale=1" />
<title>Cross-browser/Electron file selection</title>
</head>
@Alhadis
Alhadis / an.tmac
Last active March 26, 2020 17:09
troff-temp
' # month name
.if "\nd"0" .nr m \n(mo-1
.if "\nm"0" .ds ]m January
.if "\nm"1" .ds ]m February
.if "\nm"2" .ds ]m March
.if "\nm"3" .ds ]m April
.if "\nm"4" .ds ]m May
.if "\nm"5" .ds ]m June
.if "\nm"6" .ds ]m July
.if "\nm"7" .ds ]m August