Skip to content

Instantly share code, notes, and snippets.

@gilwo
gilwo / check_models.sh
Last active March 1, 2026 14:26
check_models.sh: Iterates through OpenAI-compatible models from a given URL, tests each with a completion request, and generates a grouped summary of availability.
#!/bin/bash
# ==============================================================================
# Script Name: check_models.sh
# Description: Checks the availability of models from an OpenAI-compatible API
# endpoint. It iterates through all available models, sends a
# test completion request, and reports the status (OK/FAIL).
# It generates a summary grouped by model prefix, a comma-separated
# list of successful models, and logs detailed invocation results
# to a timestamped log file.
@gilwo
gilwo / gist:389ed3b491ce682f5683deeadc8c2f37
Last active April 24, 2025 10:40
check differences of handling channel (element, nil element, closure of channel)
package main
import (
"fmt"
"sync"
"testing"
"time"
)
@gilwo
gilwo / gist:628a1de94c7ad17bd9c30f5c0b566081
Created February 12, 2025 08:56
go playground example with multiple files/packages for getting package name
package main
import (
"fmt"
_ "play/app"
"play/tool"
)
func init() {
fmt.Println("-- in main.init(), my package:", tool.GetCallerPackageName(2))
@gilwo
gilwo / ANSI.md
Created April 21, 2024 22:35 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@gilwo
gilwo / bash.sh
Created October 17, 2023 12:35
generate objectid in shell with a twist
alias rand_objectid="openssl rand -hex 12"
alias rand_objectid_now='printf "%x%s" $(date +%s) $(openssl rand -hex 8)'
# nifty trick for 3m old objectid
# refernce: https://hashnode.com/post/how-to-generate-a-mongodb-objectid-from-a-date-in-bash-cju8r0ur3001zbns1rx9mvsnw
# note this date command work on mac shell
alias objectid_3m_old='printf "%x0000000000000000" $(date -v -3m +%s)'
@gilwo
gilwo / verifySignedMessage.go
Created June 15, 2023 14:03
an example of how to sign a message from shell commands and verify it from a go program. make the program suitable for ec and rsa algorithms
package main
import (
"crypto"
"crypto/ecdsa"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/asn1"
"encoding/pem"
@gilwo
gilwo / go-socket.io_fasthttp_integration.go
Last active March 19, 2023 20:04
making fasthttp(via gofiber) play along with go-socket.io
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"net/http"
"os"
@gilwo
gilwo / ec_sign_example.go
Created March 8, 2023 19:35
EC keypair sign/verify example
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
crand "crypto/rand"
"crypto/x509"
"encoding/hex"
"fmt"
"math/big"
@gilwo
gilwo / 2fish_example.go
Last active February 26, 2023 12:50
twofish encrypt/decrypt example
// example at : https://go.dev/play/p/HTDZlSDg1AC
package main
import (
"bytes"
"crypto/cipher"
"encoding/hex"
"fmt"
"log"
@gilwo
gilwo / example.go
Created January 13, 2023 21:44
moveable floating window using wasm and go-app using golang
// howto run:
// GOARCH=wasm GOOS=js go build -o web/app.wasm && go run .
package main
import (
"fmt"
"log"
"net/http"