Skip to content

Instantly share code, notes, and snippets.

View kmdouglass's full-sized avatar

Kyle M. Douglass kmdouglass

View GitHub Profile
@EnriqueSoria
EnriqueSoria / validate_dataclass.py
Last active March 5, 2024 21:51 — forked from rochacbruno/validate_dataclass.py
Validate Dataclass Python
import logging
from dataclasses import dataclass
from typing import Union, List
logger = logging.getLogger(__name__)
class Validations:
@xinau
xinau / main.tf
Created April 6, 2020 23:25
Terraform resources for a remote backend on AWS using a S3 bucket (with logging and enforced server side encryption) and a DynamoDB table.
variable bucket {
description = "AWS S3 bucket name to use for state storage"
type = string
}
variable dynamodb_table {
description = "AWS DynamoDB table name to use for state locking"
type = string
}

Rust Error Handling Cheatsheet - Result handling functions

Introduction to Rust error handling

Rust error handling is nice but obligatory. Which makes it sometimes plenty of code.

Functions return values of type Result that is "enumeration". In Rust enumeration means complex value that has alternatives and that alternative is shown with a tag.

Result is defined as Ok or Err. The definition is generic, and both alternatives have

@esauser
esauser / build.bat
Created May 6, 2019 19:13
Concourse Windows Worker
@echo off
nuget restore -Verbosity normal
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild -p:Configuration=Release ^
-p:WarningLevel=0
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet.exe test TestProject.csproj --configuration Release --no-build -v n
@extremecoders-re
extremecoders-re / openwrt-qemu.md
Last active March 22, 2024 13:20
Running OpenWRT ARM under QEMU

Environment

The steps shown below are done on a Ubuntu VM using Qemu 3.0

$ qemu-system-arm -version
QEMU emulator version 3.0.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

To quit Qemu at any time press Ctrl+a x, i.e. Ctrl+a and then x

@jmbjorndalen
jmbjorndalen / asyncio_executors_threads_procs.py
Created April 26, 2018 08:10
Combining Python 3 asyncio coroutines with thread pool and process pool executors
#!/usr/bin/env python3
# Combining coroutines running in an asyncio event loop with
# blocking tasks in thread pool and process pool executors.
#
# Based on https://pymotw.com/3/asyncio/executors.html, but this version runs both
# threads and processes at the same time and interleaves them with asyncio coroutines.
#
# All appears to be working.
#
@masklinn
masklinn / cheatsheet.md
Last active May 1, 2024 15:58
launchctl/launchd cheat sheet

I've never had great understanding of launchctl but the deprecation of the old commands with launchctl 2 (10.10) has been terrible as all resources only cover the old commands, and documentation for Apple utilities is generally disgracefully bad, with launchctl not dissembling.

Mad props to https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/ which contains most details

domains

Internally, launchd has several domains, but launchctl 1 would only ask for service names,

@csachs
csachs / tifffeeder.py
Last active May 25, 2018 06:55
tiff file feeder
import sys
import numpy
from datetime import datetime
from flask import Blueprint, Flask, make_response, request
from tifffile import TiffFile
# BSD Licensed
bp = Blueprint('SimulatedCameraImageFeeder', __name__)
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm