Skip to content

Instantly share code, notes, and snippets.

View CraigglesO's full-sized avatar
🌎
Sic Parvis Magna

地図の神様 CraigglesO

🌎
Sic Parvis Magna
View GitHub Profile
@CraigglesO
CraigglesO / index.html
Created November 10, 2023 18:46
Example bug report on pattern loading
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Step Zoom bug</title>
<script src='./dist/maplibre-gl-dev.js'></script>
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
</head>
<body>
@CraigglesO
CraigglesO / style.spec.ts
Last active October 2, 2023 11:21
New Style Spec
export type Properties = Record<string, Value>
export type ConditionFunction = (input: string | number, properties: Properties) => boolean
export type FilterFunction = (properties: Properties) => boolean
export interface Conditional {
keyCondition?: {
key: string
keyFunction: ConditionFunction
@CraigglesO
CraigglesO / README.md
Created July 7, 2023 12:01
vector tile spec

S2 Vector Tile Specification 2.0.0

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

1. Purpose

This document specifies a space-efficient encoding format for tiled geographic vector data. It is designed to be used in browsers or server-side applications for fast rendering or lookups of feature data.

@CraigglesO
CraigglesO / spec.json
Created June 12, 2023 12:55
style spec
{
classes: [
{
name: 'class1',
source: 'source1',
type: 'fill',
filter: ['==', 'name', 'value'],
layers: [
{
name: 'layer1',
@CraigglesO
CraigglesO / game.zig
Created May 4, 2023 10:14
Wasm zig fix 2
const std = @import("std");
const builtin = std.builtin;
const allocator = std.heap.page_allocator; //it maps directly to WebAssembly memory.
//based on https://github.com/daneelsan/zig-wasm-logger
const Imports = struct {
extern "env" fn _throwError(pointer: [*]const u8, length: u32) noreturn;
pub fn throwError(message: []const u8) noreturn {
@CraigglesO
CraigglesO / game.js
Created May 4, 2023 10:14
zig wasm example fix
// game.js - load the WASM, display the game, update the engine
let console_log_buffer = "";
//let memory = null; //hack for decodeString to work
//let allocUint8 = null;
//based on https://github.com/daneelsan/zig-wasm-logger/blob/master/script.js
let wasm = {
instance: undefined,
@CraigglesO
CraigglesO / manBoyTestFails.zig
Created April 11, 2023 17:26
Non working solution to the man boy problem in zig
const std = @import("std");
const Func = *const fn () i32;
fn x (comptime n: i32) Func {
return struct {
fn lambda() i32 { return n; }
}.lambda;
}
@CraigglesO
CraigglesO / manBoyTest.zig
Last active April 11, 2023 17:30
Man Boy Test Written in Zig
const std = @import("std");
const Frame = struct {
f: *const fn (frame: *Frame) i32,
k: *i32 = undefined,
x1: *Frame = undefined,
x2: *Frame = undefined,
x3: *Frame = undefined,
x4: *Frame = undefined,
x5: *Frame = undefined,
@CraigglesO
CraigglesO / testProto.zig
Created April 8, 2023 17:16
Showing strange behavior with zig StringHashMap
const std = @import("std");
const testing = std.testing;
const ArrayList = std.ArrayList;
const StringHashMap = std.StringHashMap;
pub const Protobuf = struct {
buf: ArrayList(u8),
pos: usize,
len: usize,
allocator: std.mem.Allocator,
@CraigglesO
CraigglesO / async.js
Last active August 12, 2022 21:19
Zig using async/await in WASM
const fs = require('fs')
const source = fs.readFileSync('./async.wasm')
function u32ToU8 (num) {
const resU32 = new Uint32Array([num])
return new Uint8Array(resU32.buffer)
}
function getMemory (instance) {
return new Uint8Array(instance.exports.memory.buffer)