Skip to content

Instantly share code, notes, and snippets.

View kojiromike's full-sized avatar

Michael A. Smith kojiromike

View GitHub Profile
@kojiromike
kojiromike / pyproject.toml
Created August 31, 2023 14:52
pyproject.toml generated with `poetry new --src --name ns.pkg example`
[tool.poetry]
name = "ns-pkg"
version = "0.1.0"
description = ""
authors = ["Michael Smith <michael@phc.health>"]
readme = "README.md"
packages = [{include = "ns", from = "src"}]
[tool.poetry.dependencies]
python = "^3.10"
##
# https://aquasecurity.github.io/tfsec
name: tfsec
on:
push:
branches:
- main
pull_request:
jobs:
tfsec:
@kojiromike
kojiromike / brewup.sh
Last active April 29, 2022 17:28
Comprehensive macOS homebrew updates
burp() (
##
# Comprehensively update everything locally installed that I can manage.
local kubectl
softwareupdate -ia # Check for macOS updates
brew up # Update the list of applications in brew
brew upgrade # Update any outdated brew applications
brew list --cask | xargs -n1 brew upgrade --cask # Update any brew casks that were missed
@kojiromike
kojiromike / exc_info_demo.py
Last active December 13, 2021 16:55
A demonstration of Python exception context and logging
#!/usr/bin/env python3
import sys
import logging
from pprint import pprint
LOG = logging.getLogger('Exception Logging Demo')
logging.basicConfig(format='[%(asctime)s] %(name)s:%(levelname)s %(message)s', level='INFO')
@kojiromike
kojiromike / keybase-git-gpg.sh
Last active February 6, 2022 03:05
Sign Git Commits with Keybase
#!/bin/sh
##
# This program can possibly be substituted for gpg in the git `gpg.program` configuration
# to allow a person to use Keybase.io to sign commits on behalf of gpg.
##
# Copyright 2019 Michael A. Smith
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
--- nginx/configure.sls
/etc/nginx/conf.d/default.conf:
file.managed:
- source: salt://nginx/files/default.conf
- makedirs: True
- require_in:
- file: /etc/nginx/conf.d
--- blazegraph/configure.sls (what I currently have)
#!/usr/bin/env python
"""A few different (but really the same) ways to create the Fibonacci sequence."""
from pprint import pprint as pp
def fibs1():
'''Generate the Fibonacci sequence.'''
x, y = 0, 1
while True:
$ docker build - <<-DOCKERFILE
> FROM alpine
> VOLUME /foo
> RUN touch /foo/bar
> RUN ls /foo/bar
> DOCKERFILE
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM alpine
---> 3fd9065eaf02
Step 2/4 : VOLUME /foo
with import <nixpkgs> {};
with pkgs.python27Packages;
##
# Hypothesis: The paths from build-sandbox-paths in /etc/nix/nix.conf
# always get added to the PATH when running nix-shell.
#
# Experiment:
#
# Step 1: Produce a file containing your build-sandbox-paths:
@kojiromike
kojiromike / gist:5ef7dab570ba09df3baae4a93d891276
Last active April 24, 2017 17:05
StructLog Smith's Notes

Quick bullets about structured logging

Details from http://structlog.rtfd.org

Additional motivation from kartar and mipsytipsy

Why structured logging?

A single log message is not as important than many in aggregate. We need machines to aggregate data from many logs/messages. Machines need structured data, or they have to do expensive string parsing. Composing structured logs isn't more difficult than flat messages for humans.