Skip to content

Instantly share code, notes, and snippets.

View PatrickChildersIT's full-sized avatar

Patrick Childers PatrickChildersIT

View GitHub Profile
@PatrickChildersIT
PatrickChildersIT / Jenkinsfile
Last active November 12, 2024 04:47
Jenkinsfile definition for a python service that will automatically generate a requirements.txt file from the pyproject.toml file using poetry, in a container, before building the service's Dockerfile and uploading it.
pipeline {
agent none
stages {
stage("Clone & Prepare")
{
agent {
docker {
image 'python:latest'
registryUrl "https://index.docker.io/v1/"
}
@PatrickChildersIT
PatrickChildersIT / spreadsheet cell regular expression
Last active March 26, 2023 00:47
Regular Expression for matching spreadsheet cells with A1 notation
^(?:(?'startcolumn'[A-Za-z]{1,3})(?'startrow'\d{1,7}):(?'endcolumn'[A-Za-z]{1,3})(?'endrow'\d{1,7}))$|^(?:(?'startcolumn'[A-Za-z]{1,3}):(?'endcolumn'[A-Za-z]{1,3}))$|^(?:(?'startcolumn'[A-Za-z]{1,3})(?'startrow'\d{1,7}))$|^(?:(?'startcolumn'[A-Za-z]{1,3})(?'startrow'\d{1,7}):(?'endcolumn'[A-Za-z]{1,3}))$|^(?:(?'startcolumn'[A-Za-z]{1,3})(?'startrow'\d{1,7}):(?'endrow'\d{1,7}))$|^(?:(?'startcolumn'[A-Za-z]{1,3}):(?'endcolumn'[A-Za-z]{1,3})(?'endrow'\d{1,7}))$|^(?:(?'startrow'\d{1,7}):(?'endrow'\d{1,7}))$|^(?:(?'startrow'\d{1,7}):(?'endcolumn'[A-Za-z]{1,3})(?'endrow'\d{1,7}))$
@PatrickChildersIT
PatrickChildersIT / numble_solver.py
Last active August 12, 2022 01:44
solves Numble since I'm better at python than arithmetic
from operator import add, sub, mul, truediv
import itertools
from typing import Generator
TARGET = 755
NUMBERS = [3, 4, 25, 50, 75, 100]
OPERATIONS = {add: "+", sub: "-", mul: "*", truediv: "/"}
def series_to_string(series: list) -> str:
@PatrickChildersIT
PatrickChildersIT / log_cpu_temperatures.py
Last active November 22, 2021 05:11
I have had recent need to keep a close eye on my CPU temperatures. Using CPUThermomenterLib and pythonnet based on a stackoverflow article guiding me to modify its generic code to this specific use.
"""
Access and log CPU temperatures.
Heavily adapted from
https://stackoverflow.com/questions/3262603/accessing-cpu-temperature-in-python
"""
import time
import logging
import sys
from typing import Generator
@PatrickChildersIT
PatrickChildersIT / mime types.json
Created April 17, 2020 21:57
the mime types i got from google drive
[
"application/*",
"application/0",
"application/1",
"application/apk",
"application/applefile",
"application/arj",
"application/armor",
"application/base64",
"application/binary",
@PatrickChildersIT
PatrickChildersIT / space_heater.cpp
Last active August 24, 2019 00:24
cpp version of the python program to randomly (attempt to) generate magic squares of squared numbers. 4.7 million/s
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <stdbool.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <random>
#include <ctime>
@PatrickChildersIT
PatrickChildersIT / guess_squared_magic_squares.py
Last active September 6, 2019 19:40
Watched Numberphile recently, thought i'd make a program that tries to guess magic squares of squared numbers. Using Lox for multiprocessing. 3.4 Million/s
import random
import time
import lox
@lox.process(10)
def compute_squared_set(squared_set, square_sets_per_thread_proc):
import random
def compute_square(numbers):
"For each row, column, and diagonal check that they all sum to the same number"
magic = sum(numbers[:3])
@PatrickChildersIT
PatrickChildersIT / Exchange COM org mapper.py
Last active November 29, 2022 02:24
A simple python 3 script to use microsoft outlook's COM api via pythoncom (pypiwin32 package) to map, depth first, the organizational structure as tracked in exchange.
import pythoncom
import win32com.client
class Contact():
"""Class serves as little more than an enhanced node tree."""
def __init__(self, exchange_user):
"""
Establish a core COM object to work off of for subsequent properties.
Manager and workers are cached, in that they are only gotten once.
This reduces external calls if we need to access the name or job title multiple times.
@PatrickChildersIT
PatrickChildersIT / match_creation_to_name.py
Created October 14, 2018 02:56
Changes the Creation Date attribute of files at the top of a given Drive in windows so that Create Date orders the same as Alphabetically
# pylint: disable=I1101,E1101
"""
os for generic filesystem operations
argparse to accept a drive letter
time as a basis for creation time
pywintypes and win32file for windows file manipulation
"""
import os
import argparse
import time
@PatrickChildersIT
PatrickChildersIT / massrename.py
Last active September 29, 2018 04:35
A script to rename all media files in a given directory to one more suitable for Plex Media Server
"""os, for file IO"""
import os
import re
import argparse
def files(path):
""" Returns a list of filenames from the given directory.
https://stackoverflow.com/questions/14176166/list-only-files-in-a-directory
"""