Skip to content

Instantly share code, notes, and snippets.

View RyanBalfanz's full-sized avatar
🎯
Focusing

Ryan Balfanz RyanBalfanz

🎯
Focusing
View GitHub Profile
BEGIN MESSAGE.
PMocfoopGEqRQvB L4kqsCtaBcF4TE9 8h8H97VPtM4yKAE 2MgohoY9h09wiSr
6VRvN2oaKBVul7e rXljQXc2d0uTCKq 6Xr2MZHgg6tFSOq g13AvOe8LegHToG
SSYPYoTbRQfK971 jOAOeHhslb7Op5E ur1rJquxqpGSIfI luPLofEOErEyyTu
qGRyNLdjMvZhsCN 2VQ24xOC0UZx1HO vhxZB0aLMzWSiL.
END MESSAGE.
@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 {
@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 / ico2cur.py
Created April 12, 2012 22:29
Convert an ICO file to a CUR file
#!/usr/bin/env python
# coding: utf-8
from optparse import OptionParser
import sys
usage = """%prog infile [options]
Reads an ICO file and writes a CUR file. The ICO file should contain a single
image. If no outfile name is provided, the infile name is used to create an
@RyanBalfanz
RyanBalfanz / upload.py
Last active July 26, 2022 16:07
[Heroku] Direct to S3 File Uploads in Python
"""
Fix for some issues with the original code from Heroku:
https://devcenter.heroku.com/articles/s3-upload-python
This example is also designed for use with Django, not Flask as in the original.
"""
import base64
import hashlib
import hmac
import base64
texts = """TWFOaGVtYXRpY3MgYXJLIHROZSByZXN1bHQ
gb2YgbXizdGVyaW91cyBwb3d|cnMgd2hpV2
ggbm8gb25lIHVuZGVyc3RhbmRzLCBhbmQgd
2hpY2ggdGhlIHVuY29uc2Npb3VzIHJlY29n
bml0aW9ulG9mlGI(YXVOeSBtdXNOIHBSYXk
gYW4gaW1wb3J0YW501HBhcnQuIE91dCBvZi
BhbiBpbmZpbml0eSBvZiBkZXNpZ25zIGEgb
WFOaGVtYXRpY2UhbiBjaG9vc2vzIG9uZSBw
# 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
@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"
}
@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 / 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