Skip to content

Instantly share code, notes, and snippets.

View RyanBalfanz's full-sized avatar
🎯
Focusing

Ryan Balfanz RyanBalfanz

🎯
Focusing
View GitHub Profile
@RyanBalfanz
RyanBalfanz / monads.py
Created May 2, 2024 04:16
Monads in Python with Type Hint Annotations
#!/usr/bin/env python3.12
# -*- coding: utf-8 -*-
import typing
from dataclasses import dataclass, field
@dataclass
class Functor[T]:
value: T
@RyanBalfanz
RyanBalfanz / llm_webui.py
Created April 16, 2024 02:31
Initial LLM WebUI
import json
import urllib.parse
from dataclasses import InitVar, dataclass
from datetime import datetime, timedelta
from typing import Protocol
import httpx
import llm
import streamlit as st
@RyanBalfanz
RyanBalfanz / db.json
Created August 15, 2023 07:39
db.json
{
"string": "Hello.",
"number": 3.14,
"integer": 42,
"boolean": true,
"date": "2023-08-15",
"datetime": "2023-08-15T07:28:15.442151"
}
@RyanBalfanz
RyanBalfanz / example-01.json
Created August 15, 2023 07:38
My JSON Server
{
"string": "Hello.",
"number": 3.14,
"integer": 42,
"boolean": true,
"date": "2023-08-15",
"datetime": "2023-08-15T07:28:15.442151"
}
# Rails production setup via SQLite3 made durable by https://litestream.io/
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine.
#
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails
#
# in production you might want to map /data to somewhere on the host,
# but you don't have to!
#
FROM ruby:3.0.2
import base64
texts = """TWFOaGVtYXRpY3MgYXJLIHROZSByZXN1bHQ
gb2YgbXizdGVyaW91cyBwb3d|cnMgd2hpV2
ggbm8gb25lIHVuZGVyc3RhbmRzLCBhbmQgd
2hpY2ggdGhlIHVuY29uc2Npb3VzIHJlY29n
bml0aW9ulG9mlGI(YXVOeSBtdXNOIHBSYXk
gYW4gaW1wb3J0YW501HBhcnQuIE91dCBvZi
BhbiBpbmZpbml0eSBvZiBkZXNpZ25zIGEgb
WFOaGVtYXRpY2UhbiBjaG9vc2vzIG9uZSBw
@RyanBalfanz
RyanBalfanz / context_cancel.go
Created July 19, 2021 18:19 — forked from fracasula/context_cancel.go
GoLang exiting from multiple go routines with context and wait group
package main
// Here's a simple example to show how to properly terminate multiple go routines by using a context.
// Thanks to the WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"
@RyanBalfanz
RyanBalfanz / count_customer_bookings.go
Created January 30, 2021 01:09 — forked from CharlesWinter/count_customer_bookings.go
Our repository method for counting customer bookings
package bookings
type Repository struct {
// in reality, this client will likely be something we generate from a
// schema, or implement ourselves if needs be. Its not discussed here for
// conciseness
client bookingsServiceClient
}
type booking struct {
BEGIN MESSAGE.
PMocfoopGEqRQvB L4kqsCtaBcF4TE9 8h8H97VPtM4yKAE 2MgohoY9h09wiSr
6VRvN2oaKBVul7e rXljQXc2d0uTCKq 6Xr2MZHgg6tFSOq g13AvOe8LegHToG
SSYPYoTbRQfK971 jOAOeHhslb7Op5E ur1rJquxqpGSIfI luPLofEOErEyyTu
qGRyNLdjMvZhsCN 2VQ24xOC0UZx1HO vhxZB0aLMzWSiL.
END MESSAGE.
@RyanBalfanz
RyanBalfanz / index.html
Created January 2, 2019 20:59
Analog Clock for ARTIFACT
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="400" height="300" style="background-color:#333"></canvas>
<script>
console.info('Adapted for ARTIFACT from https://www.w3schools.com/graphics/canvas_clock_start.asp');
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");