Skip to content

Instantly share code, notes, and snippets.

View traverseda's full-sized avatar

traverseda traverseda

  • Halifax, Nova Scotia, Canada
View GitHub Profile
"""A binary serializer inspired by rypc's brine.
"""
#from __future__ import annotations
import typing, collections
from io import BytesIO, BufferedReader
from typing import Union, Tuple, FrozenSet, Generator
from functools import singledispatch
singleTons = Union[bool,None]
immutableTypes = Union[singleTons,int,float,complex,str,bytes,slice,Tuple["immutableTypes", ...],FrozenSet["immutableTypes"]]
@traverseda
traverseda / settings.py
Created June 22, 2018 15:08
12factor/django snippet for configging django via enviroment variables
import environ
root = environ.Path(__file__) - 2
# SECURITY WARNING: don't run with debug turned on in production!
env = environ.Env(DEBUG=(bool, True),) # set default values and casting
environ.Env.read_env() # reading .env file
ALLOWED_HOSTS = ['localhost', *env("ALLOWED_HOSTS", default="").split(",")]
SITE_ROOT = root()
@traverseda
traverseda / phoneAlarm.py
Created June 7, 2018 14:12
A termux cuckoo clock for android
#!/data/data/com.termux/files/usr/bin/python
import schedule, time, datetime
import os
def alarm():
print(datetime.datetime.now())
os.system("termux-vibrate -d 500 -f")
def hourAlarm():
print(datetime.datetime.now())
@traverseda
traverseda / traverseda_cla.md
Last active January 10, 2018 18:10
Personal CLA

Contributor License Agreement

The following terms are used throughout this agreement:

  • You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.
  • Project - is an umbrella term that refers to the "traverseda.uwsgi" project.
  • Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work.
  • Submitted - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or verbal communication with Alex Davies, contributors or maintainers.
  1. Grant of Copyright License.
"""
A system for storing your junk. Print a label, stick it on a box.
Write down what's in that box.
Boxes have a url, constisting of inventory://{Namespace}:{glyphString}.
For example, 'inventory://traverseda:red-ox-yellow-sheep' for the 200th-ish box
that I tag.
Things that go in the box should be refered to by an NFC tag, a uuid, or just write
from sympy import S
from wrapt import ObjectProxy
"""
A class for quickly doing math on percentages,
using bayes theorum.
"""
one = S(1)
import uasyncio as asyncio
import logging, traceback
class Server:
def __init__(self,dir="srv"):
self.dir = dir
self.routes={}
self.textTypes=('css','js')#Html is preprocessed
self.imageTypes=('png','gif','jpg','ico')
@traverseda
traverseda / findIP.py
Created January 6, 2017 09:02
A script for finding your real, network-adressable, ip.
from json import loads
import requests
def jsonip():
return loads(requests.get('http://jsonip.com').text)['ip']
def ippl():
return requests.get('http://ip.42.pl/raw').text
def httpbin():
return loads(requests.get('http://httpbin.org/ip').text)['origin']
@traverseda
traverseda / vim.py
Last active December 9, 2016 23:29
For https://github.com/jonathanslenders/ptpython/issues/155 . Edit datastructures in yaml using vim.
from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
import yaml, tempfile, subprocess, sys
def edit(data):
fd, temp_path = tempfile.mkstemp(prefix='punctual.')
@traverseda
traverseda / jsonrenderer.html
Created January 28, 2016 19:04
Render a json-tree recusrivly in jinja2
{% macro keyValue(key,value) -%}
{# generic case, if key doesn't match a particular renderer #}
<div class="{{key}}">
{{ router(value) }}
</div>
{%- endmacro %}
{% macro router(value)%}
{% if value is mapping %}
{% for key2,value2 in value.items() %}