Skip to content

Instantly share code, notes, and snippets.

View astromechza's full-sized avatar
🐙

Ben Meier astromechza

🐙
View GitHub Profile
@astromechza
astromechza / ci.yaml
Created December 12, 2024 09:49
A standard CI workflow for a Rust project which doesn't rely on too many external actions
name: ci
on:
# Run on any pull request updates for any branches
pull_request:
branches: [ "*" ]
# Run on any new commits on main after PRs are merged.
push:
branches:
- main
env:
@astromechza
astromechza / duckdb-score.yaml
Last active November 22, 2024 13:04
A score file that works with score-compose and score-k8s to demonstrate a duckdb app working with an s3 bucket endpoint.
apiVersion: score.dev/v1b1
metadata:
name: duckdb-cli-demo
containers:
main:
image: ubuntu:latest
command:
- /bin/bash
- -c
- /mnt/setup.sh && sleep 3600
@astromechza
astromechza / crockford_base32.go
Created October 30, 2024 22:01
A single file Crockford Base32 implementation with generic bitPump that can be easily converted to other bit sizes. Unit tested along with fuzzing.
package uid
import (
"bytes"
"errors"
"fmt"
"io"
"strings"
)
@astromechza
astromechza / dotenv.provisioners.yaml
Created September 12, 2024 14:29
An example environment provisioner that reads a .env file in the working directory.
- uri: cmd://python3#dotenv
type: environment
args:
- -c
- |
import json
with open('.env') as f:
content = f.read().strip()
env_map = dict([x.split("=",1) for x in content.strip().splitlines()])
print(json.dumps({"resource_outputs": env_map}))
@astromechza
astromechza / definition.yaml
Last active August 2, 2024 15:54
demo-traefik-route-definition.yaml
apiVersion: entity.humanitec.io/v1b1
kind: Definition
entity:
name: traefik-ingress-eg
driver_type: humanitec/template
type: ingress
driver_inputs:
values:
# Find all the route resources that are dependent on any dns resources used in this workload.
# We extract arrays of their host, path, port, and service resource.
@astromechza
astromechza / 001.diff
Created June 10, 2024 07:41
blog score-compose kafka provisioner
--- a/.score-compose/00-kafka-topic-provisioner.provisioners.yaml
+++ b/.score-compose/00-kafka-topic-provisioner.provisioners.yaml
@@ -1 +1,6 @@
-{}
+- uri: template://custom-provisioners/kafka-topic
+ type: kafka-topic
+ outputs: |
+ host: unknown
+ port: "9092"
+ name: unknown
- uri: template://custom/dns
type: dns
class: default
outputs: |
host: image-service.hensteeth.meierhost.com
- uri: template://custom/ingress
type: route
class: default
init: |
@astromechza
astromechza / 00-extra.provisioners.yaml
Created March 19, 2024 11:14
Experimental score-compose provisioners for dns + route
# The default dns provisioner just outputs localhost as the hostname every time.
# This is because without actual control of a dns resolver we can't do any accurate routing on any other name.
- uri: template://default-provisioners/dns
type: dns
class: default
init: |
{{ if .Params }}{{ fail "no params expected" }}{{ end }}
randomServiceName: dns-{{ randAlphaNum 6 }}
randomHostname: {{ randAlpha 10 | lower }}.local
state: |
@astromechza
astromechza / question.md
Last active October 27, 2023 13:05
Interview question

# A sample coding question to use for helping folks prepare for an interview

Other resources they may find useful: https://app.codesignal.com/pre-screen-practice - create a Developer account and do some practise questions.

Otherwise, use a google doc or coder pad to run this.

Part 1

We're working together for a company that processes long running transactions. Our program spits out a log file that looks like the following:

@astromechza
astromechza / server.py
Created July 25, 2019 16:23
Json http server with GET/POST
#!/usr/bin/env python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer
import json
current = {"hello": "world"}
class S(BaseHTTPRequestHandler):