Skip to content

Instantly share code, notes, and snippets.

@ksherlock
ksherlock / inactive.md
Created September 26, 2022 17:09
Inactive

A couple time now, I've wanted to create a few elements in Javascript. React (or preact) are too heavy or perhaps aren't appropriate and anyhow I don't want virtual doms and all that, just a real DOM. But building a DOM is tedious; JSX is much nicer. So JSX to the rescue. After all, JSX has nothing to do with virtual doms, it's just syntax sugar for building a tree. Instead of building a virtual dom, it can build a real one.

@ksherlock
ksherlock / rint.c
Created February 23, 2021 16:33
rint.c
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#define _(x) { x, #x }
static struct { int mode; char *name; } modes[] = {
_(FE_DOWNWARD),
_(FE_TONEAREST),
_(FE_TOWARDZERO),
_(FE_UPWARD),
DRIVERS = apple1.cpp apple2.cpp apple3.cpp apple2e.cpp apple2gs.cpp agat.cpp
comma = ,
empty =
space = $(empty) $(empty)
.PHONY: all
all: mame64 mame-data.tgz
@ksherlock
ksherlock / gist:2ef631b4c0994e41dacc9f8d9a664b15
Created November 24, 2018 17:23
Assertion failed: (0), function compress_data_to_8_bit, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreGraphics/CoreGraphics-1247.4.1/CoreGraphics/Images/CGImage.c, line 640.
OS X Mojave CGImageMaskCreate():
```
Assertion failed: (0), function compress_data_to_8_bit, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreGraphics/CoreGraphics-1247.4.1/CoreGraphics/Images/CGImage.c, line 640.
```
The issue seems to occur with 24-bit RGB images. 32-bit (RGBA) or 8 bit (greyscale) do not assert.
`pngcrush -noreduce -c [0|2|4|6] input.png output.png`
#!/usr/bin/env ruby -w
def to_b(x, width = 16)
tmp = x.to_s(2)
tmp = ("0" * (width - tmp.length)) + tmp
tmp.tr!('01',' #')
tmp
end
@ksherlock
ksherlock / rise_again.txt
Created December 7, 2017 02:30
rise again (rehearsal) by Bob Dylan
(words/music by Dallas Holm)
G G+ C G x 2
G G/F C /b Am D G x2
throw in an occasional G-C/G-G and Dsus4 for good measure.
@ksherlock
ksherlock / gist:7ea3b4e882531058585761401e72683a
Created December 1, 2017 18:29
Ain't no man righteous, no not one chords
(Live version)
----------------
----------------
----------------
--------0-1-2---
-0--4-4---------
----------------
----------------
$ ./bin/iix gs.out arg1 arg2
frame #1 $0201d6 ORCA.C at main:51
48 int i = 0;
49 int j = 1;
50 int x;
-> 51 x = i + j;
52 return x;
53
54 }
@ksherlock
ksherlock / s16debug.c
Created September 28, 2017 16:08
s16debug.c
#include "s16debug.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <tcpip.h>
#include <tcpipx.h>
#pragma optimize 79
@ksherlock
ksherlock / s16debug.h
Created September 28, 2017 16:07
s16debug.h
#ifndef __s16_debug_h__
#define __s16_debug_h__
void s16_debug_puts(const char *str);
void s16_debug_printf(const char *format, ...);
void s16_debug_dump(const char *data, unsigned size);
void s16_debug_tcp(unsigned ipid);
#ifdef __TCPIP__