Skip to content

Instantly share code, notes, and snippets.

View mdhowle's full-sized avatar

Matthew Howle mdhowle

View GitHub Profile
@mdhowle
mdhowle / README.md
Last active July 31, 2022 05:10
Model Serializer for Multiple table models

This will serialize inherited models.

This requires django-rest-framework and django-model-utils for InheritanceManager

@mdhowle
mdhowle / certdns.sh
Last active February 28, 2021 01:48
Script to automate obtaining Let's Encrypt certificate with certbot using Linode DNS API
#!/bin/sh
CERTBOT_LINODE_KEY="${CERTBOT_LINODE_KEY}"
CERTBOT_EMAIL="${CERTBOT_EMAIL}"
CERTBOT_VENV=/var/cache/virtualenvs/certbot
CERTBOT_UNDO=0
CERTBOT_USE_VENV=0
CERTBOT_PROPOGATION_TIME="${CERTBOT_PROPOGATION_TIME:-1000}"
CERTBOT_DOMAIN_ARGS=""
CERTBOT_EMAIL_ARGS=""
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]*[0-9]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.4", SYMLINK+="usbport13p%n", OPTIONS+="all_partitions", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.4", SYMLINK+="usbport13", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]*[0-9]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.3", SYMLINK+="usbport12p%n", OPTIONS+="all_partitions", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.3", SYMLINK+="usbport12", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]*[0-9]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.2", SYMLINK+="usbport11p%n", OPTIONS+="all_partitions", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000", KERNEL=="sd*[a-z]", SUBSYSTEM=="block", ATTRS{devpath}=="*[0-9].4.4.4.2", SYMLINK+="usbport11", GOTO="usb_end"
ENV{USB_VENDOR_MODEL}=="8563:4000"
# BEGIN Initiate mate-session.target
systemctl --user import-environment PATH DBUS_SESSION_BUS_ADDRESS KRB5CCNAME
systemctl --no-block --user start mate-session.target
# END Initiate mate-session.target
@mdhowle
mdhowle / uwsgi-and-nginx.md
Created May 15, 2018 14:10 — forked from pcostesi/uwsgi-and-nginx.md
uWSGI and NGiNX
@mdhowle
mdhowle / log_test11.py
Created December 15, 2017 16:00 — forked from anonymous/log_test11.py
Test script showing usage of a buffering SMTP handler.
#!/usr/bin/env python
#
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
#!/bin/bash
display_help() {
SCRIPTNAME=$(basename "$0")
echo "${SCRIPTNAME} setup.exe destination"
echo "Script to extract and convert a Windows GOG.COM DOSBOX installer to a Linux install"
echo
echo "Arguments:"
echo " setup.exe The GOG.COM Windows executable"
echo " destination The directory to install to"
@mdhowle
mdhowle / tcp_server.c
Created March 27, 2017 03:02 — forked from oleksiiBobko/tcp_server.c
Simple socket server in C using threads (pthread library) Compiles on linux
/*
C socket server example, handles multiple clients using threads
Compile
gcc server.c -lpthread -o server
*/
#include<stdio.h>
#include<string.h> //strlen
#include<stdlib.h> //strlen
#include<sys/socket.h>
@mdhowle
mdhowle / nginx-jail.sh
Created March 17, 2017 02:18 — forked from adityamukho/nginx-jail.sh
Setup a CHROOT jail at `/srv/http` for a public Nginx server on Arch Linux.
#!/bin/bash
pacman -S nginx
export JAIL=/srv/http
# Create Necessary Devices
mkdir $JAIL/dev
mknod -m 0666 $JAIL/dev/null c 1 3
mknod -m 0666 $JAIL/dev/random c 1 8
mknod -m 0444 $JAIL/dev/urandom c 1 9
from sys import stdout
from twisted.python.log import startLogging
from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol
class PatchServer(Protocol): #6005
def connectionMade(self):
print 'PATCH: Client connected: %s' % self.transport.getPeer()