Skip to content

Instantly share code, notes, and snippets.

View astromechza's full-sized avatar
🎉

Ben Meier astromechza

🎉
View GitHub Profile
@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):
@astromechza
astromechza / assert.go
Last active January 13, 2019 17:09
Short golang helper file for assert functionality in tests.
// Package assert provides a handful of useful assertion primitives for basic Golang unit tests.
// This is not meant to replace packages like testify but is meant to be used in small library code that don't want
// to rely on a large 3rd party dependency just for a handful of assert tests.
//
// Copy and past this file into your code base as internal/assert/assert.go and use it in your testing.
package assert
import (
"reflect"
"testing"
@astromechza
astromechza / ver.py
Last active July 12, 2018 21:58
A Git-tag based version script
# /usr/bin/env python
"""
MIT LICENSE HEADER
Copyright 2018 Ben Meier (AstromechZA)
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
@astromechza
astromechza / git-squash-reset.sh
Last active June 14, 2018 11:24
A bash function for git-squash-reset
# A bash function for doing a git squash against a previous commit.
# It includes the dates and messages of the squashed commits and drops you into an editor if you
# need to modify the message further.
git-squash-reset() {
m=$(git log --pretty=format:'- %ad - %s' --date=short "$1...HEAD" --reverse)
l=$(echo "$m" | wc -l | tr -d ' ')
git reset "$1" --soft
git commit -m "Squash of $l commits" -m "$m"
git commit --amend
@astromechza
astromechza / gohere
Last active May 16, 2018 20:42
source-able bash script to setup GOPATH in the current directory
# Script to set GOPATH variable to the current directory containing this
# `go_here` script. NOT necessarily the working directory when the script was run.
# Must be launched via `source` or `.`, NOT run as a script.
# function to get absolute path of a file/dir
function abspath {
if [[ -d "$1" ]]
then
(cd "$1" >/dev/null; pwd)
elif [[ -e $1 ]]

"""

Example of things

paragraph content

import os
import sys
@astromechza
astromechza / thing.md
Last active March 6, 2018 20:07
Testing kbd tags

Testing

Testing

Hacks..

@astromechza
astromechza / install.sh
Last active March 21, 2022 07:56
A common install.sh script that can be used and adapted for multiple projects.
#!/usr/bin/env sh
# This install script is intended to download and install the latest available
# release of a platform specific binary. It will attempt to download the version of the
# binary required by your platform. It is designed for Golang projects but can be adapted for
# other languages too.
#
# Environment variables:
# - INSTALL_DIRECTORY (optional): defaults to current directory
# - OVERRIDE_RELEASE_TAG (optional): defaults to fetching the latest release