Skip to content

Instantly share code, notes, and snippets.

View stctheproducer's full-sized avatar

Chanda Mulenga stctheproducer

View GitHub Profile
@stctheproducer
stctheproducer / README.md
Created June 25, 2025 11:19 — forked from lncitador/README.md
AdonisJS Lucid Mapper Utility

This abstract Mapper class provides a flexible and type-safe way to serialize, transform, and label AdonisJS Lucid models and their paginated results. It is designed to help you build clean API responses and DTOs in AdonisJS projects.

Features

  • Supports serialization of single models, arrays, and paginated results.
  • Custom serialization logic via subclassing.
  • Utility for picking specific fields and relations from models.
  • Label mapping mechanism for enums or field names.

Use this utility to keep your API layer clean, consistent, and maintainable when working with AdonisJS and Lucid ORM.

@stctheproducer
stctheproducer / bind-plugin.ts
Created June 8, 2025 06:48 — forked from marvinhagemeister/bind-plugin.ts
Preact Signals `bind:value`
import { options } from "preact";
import { Signal } from "@preact/signals";
// Add `bind:value` to JSX types
declare global {
namespace preact.createElement.JSX {
interface HTMLAttributes {
"bind:value"?: Signal<string | string[] | number | undefined>;
}
}
@stctheproducer
stctheproducer / money.ts
Last active May 23, 2025 15:21
This TypeScript file provides a money library for handling monetary values with precision. It uses `BigInt` to accurately store amounts in their minor currency units, avoiding floating-point issues. Leveraging `Intl.NumberFormat`, it offers robust and localized formatting of monetary values.
/**
* Represents a monetary value using BigInt for precision.
*/
export interface Currency {
code: string;
exponent: number; // Number of decimal places in the minor unit
}
// A simple registry of supported currencies
const currencies: { [key: string]: Currency } = {
@stctheproducer
stctheproducer / windsurf-memories
Created May 22, 2025 14:35 — forked from entrepeneur4lyf/windsurf-memories
Converted Cline Memory Management to Windsurf
# Windsurf Memory Bank
I am Windsurf, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
## Memory Bank Structure
The Memory Bank consists of required core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
```mermaid
flowchart TD
@stctheproducer
stctheproducer / deprecated_money.ts
Last active May 23, 2025 15:04
Money class for manipulating monetary values
import * as currencies from '@dinero.js/currencies'
import {
allocate,
createDinero,
dinero,
type Dinero,
type Calculator,
type Currency,
type DivideOperation,
add,
@stctheproducer
stctheproducer / keybase.md
Created January 8, 2025 21:20 — forked from sinewalker/keybase.md
How to import pub/sec PGP keys from keybase to your local GPG keyring.

Import Keybase PGP to GPG

After installing the keybase command-line tool onto a new / fresh computer, you may want to import your PGP key to the local keyring so that you may use the keys with GPG.

Import your PUBLIC PGP key:

keybase pgp export|gpg --import -
@stctheproducer
stctheproducer / app.ts
Last active November 15, 2024 12:05
This is the Svelte implementation of the `Link` component provided by the `Tuyau` package (https://github.com/Julien-R44/tuyau). The types are a little hacky because the Inertia Link component was built in Svelte 4.
// ...imports here
import { setTuyauState, TUYAU_KEY } from '../components/tuyau_state'
const context = new Map([[TUYAU_KEY, setTuyauState()]])
createInertiaApp({
// ...other configs
setup({ el, App, props }) {
if (el?.dataset.serverRendered === 'true') {
@stctheproducer
stctheproducer / money.ts
Created October 24, 2024 14:58
Money class with mathjs evaluation and dinero.js
import * as currencies from '@dinero.js/currencies'
import {
allocate,
createDinero,
dinero,
type Dinero,
type Calculator,
type Currency,
type DivideOperation,
add,
@stctheproducer
stctheproducer / ca-store-generator.js
Created August 21, 2023 14:42 — forked from othiym23/ca-store-generator.js
Hacky script to download Mozilla's root CA store and turn it into a bundle suitable for use with Node TLS.
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var request = require('request');
var CERTDB_URL =
'https://mxr.mozilla.org/nss/source/lib/ckfw/builtins/certdata.txt?raw=1';
var OUTFILE = './certificates.js';
@stctheproducer
stctheproducer / arrayBufferToString.ts
Last active December 2, 2021 16:23
A TypeScript function to convert an array buffer to a binary string
const arrayBufferToString = (arrayBuffer: ArrayBuffer): string => {
let binary = ''
const bytes = new Uint8Array(arrayBuffer)
const len = bytes.byteLength
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i])
}
return binary