Skip to content

Instantly share code, notes, and snippets.

View apowers313's full-sized avatar

Adam Powers apowers313

View GitHub Profile
@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 {
@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 / 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 / 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 / hello.yaml
Created April 17, 2023 04:38
Basic microk8s / Kubernetes service
apiVersion: v1
kind: Service
metadata:
name: ingress
namespace: ingress
spec:
selector:
name: nginx-ingress-microk8s
type: LoadBalancer
# loadBalancerIP is optional. MetalLB will automatically allocate an IP
@apowers313
apowers313 / test.ts
Last active January 6, 2022 19:38
Deno logger levels
import * as log from "https://deno.land/std@0.119.0/log/mod.ts";
const l = log.getLogger("default");
l.level = log.LogLevels.DEBUG;
l.debug("Hello world"); // XXX: never printed!!!
l.info(123456);
l.warning(true);
l.error({ foo: "bar", fizz: "bazz" });
l.critical("500 Internal server error");
@apowers313
apowers313 / log.txt
Created December 28, 2021 16:48
IDeno hang bug (20211228)
88665a0e64ba:deno ampower$ jupyter notebook
[D 08:31:18.955 NotebookApp] Raising open file limit: soft 256->4096; hard 9223372036854775807->9223372036854775807
[D 08:31:18.979 NotebookApp] Paths used for configuration of jupyter_notebook_config:
/etc/jupyter/jupyter_notebook_config.json
[D 08:31:18.980 NotebookApp] Paths used for configuration of jupyter_notebook_config:
/usr/local/etc/jupyter/jupyter_notebook_config.json
[D 08:31:18.980 NotebookApp] Paths used for configuration of jupyter_notebook_config:
/usr/local/Cellar/jupyterlab/3.2.4/libexec/etc/jupyter/jupyter_notebook_config.d/jupyterlab.json
/usr/local/Cellar/jupyterlab/3.2.4/libexec/etc/jupyter/jupyter_notebook_config.json
[D 08:31:18.981 NotebookApp] Paths used for configuration of jupyter_notebook_config:
@apowers313
apowers313 / main.rs
Last active December 21, 2021 19:34
Rust method as function pointer
use std::collections::HashMap;
macro_rules! handler {
($kernel:expr, $method:ident) => {
Box::new(|x| $kernel.$method(x))
};
}
fn main() {
let k = Kernel::new();
@apowers313
apowers313 / messages.rs
Created December 13, 2021 07:41
Jupyter Messages in Rust
// /* *****************
// * SHELL MESSAGES
// * *****************/
// Shell Request Message Types
// "execute_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute
// "inspect_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection
// "complete_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion
// "history_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#history
@apowers313
apowers313 / output.txt
Last active December 12, 2021 09:32
ideno-rust initial zmq output
[I 01:30:17.834 NotebookApp] Kernel started: aefa459b-5c3e-4d6c-8791-7e42723d61cf, name: rusty
[D 01:30:17.834 NotebookApp] Kernel args: {'kernel_name': 'rusty', 'cwd': '/Users/ampower/Projects/personal/ideno-rust'}
[D 01:30:17.834 NotebookApp] Path toc2/toc2.js served from /Users/ampower/Library/Jupyter/nbextensions/toc2/toc2.js
[D 01:30:17.835 NotebookApp] 200 GET /nbextensions/toc2/toc2.js?v=20211212013005 (::1) 5.130000ms
[D 01:30:17.835 NotebookApp] Path collapsible_headings/main.css served from /Users/ampower/Library/Jupyter/nbextensions/collapsible_headings/main.css
[D 01:30:17.836 NotebookApp] 200 GET /nbextensions/collapsible_headings/main.css?v=20211212013005 (::1) 5.520000ms
[D 01:30:17.837 NotebookApp] Using contents: services/contents
[W 01:30:17.838 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20211212013005 (::1) 6.600000ms referer=http://localhost:8888/notebooks/Untitled15.ipynb?kernel_name=rusty
[D 01:30:17.840 NotebookApp] 201 POST /api/sessions (::1) 59.690000ms
[D