Skip to content

Instantly share code, notes, and snippets.

@persquare
persquare / modernize_actors.py
Last active January 11, 2019 07:55
Update old-style actors docs to new-style in place
import os
from docparser import parse_old_doc
import json
import jsonschema
from jsonschema.exceptions import ValidationError
import yaml
from newstore import Store
def actor_files(root):
@persquare
persquare / test.puml
Created July 26, 2018 09:29
Test PlantUML
@startuml
object sensor
object platform_functions
object service_enabler
object application_part
object pub_sub
object consumer
sensor "*" --> "1" platform_functions
@persquare
persquare / nexa.py
Last active November 26, 2017 19:56
A simple RPi controller for Nexa switches based on pigpio. Needs 433MHz transmitter.
#!/usr/bin/env python
# To install pigpio see http://abyz.me.uk/rpi/pigpio/index.html
import pigpio
class Waveform(object):
# Times in microseconds
T1 = 250
T5 = 5*T1
@persquare
persquare / calvinscript.py
Created April 8, 2016 16:34
A CalvinScript lexer for pygments
from pygments.lexer import RegexLexer, bygroups, include, using
from pygments.lexers.data import JsonLexer
from pygments.token import *
__all__ = ['CalvinLexer']
class CalvinLexer(RegexLexer):
name = 'CalvinScript'
aliases = ['Calvinscript', 'calvinscript']
filenames = ['*.calvin']
import sys
def discard():
sys.exit(200)
def replace_text(out = None):
if out:
sys.stdout.write(out)
sys.exit(201)
#!/usr/bin/env python
# encoding: utf-8
"""
This module generates documentation for a TextMate bundle by parsing the .tmCommand files.
"""
import os
import sys
import re
#!/usr/bin/env python -S
"""Open a link (or Markdown style reference link) in TextMate's companion window."""
import os
import sys
import re
envvars = ['TM_BUNDLE_SUPPORT', 'TM_SUPPORT_PATH']
sys.path[:0] = [os.environ[v]+'/lib' for v in envvars if os.environ[v] not in sys.path]
#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
path=`zk --txmt`
if [[ "$path" ]]; then
open $path
fi
@persquare
persquare / zk
Last active March 5, 2020 15:28
Create a ZK-note and return the file path
#!/usr/bin/env python
# zk - create a new zettelkast entry and return the path
import sys
import os
import pwd
import argparse
from datetime import datetime
property inbox_cmd : "$HOME/Tools/bin/inbox"
tell application "Mail"
set theMessages to selection
repeat with msg in theMessages
set title to subject of msg (* Strip Re: etc. *)
set link to "message://%3C" & message id of msg & "%3E"
set arg to title & " " & link
do shell script inbox_cmd & " " & quoted form of arg
end repeat