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 / rainbling.ino
Last active December 22, 2016 00:29
Rainbling: A Total Control Lighting Arduino Sketch for rainbows with flashes.
/**************************************************************
* rainbling.ino
*
* An idea for having rainbow colors appear in groups (totems)
* with occasional flashes.
***************************************************************/
#include <SPI.h>
#include <TCL.h>
const int REPEATS = 24;
@devries
devries / cylon_eye.ino
Created September 21, 2014 20:19
Cool Neon Cylon Eye (originally from Mike Winter, possibly modified)
#include <SPI.h>
//LightStrand_RobotMike
//by Mike Winter
//version 3
//Demonstrates chaseing lights
//Intented use: testing LED interface
//Code State: experimental, but it worked for me with 25 lights
//Concept: user adjust Pots to make a color. Color travels down strand of lights
//SPI Interface to strand based on Keith's excellent SPI code, thanks Keith
@devries
devries / json_object.py
Last active August 29, 2015 14:25
A JSON library with an object encoder for python
#!/usr/bin/env python
import json
from datetime import datetime
class ObjectEncoder(json.JSONEncoder):
def default(self,obj):
try:
return json.JSONEncoder.default(self,obj)
except TypeError:
pass
@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 / de.py
Created October 29, 2016 19:45
Differential Evolution (short teach version without comments)
#!/usr/bin/env python
import numpy.random as random
def de_population(pmin,pmax,np):
"""Create a population of np randomly distributed sets of floating point
parameters whose elements are uniformly distributed between the values
in the array pmin and the values in pmax. Return a list of np of these
arrays.
pmin - minimum parameter values
@devries
devries / keybase.md
Created January 10, 2017 21:52
Keybase identity

Keybase proof

I hereby claim:

  • I am devries on github.
  • I am idolstar (https://keybase.io/idolstar) on keybase.
  • I have a public key ASDjQ7wmNg3jKlaiv6K55IgdJqaJ9w_CI-UISWDjnYZV7Ao

To claim this, I am signing this object:

@devries
devries / cos-cloud-config.cfg
Last active March 14, 2017 19:28
Google Container Optimized OS User-data
#cloud-config
users:
- name: cloudservice
uid: 2000
write_files:
- path: /etc/systemd/system/cloudservice.service
parmissions: 0644
owner: root
@devries
devries / ca.md
Created June 3, 2018 13:25 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@devries
devries / Dockerfile
Created June 3, 2018 16:27
Alpine Python Dockerfile notes
FROM python:3.6-alpine
RUN apk add --update \
gcc \
make \
musl-dev \
libuv-dev \
linux-headers \
libxml2-dev \
libxslt-dev \