Skip to content

Instantly share code, notes, and snippets.

View mikaelvesavuori's full-sized avatar

Mikael Vesavuori mikaelvesavuori

View GitHub Profile
@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:

@mikaelvesavuori
mikaelvesavuori / asyncapi3-request-reply-http.yml
Created December 20, 2023 09:52
AsyncAPI 3 request reply (HTTP) example.
asyncapi: 3.0.0
info:
title: Hello world using request/reply
version: 1.0.0
description: Hello world example using request/reply
channels:
hello:
address: /hello
messages:
@mikaelvesavuori
mikaelvesavuori / index.mjs
Last active December 18, 2023 09:12
Different ways to output IDs with Node.
/**
* @see https://medium.com/geekculture/the-wild-world-of-unique-identifiers-uuid-ulid-etc-17cfb2a38fce
* @see https://www.honeybadger.io/blog/uuids-and-ulids/
*
* Install with `npm init -y && npm install uuid nanoid ulidx -S`
*/
import { randomUUID } from 'crypto';
import { v4 } from 'uuid';
import { nanoid } from 'nanoid';
import { ulid } from 'ulidx';

Pay Transparency Card

Who am I?

Name

Naomi Nameson.

Contact email

@mikaelvesavuori
mikaelvesavuori / podman-cheatsheet.sh
Created December 3, 2023 15:52
Podman cheatsheet for common basic commands.
# Build and tag image
podman build -t <IMAGE>:<TAG> .
# List images
podman images
# List processes
podman ps
# Kill a process
@mikaelvesavuori
mikaelvesavuori / push-to-ttl.sh
Created December 3, 2023 15:51
Push a container image to ttl.sh using Podman
#!/bin/bash
########################################################################
# Uses Podman to build an image and push it to ttl.sh (https://ttl.sh) #
########################################################################
NAME=$(uuidgen | tr "[:upper:]" "[:lower:]")
echo "Image name is: ${NAME}"
@mikaelvesavuori
mikaelvesavuori / export.sh
Created October 30, 2023 06:05
Import and export spaces in Contentful.
#!/bin/bash
# See: https://www.contentful.com/developers/docs/tutorials/cli/import-and-export/
EXPORT_FOLDER="export"
EXPORT_FILE="backup.json"
SPACE_ID="YOUR_ID_HERE"
mkdir -p $EXPORT_FOLDER
@mikaelvesavuori
mikaelvesavuori / git-commands.sh
Created September 3, 2023 19:47
Various Git commands to inspect code.
git log -S <string>
git log -p <FILE>
git log --pretty --abbrev-commit — <FILE>
git log --pretty=format:"%h %ad %an - %s" --abbrev-commit -- <FILE>
git bisect start
git bisect bad
git bisect good
git bisect reset