Skip to content

Instantly share code, notes, and snippets.

View apowers313's full-sized avatar

Adam Powers apowers313

View GitHub Profile
@apowers313
apowers313 / maas_install.sh
Created April 17, 2023 04:44
MAAS Setup Steps
#!/bin/bash
###
# install maas
###
sudo snap install maas
sudo snap install maas-test-db
maas init region+rack --database-uri maas-test-db:///
maas createadmin --username admin --password admin --email admin
@apowers313
apowers313 / maas_config_machine.sh
Created April 17, 2023 04:46
Setup.a new machine on MAAS
#!/bin/bash
# list all hosts
maas admin machines read | grep hostname
# find hosts by status
maas admin machines read status=new | grep hostname
# (new, commissioning, ready)
# find machine
@apowers313
apowers313 / dynaconf_plus_pydantic.py
Created September 3, 2023 16:32
Apply pydantic validation to Dynaconf config
from typing import Any
from dynaconf import Dynaconf
from pydantic import BaseModel, Field
# XXX: no promises that these are complete or correct...
class DynaconfConfig(BaseModel):
ENVVAR_PREFIX_FOR_DYNACONF: str | None
SETTINGS_FILE_FOR_DYNACONF: bool | list[str]
@apowers313
apowers313 / babylon-forcegraph.html
Created March 6, 2024 06:02
Create a 3D Force Graph in Babylon.js using ngraph
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Babylon Template</title>
<style>
html,
body {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@apowers313
apowers313 / simple_kernel.py
Created October 10, 2024 14:17
CUDA Python Simple Kernel
from typing import Any
import numpy as np
from cuda import cuda, cudart, nvrtc
cuda_code = """
extern "C" __global__ void simple() {
printf("this is a test\\n");
}
"""
@apowers313
apowers313 / example.py
Created October 10, 2024 14:17
CUDA Python Example
# type: ignore
import numpy as np
from cuda import cuda, nvrtc
def _cudaGetErrorEnum(error):
if isinstance(error, cuda.CUresult):
err, name = cuda.cuGetErrorName(error)
return name if err == cuda.CUresult.CUDA_SUCCESS else "<unknown>"
@apowers313
apowers313 / simple_kernel_with_arg.py
Created October 10, 2024 14:19
CUDA Python Simple Kernel With Argument
import ctypes
from typing import Any
import numpy as np
from cuda import cuda, cudart, nvrtc
cuda_code = """
extern "C" __global__ void simple(char *str) {
printf("this is a test\\n");
printf("passed argument was: %s\\n", str);
@apowers313
apowers313 / simple_graph.py
Created October 10, 2024 14:19
CUDA Python Simple Graph
from typing import Any
import numpy as np
from cuda import cuda, cudart, nvrtc
cuda_code = """
extern "C" __global__ void simple() {
printf("this is a test\\n");
}
"""
@apowers313
apowers313 / simple_graph_with_arg.py
Created October 10, 2024 14:20
CUDA Python Simple Graph With Argument
import ctypes
from typing import Any
import numpy as np
from cuda import cuda, cudart, nvrtc
cuda_code = """
extern "C" __global__ void simple(char *str) {
printf("this is a test\\n");
printf("passed argument was: %s\\n", str);