Skip to content

Instantly share code, notes, and snippets.

View Jimbly's full-sized avatar

Jimb Esser Jimbly

View GitHub Profile
@Jimbly
Jimbly / setHighDPIAware.c
Created June 4, 2024 02:31
setHighDPIAware()
#ifndef DPI_ENUMS_DECLARED
typedef enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
#ifndef _DPI_AWARENESS_CONTEXTS_
typedef enum DPI_AWARENESS_CONTEXT {
DPI_AWARENESS_INVALID,
DPI_AWARENESS_UNAWARE,
assert(loadfile("common.inc"))();
askText = singleLine([[
Choose window
]]);
function sws(delay, msg)
sleepWithStatus(delay, msg, 0xFFFFFFff);
end
{
let w = 128;
let num_images = 3;
let source_canvas = document.createElement('canvas');
source_canvas.width = w;
source_canvas.height = w * num_images * 2;
let source_img = new Image();
source_img.src = source_canvas.toDataURL('image/png');
source_img.onload = function () {
let canvas = document.createElement('canvas');
@Jimbly
Jimbly / common_loader_example.ts
Created January 30, 2023 20:30
Generic common loader for wall types example
import * as assert from 'assert';
import { FSAPI, fileBaseName } from 'glov/common/fsapi';
import { DataObject } from 'glov/common/types';
type WallDesc = {
id: string; // filled in at load
other_id?: string; // from data
other_desc?: WallDesc; // reference at load-time
};
@Jimbly
Jimbly / allowDeclareFields.ts
Last active October 19, 2022 21:35
allowDeclareFields example and commentary
// The setup: I have an Entity class hierarchy for server/common/client, and each entity has
// a reference to an entity_manager, which should be templated to the appropriate type so
// that an entity getting other entities from the manager always get the correct type of
// entity back.
// The common code:
interface EntityManager<Entity extends EntityCommon = EntityCommon> {
entities: Partial<Record<number, Entity>>;
}
@Jimbly
Jimbly / EntityManagerHierarchy.ts
Created September 27, 2022 15:31
Multiple inheritence class hierarchy for an entity manager
/**
* Conceptual/Code-time hierarchy:
*
* Sever Code Common Code Client Code
*
*
* EntityGameServer EntityGameClient
* Game Code | \ / |
* | EntityGameCommon |
* | | |
@Jimbly
Jimbly / explore_to.cpp
Created June 20, 2022 23:22
libGLOV exploreTo implementation example
// Path to directory, or file, but not to a "." (e.g. c:/foo/.)
void exploreTo(const char *localfname) {
wchar_t *path = utf8ToWideAlloc(localfname);
for (wchar_t *s = path; *s; ++s)
if (*s == '/')
*s = '\\';
// Remove trailing backslash, FindFirst will fail
if (path[wcslen(path) - 1] == '\\') {
path[wcslen(path) - 1] = '\0';
}
@Jimbly
Jimbly / WindowStyles.lua
Created June 1, 2021 03:25
Modifying Window Styles in Automato
dofile("common.inc");
dofile("screen_reader_common.inc");
dofile("ui_utils.inc");
local styles = {
WS_BORDER=0x00800000,
WS_DLGFRAME=0x00400000,
-- WS_CAPTION=0x00C00000, WS_BORDER | WS_DLGFRAME
-- WS_CHILD=0x40000000, not relevant
@Jimbly
Jimbly / in.js
Last active January 18, 2021 17:03
Uglify sourcemap test
"use strict";
var _window$foo = window.foo,
a = _window$foo[0],
b = _window$foo[1];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluLmpzIl0sIm5hbWVzIjpbIndpbmRvdyIsImZvbyIsImEiLCJiIl0sIm1hcHBpbmdzIjoiOztrQkFBYUEsTUFBTSxDQUFDQyxHO0lBQWZDLEM7SUFBR0MsQyIsImZpbGUiOiJpbi5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCBbYSwgYl0gPSB3aW5kb3cuZm9vO1xuIl19
const { round, floor, ceil } = Math;
let correct = [0,0,0];
function test(dpr, dim) {
let clientWidth = round(dim / dpr);
let scaled = clientWidth * dpr;
if (round(scaled) === dim) {
correct[0]++;
}
if (floor(scaled) === dim) {
correct[1]++;