Skip to content

Instantly share code, notes, and snippets.

@bendavis78
bendavis78 / emperor.ini
Created Jan 21, 2020
uwsgi emperor config
View emperor.ini
[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 Jan 21, 2020
UWSGI Django vassal config
View django-vassal.ini
[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
View index.html
<!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 Jan 20, 2020
Example for pagedjs issue
View paged-example.html
<!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 Jan 16, 2020
Extracts images from PDF while preserving PNG transparency
View extract_pdf_images.sh
#!/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 Apr 14, 2022
Building uwsgi w/ support multiple python versions
View uwsgi_custom_build.md

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.

View tictactoe.py
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
View tictactoe_starter.py
import tkinter as tk
from tkinter import messagebox
# We can make a "virtual" game board as a list of lists. The list contains 3 other lists (rows).
# Each row list contains 3 string values representing spaces. The spaces will be populated with
# either "X" or "O", but we start with empty strings to denote an empty space.
#
# We can access a space on the board using row and column indexes. For example, the top-left space
# is `board[0][0]`, the center space is `board[1][1]`, and the bottom-right space is `board[2][2]`.
@bendavis78
bendavis78 / chromeos-recovery.md
Created Dec 20, 2018
Chrome OS recovery images manual download