Skip to content

Instantly share code, notes, and snippets.

View martincohen's full-sized avatar

Martin Cohen martincohen

View GitHub Profile
@martincohen
martincohen / struct.lua
Last active April 25, 2022 02:05
Tiny binary writer and reader in Lua.
-- struct.lua
-- Tiny binary writer and reader in Lua.
-- version: 1.3
-- author: Martin 'Halt' Cohen
-- url: https://twitter.com/martin_cohen
-- license: MIT
-- changes: at the end of this file
-- dependencies:
-- http://bitop.luajit.org
local function read_uint16_le(bytes, offset)
local a, b = bytes:byte(offset + 1, offset + 2)
return a + b * 0x100
end
local function read_uint16_be(bytes, offset)
local a, b = bytes:byte(offset + 1, offset + 2)
return a * 0x100 + b
end
#include <co-rune.h>
void
corune_data_test_grapheme_break_property()
{
COASSERT(corune_get_grapheme_break_property(0x0e1000) == 0);
for (int i = 0x000600; i <= 0x000605; ++i) {
COASSERT(corune_get_grapheme_break_property(i) == 12);
}
for (int i = 0x0006dd; i <= 0x0006dd; ++i) {
#pragma once
// 1. co-rune-grapheme-break + state machine
// 2. co-rune-general-category
// 3. co-rune-case-mapping
#define CO_RUNE_DATA_LZ_SIZE_UNPACKED 15120
uint8_t CO_RUNE_DATA_LZ[6526] =
{
/*****************************************************************************
* directsound.c: DirectSound audio output plugin for VLC
*****************************************************************************
* Copyright (C) 2001-2009 VLC authors and VideoLAN
* $Id: 2f5b9f46d3739e513d875b950eaf4d2df641f9dc $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
// Reformatted version from here:
// https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4422&lngWId=3
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
/*
* some good values for block size and count
*/
#define BLOCK_SIZE 8192
typedef struct UITextEditor
{
int text_capacity;
int text_length;
char *text;
int cursor;
}
UITextEditor;
void
@martincohen
martincohen / pcx.h
Created November 20, 2015 23:44
Tiny PCX reader
#ifndef PCX_H
#define PCX_H
#include <assert.h>
#include "common.h"
typedef struct PCXHeader
{
u8 id;
struct ScratchMemory {
void *base;
memi capacity;
};
void child(ScratchMemory *memory,...) {
// do things to memory
}
void parent(ScratchMemory *memory,...) {