Skip to content

Instantly share code, notes, and snippets.

View okikio's full-sized avatar
🏠
Working from home

Okiki Ojo okikio

🏠
Working from home
View GitHub Profile
@okikio
okikio / beta-distribution.ts
Last active January 4, 2023 02:25
beta-distribution.ts
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@okikio
okikio / README.md
Last active January 10, 2023 06:51
uint8array-to-utf-8.ts
@okikio
okikio / lzuint8array.js
Created February 14, 2023 05:21 — forked from JobLeonard/lzuint8array.js
Uint8Array to LZ-string and back
const LZuint8Array = (function () {
/*
basic ranges of printable UTF16 values (as found in LZ-string):
[32, 127), [160, 55296), [63744, 65536)
We also have filter out string characters like:
" (34)
' (39)
` (44)
(Forward tick is safe: ´ (96))
So:
@okikio
okikio / bundlejs_core.mjs
Last active February 14, 2023 17:40
The bundled src code for @bundlejs/core
This file has been truncated, but you can view the full file.
var P5=Object.create;var s3=Object.defineProperty;var h5=Object.getOwnPropertyDescriptor;var d5=Object.getOwnPropertyNames;var K5=Object.getPrototypeOf,H5=Object.prototype.hasOwnProperty;var H1=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var z1=(e,t)=>()=>(e&&(t=e(e=0)),t);var U5=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),n1=(e,t)=>{for(var n in t)s3(e,n,{get:t[n],enumerable:!0})},S5=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of d5(t))!H5.call(e,a)&&a!==n&&s3(e,a,{get:()=>t[a],enumerable:!(r=h5(t,a))||r.enumerable});return e};var V2=(e,t,n)=>(n=e!=null?P5(K5(e)):{},S5(t||!e||!e.__esModule?s3(n,"default",{value:e,enumerable:!0}):n,e));var p2=U5((y8,T0)=>{"use strict";var c3=Object.defineProperty,u5=Object.getOwnPropertyDescriptor,j5=Object.getOwnPropertyNames,R5=Object.pro
@okikio
okikio / opfs.ts
Created April 21, 2023 23:43
opfs.ts - API
const isWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
async function getHandleFromPath(path: string) {
const pathParts = path.split('/').filter(part => part.length > 0);
let currentHandle = await navigator.storage.getDirectory();
for (const part of pathParts) {
if (part === '..') {
currentHandle = await currentHandle.getParent();
} else {
@okikio
okikio / dom-expressions.ts
Created June 10, 2023 01:00
dom-expressions.ts
import { signal, effect } from 'https://esm.sh/usignal';
// Function to check if an expression is iterable
function isIterable(expression) {
return Symbol.iterator in Object(expression);
}
// Function to create a new DOM range for an expression
function createDOMRange(domElement, expression) {
const textNode = document.createTextNode(evaluateExpression(expression.expr));
@okikio
okikio / mod.ts
Created January 5, 2024 07:53
Un-Escape Typescript Code
import * as ts from "https://esm.sh/typescript"
/**
* Determines whether escape sequences in a token of a specific kind should be preserved.
* Useful for maintaining the integrity of literals where escape characters are meaningful.
*
* @example
* // Simple: In string literals like `"Hello\nWorld"`, the `\n` should be preserved.
* shouldPreserveEscapes(ts.SyntaxKind.StringLiteral);
*
@okikio
okikio / ideas.md
Created March 27, 2024 06:02
Unified URI Spec. Brainstorm

Unified URI Spec. Brainstorm

Hey 👋, I was working on the proposals for unifying the URL specs. From the research I’ve done on the topic so far, we’d need a total of 2 RFC's to solve to problem and ensure it never occurs again.

Unified URI RFC (RFC 1)

The 1st RFC (The Unified URI RFC) will use the original 2005 URI RFC as it’s basis, then build on top of it the modern WHATWG URL standard. Alwin Blok already created a new URL Spec. proposal to try to accomplish this very goal, we’ll investigate what changes there are between both RFC’s and the new proposal by Alwin, and look to create a Unified RFC from that.

Some ideas that @Randall, Jonathan Neal, and I played with were separating URI’s and URL’s.

  • URI’s represent any form a path locator ca