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 / 1-rebase-to-branch.md
Last active February 15, 2025 22:39
Using git rebase to update your local branch.

Below is a step-by-step guide (in plain English) for rebasing your feature branch on top of main. The code is purely demonstrative—treat it as a starting point if you want an automated workflow around Git operations.

Tip

There is an attached bash script I call gitru.sh (git rebase update). It automatically rebases your local feature branch (basically it updates your local branch with changes from the main branch). Only run it on separate feature branches avoid running it on the main branch.


1. Scientific Method-Inspired Breakdown

1.1 Design Requirements & Use Cases

Solid UI is basically a fork of shadcn/ui for solidjs, it uses the exact same components and props. The only difference is that they add a couple new components, specifically

Progress Circle

Visual element to indicate progress, performance, or status represented in a circular shape.

import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { Card } from "~/components/ui/card"
import { ProgressCircle } from "~/components/ui/progress-circle"
@okikio
okikio / constrain-transform-stream-queues.md
Last active December 7, 2024 03:04
Queue's via TransformStreams

Using TransformStream in place of traditional queue implementations is an interesting approach that leverages the stream API's natural queuing and backpressure features. Below is a breakdown of how you might implement each queue type using TransformStream, adhering to the constraint of using no more than 2 TransformStreams per queue, and addressing any limitations that arise.

1. Simple Queue (FIFO Queue)

  • Implementation:
    • TransformStream 1: This stream simply passes data from the writable side to the readable side in FIFO order.
    • TransformStream 2: Not necessary in this case, as one TransformStream is sufficient to maintain the FIFO order.
const fifoQueue = new TransformStream(undefined, undefined, { highWaterMark: Infinity });
@okikio
okikio / split-iter.ts
Last active August 21, 2024 06:10
Splits a single iterator into 2 separate async iterators by some predicate or by whether an error occurs or not.
/**
* An async generator function that pulls values from the source async iterator.
*
* @template T The type of values being yielded from the source iterator.
*
* This generator yields values it receives from an external source (via `yield`).
* It also receives an initial value when invoked, which is yielded first.
*
* ### How it Works
*
// Target object
const target = {
foo: 1,
bar: 2,
};
// Fallback object
const fallback = {
bar: 20, // This will be overridden by target's bar
baz: 3,
import type { Logger as LogTapeLogger } from "@logtape/logtape";
import { deepMerge } from "@bundle/utils/utils/deep-equal.ts";
import { getLogger } from "@logtape/logtape";
export const initLogger = getLogger(["@bundle/core", "init"]);
export const buildLogger = getLogger(["@bundle/core", "build"]);
export const generalLogger = getLogger(["@bundle/core", "general"]);
// Add more loggers as needed
import type { Filter } from "./filter.ts";
import type { LogLevel } from "./level.ts";
import type { LogRecord } from "./record.ts";
import type { Sink } from "./sink.ts";
/**
* A logger interface. It provides methods to log messages at different
* severity levels.
*
* ```typescript
@okikio
okikio / spec.md
Last active June 29, 2024 08:46
Compressed Typescript Import and Export Notation (CTIE Notation)

Specification for TypeScript Import and Export Notation

Overview

This specification defines a notation format for representing TypeScript imports and exports. It is designed to be concise, flexible, and easily understandable, suitable for use in various contexts including configuration files, command-line interfaces, and documentation.

Format Design

Basic Structure

  • Imports and Exports: Use - to start import declarations and ~ to start export declarations.
  • Namespace Imports: Double bangs !! indicate namespace imports (e.g., * as name).
@okikio
okikio / filesystem.ts
Last active June 24, 2024 04:28
How to integrate into the esbuild wasm file system built into the package. Think esbuild-wasm-fs
// Based off of https://github.com/esbuild/esbuild.github.io/blob/main/src/try/fs.ts
// GitHub Permalink: https://github.com/esbuild/esbuild.github.io/blob/d405aa5f06ef359430344ca7fcbbc9bc8acf620e/src/try/fs.ts
// This file contains a hack to get the "esbuild-wasm" package to run in the
// browser with file system support. Although there is no API for this, it
// can be made to work anyway by pretending that node's "fs" API is present.
import { decode, encode } from "./encode-decode";
const enum Kind {
File,
@okikio
okikio / private-field-event-handler-delegation.ts
Last active June 20, 2024 20:56
A way to keep event handler private, but still benefit from a constant event listener object, decreasing memory overhead and ensuring private fields stay private. Inspired by https://webreflection.medium.com/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38. Demo https://codepen.io/okikio/pen/QWRmdxm
export class Component {
/**
* For perf. reasons use a class to delagate event handlers,
* this lets us avoid binds and arrow functions which have memory overhead,
* in addition since it's always the same instance of the same class,
* so it's super easy to remove later on
*
* Based on https://webreflection.medium.com/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38
*/
static #eventhandlers = new WeakMap();