Skip to content

Instantly share code, notes, and snippets.

Avatar

Cefn Hoile cefn

View GitHub Profile
View make_xcms.py
#! /home/linuxbrew/.linuxbrew/opt/python@3.8/bin/python3.8
import os
import math
import shutil
import requests
from xml.etree import ElementTree
def decimalMinuteString(decimalDegreeString, paddegrees):
degrees = float(decimalDegreeString)
@cefn
cefn / configurator.js
Last active Apr 5, 2020
Uploads design docs to couchdb through nano for Component testing within views
View configurator.js
const {
Loader
} = require("./designdocs/loader")
class CouchdbConfigurator{
constructor(dbHandle){
if( //duck-type check for nano db handle
typeof dbHandle === "object" &&
typeof dbHandle.config === "object" &&
dbHandle.config.url &&
@cefn
cefn / priority.js
Created Apr 5, 2020
Example view map function
View priority.js
var priorities = [
"!urgent",
null,
"!soon",
"!normal",
"!backlog",
"!wishlist",
]
function getPriorityOrder(task) {
@cefn
cefn / priority.test.js
Created Apr 5, 2020
Example unit-testing for CouchDB map function
View priority.test.js
const testScriptType = "map"
const testScriptId = "priority"
const priorities = [
"!urgent",
null,
"!soon",
"!normal",
"!backlog",
"!wishlist",
]
@cefn
cefn / loader.js
Last active Apr 5, 2020
Strategy for evaluating + unit-testing Couchdb map, reduce, update functions
View loader.js
const path = require("path")
const glob = require("glob")
const fs = require("fs")
const nodeEval = require("node-eval")
/** Helper object to construct a map of named design docs from a path containing js scripts.
* It populates couchdb design documents from js files targeting Spidermonkey 1.8.5
*
* File paths like
* * designdocs/map/priority.js
@cefn
cefn / whitefurze_purchase.py
Created Dec 15, 2019
Purchase order calculation comparing storage box vendors
View whitefurze_purchase.py
from dataclasses import dataclass
@dataclass
class Vendor:
pass
"""
mini45=None
midi45=None
maxi45=None
View test_example.py
import pytest
def checkHelper(value):
assert list(value) == list('foo')
@pytest.mark.parametrize("value", (
'foo',
'far'
))
def testInline(value):
View monkey_patch_dataclass_init.py
def mapInitArgs(cls, fromType, toType, translateFun):
oldinit = cls.__init__
def newinit(self, *args, **kwargs):
fields = cls.__dataclass_fields__
fieldIter = iter(fields)
for pos,arg in enumerate(args):
fieldName = next(fieldIter)
if fields[fieldName].type is toType and type(arg) is fromType:
args[pos] = translateFun(arg)
View interactive-debugging-flowchart.graphml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:java="http://www.yworks.com/xml/yfiles-common/1.0/java" xmlns:sys="http://www.yworks.com/xml/yfiles-common/markup/primitives/2.0" xmlns:x="http://www.yworks.com/xml/yfiles-common/markup/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
<!--Created by yEd 3.18.1-->
<key attr.name="Description" attr.type="string" for="graph" id="d0"/>
<key for="port" id="d1" yfiles.type="portgraphics"/>
<key for="port" id="d2" yfiles.type="portgeometry"/>
<key for="port" id="d3" yfiles.type="portuserdata"/>
<key attr.name="url" attr.type="string" for="node" id="d4"/>
<key attr.name="description" attr.type="string" for="node" id="d5"/>
<key for="node" id="d6" yfiles.type="nodegraphics"/>
View flash.sh
virtualenv myenv
pip3 install vgkits-vanguard
vanguard see firmware
vanguard brainwash circuitpython
vanguard shell
Launching Miniterm to connect to Vanguard Python Shell
Running 'serial.tools.miniterm --raw --eol CR --encoding ascii /dev/ttyUSB0 115200'
--- Miniterm on /dev/ttyUSB0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
You can’t perform that action at this time.