Skip to content

Instantly share code, notes, and snippets.

View stevegt's full-sized avatar

Steve Traugott stevegt

View GitHub Profile
@stevegt
stevegt / gist:50f5e20777c15bdeae20a9e160a94f47
Created September 3, 2024 01:00
example ollama client in python
from ollama import Client
import os
# derived from https://github.com/ollama/ollama-python
host = os.getenv('OLLAMA_HOST', 'http://localhost:11434')
client = Client(host=host)
response = client.chat(model='llama3.1:8b', messages=[
{
'role': 'user',
@stevegt
stevegt / gist:c912c4708e8181cecc6d2ba588c20620
Created September 3, 2024 00:43
example Ollama client in Go
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/ollama/ollama/api"
. "github.com/stevegt/goadapt"
@stevegt
stevegt / got-loop.sh
Created May 29, 2024 01:42
a much simpler script for an automatic go vet loop
#!/bin/bash
winid=$(getwinid)
while true
do
inotifywait -r -e modify *
sleep 1
go vet || continue
wmctrl -ia $winid
@stevegt
stevegt / watch-test-commit.sh
Created May 29, 2024 01:39
a script I use to automate the go test/git commit cycle when doing rapid development and refactoring
#!/bin/bash
if [ -z "$1" ]
then
echo "Usage: $0 <paths-to-watch>"
exit 1
fi
# get current window id
window_id=$(xdotool getactivewindow)
// Single line comment
/* Multi-
line comment */
// A package clause starts every source file.
// Main is a special name declaring an executable rather than a library.
package main
// Import declaration declares library packages referenced in this file.
import (
@stevegt
stevegt / makekey.py
Last active May 9, 2022 18:04 — forked from tdfischer/makekey.py
Schlage 5 Cylinder Key Generator from https://noisebridge.net/wiki/Key_Milling
#!/usr/bin/env python
# makekey.py - A key making tool
# This program will accept a pin configuration for a Schalge 5 Pin lock and produce GCode to mill out the corresponding key.
#
# For example, this will produce a bump key:
# $ ./makekey.py 99999
#
# This could produce a key to something else:
# $ ./makekey.py 38457
#
@stevegt
stevegt / atan2.thinkscript
Created January 30, 2022 19:51
thinkscript atan2
script atan2 {
input y = 1.1;
input x = 1.1;
# approx from wikipedia
plot atan2 = 2 * atan(y/(sqrt(sqr(x) + sqr(y)) + x));
}
@stevegt
stevegt / mob-consensus
Last active January 6, 2022 19:31
simple shell script for mob programming: provides fast merge and review, supports async work
#!/bin/bash -e
repo_root=$(git rev-parse --show-toplevel)
current_branch=$(git rev-parse --abbrev-ref HEAD)
twig=$(basename $current_branch)
usage() {
echo "Usage: $0 [-cFn] [-b BASE_BRANCH] [OTHER_BRANCH]
With no arguments, compare $current_branch with other branches named "'*'"/$twig.
package main
import (
"log"
"os"
"regexp"
"strings"
"text/template"
)
@stevegt
stevegt / buildah-flow.dot
Last active August 9, 2021 23:52
journal engine flowchart using buildah as example
digraph docker {
rankdir=LR;
io [label="I/O"];
subgraph cluster_20 {
label=journal;
// open [label="open\nexisting\njournal"];
notify [label="start\nprocess"];
create [label="create\nnew\njournal"];