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 July 18, 2024 13:25 — 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 July 12, 2024 14:31
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 September 24, 2024 12:23
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__)
@benhoyt
benhoyt / atomic_counter.py
Created August 3, 2016 13:12
An atomic, thread-safe incrementing counter for Python
"""An atomic, thread-safe incrementing counter."""
import threading
class AtomicCounter:
"""An atomic, thread-safe incrementing counter.
>>> counter = AtomicCounter()
>>> counter.increment()