Skip to content

Instantly share code, notes, and snippets.

View kfsone's full-sized avatar

Oliver Smith kfsone

View GitHub Profile
@kfsone
kfsone / simple_hue_commands.ipynb
Created June 12, 2017 07:11
Simple demonstration of talking to a hue hub to control a lamp.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env python
"""
Intended for use from ipython, but you can use via import.
iPython usage:
import saves
csvs = saves.init()
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False
@kfsone
kfsone / failfn.go
Last active May 24, 2019 06:00
A proposal for formalizing and inlining error handling in the Go language
// Go's informal error handling syntax introduces a lot of boiler-plate and ambiguity:
// boiler-plate: you have to capture and test the value, and you frequently want to forward it, etc
// there is also the potential for people to violate convention/norms.
func sqrt(value float64) (float64, error, error) {
// what does the second error mean?
}
func v(value float64) (error) {
// just, what ?
// this is pseudo-c
struct Pointers {
const char *timestampStart;
const char *timestampEnd;
const char *pidStart;
const char *pidEnd;
const char *levelStart;
const char *levelEnd;
const char *prefixStart;
import random
# time
t = 0
# how likely is replication to be successful
replication_success_ratio = 0.7
# estimate time for rna in a cell to reach a replication center,
# we'll also repurpose it as how long it takes a viable strand to
# start itself replicating (which is generous),
# and how long the virions in a dead cell take to find new cells.
<comment>
A pseudo-RXML of how you might implement a table-rendering based on a collection of YAML files,
using technologies built into Roxen since 1995, imagining the vcs tag had gained git support,
and that a yaml tag had been introduced similar to other parsing tags.
Roxen was based on uLPC, the MUD language, which was a dynamic (jit'd -> p-code) C++/Objective-C
like language, which meant it was capable of jit/caching dynamic content generation...
It featured a server-side XML-based scripting language called RXML which integrated with
your HTML fluidly the way modern HTML 5 introduced things like <template> etc.
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False