Skip to content

Instantly share code, notes, and snippets.

@bendavis78
bendavis78 / brick.py
Created October 2, 2023 17:41
Brick tutorial using 123d CAD library
from build123d import *
from ocp_vscode import *
C, MIN, MAX = Align.CENTER, Align.MIN, Align.MAX
pip_count = 6
brick_unit_size = 8
pip_height = 1.8
pip_diameter = 4.8
@bendavis78
bendavis78 / gist:6f7f6bc9c75e21094a54fc020cc054ee
Last active September 25, 2023 01:18
build123d installation on macos apple silicon m1
# As of 9/24/2023
# This requires conda, mamba, or micromamba
micromamba create -n code_cad python=3.10 -c conda-forge
micromamba -n code_cad install -c cadquery -c conda-forge cadquery=master
micromamba -n code_cad run pip install \
'typing_extensions~=4.4.0' 'numpy~=1.24.1' 'svgpathtools~=1.5.1' \
'anytree~=2.8.0' 'ezdxf~=1.0.0' 'numpy-stl~=3.0.0' 'ipython~=8.0.0' \
'git+https://github.com/CadQuery/OCP-stubs@7.7.0#egg=OCP-stubs' \
'git+https://github.com/jdegenstein/py-lib3mf#egg=py_lib3mf'
micromamba -n code_cad run pip install --no-deps git+https://github.com/gumyr/build123d
{
"home_assistant": {
"installation_type": "Unknown",
"version": "2022.12.3",
"dev": false,
"hassio": false,
"virtualenv": false,
"python_version": "3.10.8",
"docker": false,
"arch": "x86_64",
@bendavis78
bendavis78 / emperor.ini
Created January 21, 2020 17:02
uwsgi emperor config
[uwsgi]
plugins-dir = /usr/lib/uwsgi/plugins
emperor = /etc/uwsgi/vassals/*.ini
show-config = 1
uid = http
gid = http
emperor-stats = /run/uwsgi/emperor-stats.sock
umask = 002
logto = /var/log/uwsgi/emperor.log
@bendavis78
bendavis78 / django-vassal.ini
Created January 21, 2020 16:59
UWSGI Django vassal config
[uwsgi]
module = hive.wsgi
workers = 6
plugins = python3
base = /srv/hive
virtualenv = /srv/hive
logto = /srv/hive/log/uwsgi.hive.log
socket = /run/uwsgi/hive.sock
touch-reload = /srv/hive/reload
buffer-size = 32768
<!doctype html>
<html>
<head>
<script src="load-pages.js"></script>
<script>window.PagedConfig = {auto: false};</script>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<style>
@media screen {
.pagedjs_sheet {
box-shadow: 1px 1px 4px 1px rgba(0,0,0,0.15);
@bendavis78
bendavis78 / paged-example.html
Created January 20, 2020 21:27
Example for pagedjs issue
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<style>
@media screen {
.pagedjs_sheet {
box-shadow: 1px 1px 4px 1px rgba(0,0,0,0.15);
margin: 20px auto;
}
@bendavis78
bendavis78 / extract_pdf_images.sh
Created January 16, 2020 19:30
Extracts images from PDF while preserving PNG transparency
#!/bin/bash
usage() {
echo "Usage: $(basename $0) in.pdf dest";
}
[[ -z "$1" ]] && usage && exit 1;
[[ -z "$2" ]] && usage && exit 1;
TMPDIR="$(mktemp -d)";
DIR=$2;
@bendavis78
bendavis78 / uwsgi_custom_build.md
Last active November 6, 2023 15:53
Building uwsgi w/ support multiple python versions

Installation

Remove all traces of uwsgi on the system, if previously installed

apt remove uwsgi uwsgi-core
rm /usr/bin/uwsgi
rm /usr/local/bin/uwsgi
rm -rf /usr/lib/uwsgi
rm -rf /usr/local/lib/uwsgi

Any config files in /etc can stay.

import ml4k
import random
import tkinter as tk
from copy import copy
from tkinter import messagebox
API_KEY = "PASTE-API-KEY-HERE"
AI_MODE = "random"
TRAINING = False