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 / b2.js
Created February 17, 2022 03:27
PUT signedURL for clients without threat of bad actors
import { AwsClient } from 'aws4fetch'
let b2
// accessKeyId -> B2 keyID
// secretAccessKey -> B2 AppKey
export const prepB2 = (accessKeyId, secretAccessKey) => {
if (!b2) b2 = new AwsClient({ accessKeyId, secretAccessKey, service: 's3' })
}
@CraigglesO
CraigglesO / report.json
Created August 11, 2022 14:19
example oura report
{
"data": [
{
"average_breath": 15.125,
"average_heart_rate": 49.875,
"average_hrv": 66,
"awake_time": 14490,
"bedtime_end": "2022-08-10T02:20:41-04:00",
"bedtime_start": "2022-08-09T14:29:41-04:00",
"day": "2022-08-10",
@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)
@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 / 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 / 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 / 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 / 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 / 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 / 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.