Skip to content

Instantly share code, notes, and snippets.

View w4's full-sized avatar
☄️
😩

jordan w4

☄️
😩
View GitHub Profile
@w4
w4 / build.rs
Created March 31, 2024 08:16
flatbuffers build.rs
use std::{fmt::Write, process::Command};
pub fn main() {
let root = std::env::var("CARGO_MANIFEST_DIR").expect("missing CARGO_MANIFEST_DIR env var");
let out = std::env::var("OUT_DIR").expect("missing OUT_DIR env var");
build_flatbufs(&root, &out);
}
fn build_flatbufs(root: &str, out: &str) {
#!/usr/bin/env python3
import sys
import glob
import json
import textwrap
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
from xml.etree import ElementTree
from datetime import datetime
{ config, pkgs, lib, ... }:
{
containers.certbot = {
autoStart = true;
ephemeral = true;
bindMounts = {
"/var/lib/acme" = { hostPath = "/data/acme"; isReadOnly = false; };
};
{ config, pkgs, ... }:
let
teleport = (import ./build.nix) { inherit pkgs; };
in
{
virtualisation.oci-containers.containers.teleport = {
image = "teleport:11.1.4";
imageFile = teleport;
volumes = [ "${config.age.secrets.teleport-config.path}:/etc/teleport.d/teleport.yaml" "/data/teleport/data:/var/lib/teleport" ];
ports = [ "443:443" "3025:3025" "3024:3024" "3023:3023" ];
@w4
w4 / default.nix
Created December 11, 2022 16:30
Reproducable dnscontrol config builds using Nix
{ pkgs ? import <nixpkgs> { } }:
pkgs.stdenv.mkDerivation rec {
name = "dnsconfig";
version = "0.1.0";
phases = [ "buildPhase" "testPhase" ];
src = ./config;
buildPhase = ''
@w4
w4 / Containerfile
Last active October 3, 2022 10:17
Download, build and install Teleport for Podman on ARM64 NixOS
ARG VERSION
FROM ubuntu AS download
ARG DEBIAN_FRONTEND=noninteractive
ARG VERSION
WORKDIR /tmp
RUN apt update && apt install -y curl
RUN curl -o teleport.tar.gz https://get.gravitational.com/teleport-v$VERSION-linux-arm64-bin.tar.gz \
&& tar xvzf teleport.tar.gz
{ config, pkgs, lib, ... }:
{
containers.grafana = {
autoStart = true;
ephemeral = true;
bindMounts = {
"/data" = {
hostPath = "/data/random/grafana";
isReadOnly = false;
};
@w4
w4 / vault-crtlist-generator.py
Last active March 10, 2022 02:46
Call LetsEncrypt via vault-acme for a list of domains to generate SSL certificates and create a HAProxy crtlist (and NixOS container to run it)
import requests
import json
import logging
import os
separator = '-------------------------------------------------------'
logging.basicConfig(format='%(levelname_brackets)s %(message)s', level=logging.INFO)
old_factory = logging.getLogRecordFactory()
def record_factory(*args, **kwargs):
@w4
w4 / Cargo.toml
Last active January 9, 2022 17:11
spotify playlist scraper (api-based)
[package]
name = "spotify-playlist-scraper"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rspotify = { version = "0.11.3", features = ["cli"] }
futures = "0.3.19"
From a5f4c545e231d76226497b938baf0b9d7747584b Mon Sep 17 00:00:00 2001
From: "jordan@doyle.la" <jordan@doyle.la>
Date: Fri, 7 Aug 2020 17:21:17 +0100
Subject: [PATCH] Use CSS styles for syntax highlighting
---
Cargo.lock | 6 +++---
Cargo.toml | 2 +-
src/highlight.rs | 26 +++++++++++++-------------
src/main.rs | 9 ++++++++-