Skip to content

Instantly share code, notes, and snippets.

View NucciTheBoss's full-sized avatar
👾
All your source belong to us

Jason Nucciarone NucciTheBoss

👾
All your source belong to us
View GitHub Profile
@NucciTheBoss
NucciTheBoss / doc-cheat-sheet-myst
Created July 22, 2024 20:54
Charmed HPC doc website markdown cheatsheets
---
orphan: true
myst:
substitutions:
reuse_key: "This is **included** text."
advanced_reuse_key: "This is a substitution that includes a code block:
```
code block
```"
---
@NucciTheBoss
NucciTheBoss / README.md
Last active July 22, 2024 20:49
README template for community-oriented projects

Project Name

Optional: Project logo/image.

badges-specific-to-project

One to three sentence description of project.

Optional: GIF demoing functionality of project

@NucciTheBoss
NucciTheBoss / Makefile
Last active June 25, 2024 14:14
Template Makefile for non-Python based projects
##@ Build
.PHONY: build
build: ## Build project
# Where targets related to building the project - e.g. compiling, preprocessing, snapping, etc. - should go.
##@ Lint
# Where targets related to linting the project source code should go.
@NucciTheBoss
NucciTheBoss / type_checker.py
Created March 1, 2024 21:20
Type checking decorator - a simple Python decorator for validating the type of passed arguments for functions and methods
# Works with builtin types and classes. Does not support type checking with annotations.
# If you are using types composed with the `typing` module, a more advanced validator should be used
def assert_type(*typed_args, **typed_kwargs):
"""Check the type of args and kwargs passed to a function/method."""
def decorator(func: Callable):
sig = inspect.signature(func)
bound_types = sig.bind_partial(*typed_args, **typed_kwargs).arguments
@functools.wraps(func)
@NucciTheBoss
NucciTheBoss / compound_status.py
Last active April 6, 2023 16:52
Compound statuses for charm operators
# Copyright 2023 Jason C. Nucciarone
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@NucciTheBoss
NucciTheBoss / pack_charms_on_centos7.md
Created March 9, 2023 18:53
How to pack charmed operators on CentOS 7 using charmcraft

How to pack charms on CentOS 7 using charmcraft

So, you have the situation where you need to pack a newer charm that uses the latest and greatest bells and whistles Python provides, but the default Python on CentOS 7 (Python 3.6 to be exact) is too old? This quick guide will tell you how to get a CentOS 7 packer instance up and running using libvirt/kvm packing charms before you know it.

Originally I was going to use a CentOS 7 virtual machine with LXD, but it was having consistent connectivity issues. Even though the virtual machine had an IP address, lxc was incapable of reaching. Also, the virtual machine struggled to connect to the internet after it was first started, requiring an IP address to be manually assigned with dhclient -v

@NucciTheBoss
NucciTheBoss / unit_connection.py
Last active January 24, 2023 15:56
Asynchronous context manager for connecting to Juju units with ssh and pytest_operator
#!/usr/bin/env python3
# Copyright 2023 Jason C. Nucciarone
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@NucciTheBoss
NucciTheBoss / slurmdbd_conf_editor.py
Created January 11, 2023 14:38
An in-place configuration file editor for slurmdbd.conf written in Python
#!/usr/bin/env python3
"""Abstractions that wrap the slurmdb configuration file."""
import logging
import pathlib
import re
from collections import deque
from datetime import datetime
from enum import Enum
@NucciTheBoss
NucciTheBoss / filterdict.py
Last active September 27, 2022 17:59
Filtering a dictionary recursively
#!/usr/bin/env python3
"""Filter None out of a dictionary with nested data structures."""
from typing import Dict
def filterdict(dirty: Dict) -> Dict:
"""Filter `None` values out of a dictionary.
@NucciTheBoss
NucciTheBoss / pypiserver.service
Created September 12, 2022 13:36
Systemd service files for my private services!
# sudo snap install pypi-server
# cat << EOF > /etc/systemd/system/pypiserver.service <This file> EOF
# systemctl enable pypiserver
[Unit]
Description=A minimal PyPI server for use with pip/easy_install.
After=network.target
[Service]
Type=simple