Skip to content

Instantly share code, notes, and snippets.

@hex-plex
hex-plex / load_balancer.py
Created May 26, 2024 07:54
Load Balancer to spin multiple models with single API interface
from flask import Flask, request, jsonify
import requests
import random
app = Flask(__name__)
endpoints = {
'model_provider/model_1': 'http://0.0.0.0:8001',
'model_provider/model_2': 'http://0.0.0.0:8002',
'model_provider/model_3': 'http://0.0.0.0:8003',

introduction

inspired by a friend’s fledgling language design and motivated by the JeanHeyd Meneide RustConf Fiasco™ and improving the story for compile-time introspection, i decided i needed a place to spew the last year’s musings on variadic generics in Rust in one mighty, less-than-understandable catharsis.

i think somewhere in here is a considered and reasonable design, so that’s neat!

perhaps i’ll make this an RFC one day. probably not. you have my express permission to do that yourself.

variadic generics?

this nugget of language jargon encapsulates the idea that we might want to bind to an arbitrarily large list of generic parameters, all at once. there are many reasons to want to do this:

@b01
b01 / download-vs-code-server.sh
Last active July 17, 2025 05:04
Linux script to download latest VS Code Server, good for Docker (tested in Alpine).
#!/bin/sh
# Copyright 2023 Khalifah K. Shabazz
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the “Software”),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
@michael-grunder
michael-grunder / libevent-hiredis-reconnect.c
Created December 1, 2020 18:04
Quick and dirty reconnect via events for Hiredis + libevent
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <hiredis/hiredis.h>
#include <hiredis/async.h>
@bweston92
bweston92 / indexes.go
Created September 4, 2018 14:17
MongoDB Golang Driver Ensure Index
package mgoutil
import (
"context"
"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/pkg/errors"
)
@ZenGround0
ZenGround0 / client.go
Created January 3, 2018 20:26
Golang HTTP multipart streaming
package main
import (
"io"
"mime/multipart"
"net/http"
"net/url"
"os"
"fmt"
)
@posener
posener / go-shebang-story.md
Last active October 2, 2025 23:42
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@louxiu
louxiu / Client.java
Created March 15, 2017 11:11
Understanding netty channel buffers and watermarks
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
@teknoraver
teknoraver / unixhttpc.go
Last active September 30, 2025 08:41
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@jezell
jezell / kubernetes-websocket.go
Created September 25, 2016 08:04
Connect to Kubernetes endpoint over websockets
package main
import (
"bytes"
"flag"
"golang.org/x/net/websocket"
"io"
"k8s.io/client-go/1.4/rest"
"k8s.io/client-go/1.4/tools/clientcmd"
"log"