Skip to content

Instantly share code, notes, and snippets.

View mikaelvesavuori's full-sized avatar

Mikael Vesavuori mikaelvesavuori

View GitHub Profile
@mikaelvesavuori
mikaelvesavuori / mikrochat.bundled.mjs
Last active April 3, 2025 18:35
MikroChat bundled
// MikroChat - See LICENSE file for copyright and license details.
// node_modules/mikroauth/lib/index.mjs
import f from 'node:crypto';
import { URL } from 'node:url';
// node_modules/mikroconf/lib/chunk-DLM37L3L.mjs
var ValidationError = class extends Error {
constructor(message) {
super(message);
#!/usr/bin/env node
// MikroDB - See LICENSE file for copyright and license details.
var W=class extends Error{constructor(i){super(i),this.name="ValidationError",this.message=i||"Validation did not pass",this.cause={statusCode:400}}};import{existsSync as ie,readFileSync as ne}from"node:fs";var x=class{config={};options=[];validators=[];autoValidate=!0;constructor(i){let e=i?.configFilePath,t=i?.args||[],r=i?.config||{};this.options=i?.options||[],this.validators=i?.validators||[],i?.autoValidate!==void 0&&(this.autoValidate=i.autoValidate),this.config=this.createConfig(e,t,r)}deepMerge(i,e){let t={...i};for(let r in e)e[r]!==void 0&&(e[r]!==null&&typeof e[r]=="object"&&!Array.isArray(e[r])&&r in i&&i[r]!==null&&typeof i[r]=="object"&&!Array.isArray(i[r])?t[r]=this.deepMerge(i[r],e[r]):e[r]!==void 0&&(t[r]=e[r]));return t}setValueAtPath(i,e,t){let r=e.split("."),s=i;for(let o=0;o<r.length-1;o++){let a=r[o];!(a in s)||s[a]===null?s[a]={}:typeof s[a]!="object"&&(s[a]={}),s=s[a]}let n=r[r.length-1];s[n]=t}getVal
@mikaelvesavuori
mikaelvesavuori / clear-storage.js
Created December 24, 2024 19:55
Clear cookies, storage, and everything
(async function clearAllStorage() {
// Clear all cookies
document.cookie.split(";").forEach(function (cookie) {
const domainParts = window.location.hostname.split(".");
const pathParts = window.location.pathname.split("/");
domainParts.forEach((_, index) => {
const domain = domainParts.slice(index).join(".");
pathParts.forEach((_, pathIndex) => {
const path = pathParts.slice(0, pathIndex + 1).join("/") || "/";
@mikaelvesavuori
mikaelvesavuori / evolution-document-demo.md
Last active November 30, 2024 08:38
Evolution Document demo

ED 001: Improve Onboarding Experience for New Users

Status

Accepted

What we want to solve

The current onboarding process for new users lacks clear guidance, leading to frustration and drop-offs during the trial phase. Users are not engaging with core features early enough, reducing the likelihood of conversion to paid subscriptions.

@mikaelvesavuori
mikaelvesavuori / well-architected-lens.template.json
Created May 13, 2024 11:40
AWS Well-Architected Lens template.
{
"schemaVersion": "2021-11-01",
"name": "Replace with lens name",
"description": "Replace with your description",
"pillars": [
{
"id": "pillar_id_1",
"name": "Pillar 1",
"questions": [
{
@mikaelvesavuori
mikaelvesavuori / clone-org-repos.sh
Created May 13, 2024 11:40
Clone all repositories belonging to a GitHub organization.
#!/bin/bash
GITHUB_TOKEN="your_access_token"
ORG_NAME="your_organization"
PAGE=1
function updateCloneUrlList() {
rm repos.txt
while true; do
@mikaelvesavuori
mikaelvesavuori / ulid.mjs
Created May 9, 2024 08:36
Example of ULID to replace timestamps.
import { ulid, decodeTime } from 'ulidx';
const timestamp = () => parseInt(Date.now().toString());
const time = timestamp();
const ulidTime = ulid(time);
console.log('timestamp', time);
console.log('ulid', ulidTime);
console.log('ulid timestamp', decodeTime(ulidTime));
@mikaelvesavuori
mikaelvesavuori / keylistGenerator.ts
Created April 22, 2024 10:06
A keylist generator that can produce 1000 conflict-free keys in less than 3200 bytes.
export function keylistGenerator() {
const bytes = (str: string) => new Blob([str]).size;
const newId = () => randomBytes(3).toString('hex');
//const newId = () => randomBytes(5).toString('base64').substring(0, 6);
function generateIdString() {
const keylist: string[] = [];
let generatedIds = 0;
@mikaelvesavuori
mikaelvesavuori / createFileInGithub.ts
Last active April 22, 2024 05:42
Helpful GitHub API functionality for Node.
import { getBlobShaFromGithub } from './getBlobShaFromGithub';
export async function createFileInGithub(input: string, fileName: string, type: string) {
const owner = process.env.OWNER;
const repo = process.env.REPO;
const workflowId = process.env.WORKFLOW_ID;
const token = process.env.GITHUB_TOKEN;
if (!owner || !repo || !workflowId || !token)
throw new Error('Missing required environment variables!');
@mikaelvesavuori
mikaelvesavuori / prompting-examples.md
Created January 17, 2024 13:50
Prompting examples

Prompting demos

Zero-shot prompting

Give me a name for an article about microservices on AWS.

Example output: