Skip to content

Instantly share code, notes, and snippets.

Note (minor): could not create multicast responder for address FF31:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2 (failed with: set_option: No such device)
Note (minor): could not create multicast responder for address FF02:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2 (failed with: set_option: No such device)
Note (minor): could not create multicast responder for address FF05:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2 (failed with: set_option: No such device)
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 2 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyACM0 - Low Energy Dongle - CDC control
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC control VID=0x2458 PID=0x0001 on /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
@calroc
calroc / dre.py
Created June 26, 2018 01:05
Dirty but functional implementation of Brzozowski’s derivatives of regular expressions.
from itertools import product
phi = frozenset()
y = frozenset({''})
syms = O, l = frozenset({'0'}), frozenset({'1'})
AND, CONS, KSTAR, NOT, OR = 'and cons * not or'.split()
/*
Via https://www.metalevel.at/prolog/puzzles
The "Zebra Puzzle" https://en.wikipedia.org/wiki/Zebra_Puzzle
- There are five houses.
- The Englishman lives in the red house.
- The Spaniard owns the dog.
- Coffee is drunk in the green house.
@calroc
calroc / WTFAPL.ipynb
Created March 8, 2017 23:35
Nerd-sniped. APL algorithm for frindin primes is elegant but wasteful, can do better? 2 new messages since 1:28 PM Mark as read (esc)Mark as read Channel #tech
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calroc
calroc / password_generator.py
Created December 2, 2013 22:33
A simple and straightforward password generator that produces alphanumeric random strings of length ten omitting those characters that are easily confused with each other in various fonts. Ensures at least one character will be a numeral.
#!/usr/bin/env python
from string import letters, digits
from random import choice
# Get a list of unambiguous ASCII characters. (It must be a list as
# sets don't work with random.choice().)
chars = list(set(letters + digits) - set('oO0I1lB8S5b6'))
@calroc
calroc / Solving Logic Puzzles with the Laws of Form Notation.json
Last active December 26, 2015 02:09
Solving Logic Puzzles with the Laws of Form Notation
{
"metadata": {
"name": "Solving Logic Puzzles with the Laws of Form Notation"
},
"name": "Solving Logic Puzzles with the Laws of Form Notation",
"nbformat": 2,
"worksheets": [
{
"cells": [
{
@calroc
calroc / om.py
Created March 4, 2013 08:36
Driving the LogPy logic package using a simple Omega parser. I'm probably being silly and naive, but it's fun. https://github.com/logpy/logpy https://gitorious.org/python-omega/
#!/usr/bin/env python
from omega import BaseParser
from logpy import run, eq, membero, var, conde
# Still TODO: membero and conde
#: Namespace for storing logic variable as they are defined.
variables = {}
@calroc
calroc / Algorithmic Beauty of Plants.py
Last active December 14, 2015 11:38
I'm just noodling around with the Python-Omega parser (https://gitorious.org/python-omega), and I used it to implement a simple version of the Anabaena catenula "simulator" from the book "The Algorithmic Beauty of Plants" http://algorithmicbotany.org/papers/#abop One interesting thing is that the DOL-system is meant to evaluate its terms in para…
#!/usr/bin/env python
'''
A simple demonstration of a deterministic and context-free "DOL-system"
"...used to simulate the development of a fragment of a multicellular
filament such as that found in the blue-green bacteria Anabaena catenula..."
- "The Algorithmic Beauty of Plants" http://algorithmicbotany.org/papers/#abop
Implemented by simple parsers in the Omega parser language (a variant of
Warth's OMeta language.) https://gitorious.org/python-omega
'''
@calroc
calroc / six_step_reframe.py
Created February 6, 2013 02:24
This is Python pseudocode for the deprecated Six Step Reframe pattern.
from nlp import unconscious_connection
behavior = 'some behaviour you want to change'
urmind = unconscious_connection()
G = urmind.get_generative_part()
I = urmind.intention_of(behavior)
@calroc
calroc / d2j.py
Created January 4, 2013 05:52
A wee little script to convert the Pigeon User Interface into JSON suitable for graphing with the D3.js visualization kit. See http://thinkpigeon.blogspot.com/2013/01/persistant-binary-tree.html
from pigeon.xerblin.world import ROOT
def trreee(node):
key, value, lower, higher = node
it = {'name': key}
children = []
if lower:
children.append(trreee(lower))
if higher:
children.append(trreee(higher))