Skip to content

Instantly share code, notes, and snippets.

View devries's full-sized avatar
🏠
Working from home

Christopher De Vries devries

🏠
Working from home
View GitHub Profile
@devries
devries / kstest.py
Created April 29, 2014 16:19
An implementation of the Kolmogorov-Smirnov test in python
#!/usr/bin/env python
import math
import sys
def main(argv=None):
if argv is None:
argv = sys.argv
if len(argv) != 3:
print >>sys.stderr, "Usage:",sys.argv[0],"<datafile1> <datafile2>"
@devries
devries / dhcp_option119.py
Last active April 19, 2023 17:25 — forked from grawity/dhcp_option119.py
a script for converting domain names to DHCP Option 119 (Domain Search Option)
#!/usr/bin/env python3
"""Command generator for setting DHCP Option 119
This script converts the specified domain names to DHCP Option 119
(Domain Search Option) and prints commands for various DHCP servers.
USAGE:
./dhcp_option119.py DOMAIN ...
EXAMPLE:
@devries
devries / ssl_redirect.py
Last active March 24, 2022 09:02
WSGI middleware to redirect incoming http requests to https. This is not original, but I can't remember where I first found it.
from urllib import quote
class SSLRedirect(object):
def __init__(self,app):
self.app=app
def __call__(self,environ,start_response):
proto = environ.get('HTTP_X_FORWARDED_PROTO') or environ.get('wsgi.url_scheme', 'http')
if proto=='https':
@devries
devries / makestableipv6.sh
Created September 10, 2021 16:49
Need a random in the sysctl conf file
#!/bin/sh
# This file goes in /etc/sysctl.d to set up a stable-privacy IPv6 Address
cat > 50-rfc7217.conf <<EOF
# Set up a secret for RFC7217 private static IPv6 address
net.ipv6.conf.default.stable_secret = $(hexdump -n 16 -e '7/2 "%04x:" 1/2 "%04x" "\n"' /dev/urandom)
EOF
@devries
devries / tmux.conf
Last active October 28, 2020 15:42
Use CTRL-a the way God intended.
unbind C-b
set -g prefix C-a
bind C-a send-prefix
bind-key a send-keys C-a
@devries
devries / terminal.go
Created April 30, 2020 16:35
Some terminal UI example
package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"strings"
)
@devries
devries / main.go
Last active March 20, 2020 19:32
Go Generator with Context
package main
import (
"context"
"fmt"
"math"
"time"
)
func main() {
@devries
devries / Dockerfile
Created August 14, 2019 18:33
Alpine Nginx image
FROM alpine:3.10
RUN apk update && apk upgrade
RUN apk add openssl curl ca-certificates
RUN printf "%s%s%s\n" \
"http://nginx.org/packages/mainline/alpine/v" \
`egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release` \
"/main" \
| tee -a /etc/apk/repositories
RUN curl -o /etc/apk/keys/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
RUN apk add nginx
@devries
devries / singleton_main.go
Last active October 29, 2018 15:57
Singleton Example for Go
package main
import (
"fmt"
"sync"
"time"
)
func main() {
go setter()
@devries
devries / rainbow.py
Created September 29, 2018 19:25
Writing over SPI to TCL LEDs from python
#!/usr/bin/env python
import time
import math
def main():
#fout = open('spidev','w')
fout = open('/dev/spidev2.0', 'w')
ctr = 0