Skip to content

Instantly share code, notes, and snippets.

View traverseda's full-sized avatar

traverseda traverseda

  • Halifax, Nova Scotia, Canada
View GitHub Profile
@traverseda
traverseda / gist:5a131a7d4a2a0273f370
Created November 11, 2014 22:40
Add a custom widget to all bigIntegerfields on a django_import_export Model Admin, or otherwise override the modelresource_factory
from import_export.resources import *
from import_export.admin import *
from import_export.widgets import Widget
class NullWidget(Widget):
def render(self, value):
if value == "":
return None
return value
@traverseda
traverseda / test.py
Last active August 29, 2015 14:12
verse client example
import vrsent
import subprocess
import time
import os
import argparse
def setup_server():
if os.path.isfile('verse.pid'):
pidfile = open('verse.pid', 'r')
pid = int(pidfile.read())
@traverseda
traverseda / si_markdown.py
Created January 28, 2015 11:31
For converting datapacrats weird syntax into common markdown.
import re,sys,tempfile
import markdown2
def emphasis(matchobject):
return("*{}*".format(matchobject.group(1)))
regexes=[
#Close enough
('/(?!/)(?<!//)(.+?)/',emphasis)
@traverseda
traverseda / betterOS.md
Last active August 29, 2015 14:16
Notes, ranting, etc

A general collection on my thoughts on operating system design. Almost definitly horribly organized. I'll probably sort these into a blog post eventually.


http://www.catb.org/esr/writings/taoup/html/ch20s03.html

I'd like to add an addendum. Binary file formats, or at least poorly documented binary file formats. The amount of time I've spent trying to get a lead on sketchups format...

Plan 9 is obviously nice.

@traverseda
traverseda / gears.scad
Created July 27, 2015 11:15
openscad tiny gears (Might work for layer cutting?)
//cube([5,5,10]);
//cylinder(r=0.6,h=20);
holeWidth=1.6;
toothWidth=holeWidth+0.3;
pi=3.14159265359;
@traverseda
traverseda / Bookmarks.md
Last active May 25, 2022 16:30
Bookmarks
@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() %}
@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 / 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']
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')