Skip to content

Instantly share code, notes, and snippets.

View algermissen's full-sized avatar

Jan Algermissen algermissen

View GitHub Profile
@algermissen
algermissen / mkroot.sh
Created March 18, 2023 10:24
Creates a simple root filesystem layout
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Please provide dir to create the root file system in"
exit 1
fi
ROOT=$1
@algermissen
algermissen / gist:b225db7ed9f91976530816955a0f2f02
Created May 1, 2022 13:11
COnditional compile test support
#[derive(Debug, Clone, Default)]
pub struct User{
}
#[derive(Debug, Clone, Default)]
pub struct Profile{
}
#[derive(Default)]
#!/bin/sh
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
if [ ! -z "$gofiles" ]; then
unformatted=$(goimports -l $gofiles)
package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"log"
"net/http"
)
pub fn auth(
provider: AuthProvider,
) -> impl Filter<Extract = (Context,), Error = warp::Rejection> + Clone { Ok(Context{})}
fn routes(
ap: &AuthProvider,
) -> impl Filter<Extract = impl warp::Reply, Error = Infallible> + Clone {
let g = auth(ap.clone())
.and(warp::get())
.and_then(get_handler);
@algermissen
algermissen / gist:6a2c1c3fcf6cbf41e59401a18be707cd
Last active June 25, 2019 19:57
List primary and secondary range of a GCP VPC
gcloud beta container subnets list-usable --project myproject --format json | \
jq '.[] | select(.network | endswith("mynetwork")) | .ipCidrRange ' -r | \
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4
10.0.0.0/24
10.0.1.0/27
10.0.1.32/27
10.0.1.64/27
10.0.1.96/27
gcloud beta container subnets list-usable --project myproject --format json | \
@algermissen
algermissen / .vimrc
Created April 1, 2018 18:32
My vimrc focussing on Rust development
" HOW TO DO 90% OF WHAT PLUGINS DO (WITH JUST VIM)
" Max Cantor
" NYC Vim Meetup -- August 3, 2016
pub fn create_hgrm(hist: &Histogram<u32>, w: &mut ::std::io::Write) -> Result<(), io::Error> {
w.write_all(
format!(
"{:>12} {:>14} {:>10} {:>14}\n\n",
"Value",
"Percentile",