Skip to content

Instantly share code, notes, and snippets.

View wouterdb's full-sized avatar

Wouter De Borger wouterdb

View GitHub Profile
@wouterdb
wouterdb / check.py
Created June 16, 2022 19:23
Nagios checks for inmanta: example code
import datetime
from datetime import timedelta
from urllib.parse import quote
import requests
base_url = "http://192.168.5.77:8888/"
def list_environments():
Make a program to calculate all valid checkers moves for a specific piece, given the position of all pieces on the board.
rules
1- always move diagonally forward 1 square (either left or right)
1- pieces capture diagonally by jumping over a piece that is diagonally adjacent
1- captures can capture both forward an backward
1- if at the end postion of a capture you can do another capture you must also make this capture (chaining)
1- if a capture is possible, only the longest capture chain is a valid move
@wouterdb
wouterdb / puzzler1.py
Last active June 18, 2019 08:58
Pydantic Puzzlers
import pydantic
class Project(pydantic.BaseModel):
source: str
validate_: bool = False
class Config:
# validate is not a valid field name, because BaseModel has a validate method
# use alias so we can use a validate field in the json and validate_ in python
fields = {"validate_": {"alias": "validate"}}
@wouterdb
wouterdb / Dockerfile
Created November 12, 2018 20:44
Lister dockerfile
# Use an official Python runtime as a parent image
FROM python:3.7-slim
# Set the working directory to /app
WORKDIR /www
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN mkdir -p /www/;touch /www/content
# Make port 80 available to the world outside this container
EXPOSE 8000
@wouterdb
wouterdb / lister.py
Created November 12, 2018 19:55
Simple Python directory lister
#!/usr/bin/env python3
from http.server import HTTPServer, BaseHTTPRequestHandler
import os
import json
class StaticServer(BaseHTTPRequestHandler):
def do_GET(self):
files = os.listdir(".")
self.send_response(200)