Skip to content

Instantly share code, notes, and snippets.

View damienpontifex's full-sized avatar

Damien Pontifex damienpontifex

View GitHub Profile
{
# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount --yes-wipe-all-disks ./disk-config.nix
# nixos-install --flake github:damienpontifex/nixos-homelab?ref=main#homeserver
disko.devices = {
disk = {
main = {
device = "/dev/sda"; # Change to your actual disk (e.g., /dev/nvme0n1)
type = "disk";
content = {
type = "gpt";
@damienpontifex
damienpontifex / tf-experiment-template.py
Last active December 11, 2025 01:00
A template for a custom tensorflow estimator and experiment with python3 typings for desired parameter types
import argparse
import psutil
import tensorflow as tf
from typing import Dict, Any, Callable, Tuple
## Data Input Function
def data_input_fn(data_param,
batch_size:int=None,
shuffle=False) -> Callable[[], Tuple]:
"""Return the input function to get the test data.
@damienpontifex
damienpontifex / Makefile
Last active September 16, 2025 00:38
Makefile template
.SHELLFLAGS := -o errexit -o nounset -o pipefail
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: help all fmt validate
## help: Display available commands and their descriptions
help:
@echo "Usage:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) \
@damienpontifex
damienpontifex / az-storage-oauth-list-containers.sh
Last active November 29, 2024 09:41
Access storage by using OAuth token from az cli
#!/bin/bash
# Add your use account as "Storage Blob Data Contributor" RBAC to the Access Control of the storage account
STORAGE_ACCOUNT=<account-name>
STORAGE_ACCESS_TOKEN=$(az account get-access-token --resource https://storage.azure.com/ --query accessToken -o tsv)
curl \
-H "Authorization: Bearer $STORAGE_ACCESS_TOKEN" \
@damienpontifex
damienpontifex / bazel-azure-storage-remote-cache.sh
Last active August 12, 2024 18:48
Bazel remote cache with Azure Storage
# Interactive read the storage account name
read -p "Storage account name: " STORAGE_ACCOUNT
# Or set variable directly here
# STORAGE_ACCOUNT=azurestorageaccountname
STORAGE_CONTAINER=bazel-cpp-tutorial
ACCESS_TOKEN=$(az account get-access-token \
--resource="https://${STORAGE_ACCOUNT}.blob.core.windows.net/" \
--query accessToken --output tsv)
@damienpontifex
damienpontifex / .amplify-cli-usage
Last active May 3, 2024 22:27
Making the amplify CLI easier to use
Purposefully left blank for naming
@damienpontifex
damienpontifex / azure-devops-pr-labels.yml
Last active October 25, 2022 09:35
Get labels applied to PR. Used if we want to do custom actions in the build based on those labels. We should set them as environment variables or whatever action you want
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: Job1
steps:
- script: |
LABELS_JSON=$(curl -H "Authorization: Bearer ${SYSTEM_ACCESSTOKEN}" "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/labels?api-version=5.1-preview.1")
echo $LABELS_JSON
env:
<#
.DESCRIPTION
An example runbook which gets all the ARM resources using the Managed Identity
.NOTES
AUTHOR: Azure Automation Team
LASTEDIT: Oct 26, 2021
#>
try
{
@damienpontifex
damienpontifex / directories-to-tfrecords.py
Created September 18, 2017 06:20
Convert recursive directories to TFRecords
#! /usr/env/bin python3
import argparse
import os
import sys
import glob
import pickle
import tensorflow as tf
import numpy as np
from PIL import Image
@damienpontifex
damienpontifex / cloudformation-yaml-language-server.yml
Created May 26, 2021 01:02
Snippet that defines schema for cloud formation yaml to be used with yaml-language-server
# yaml-language-server: $schema=https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json
AWSTemplateFormatVersion: 2010-09-09
Resources: