Skip to content

Instantly share code, notes, and snippets.

View danieljfarrell's full-sized avatar

Daniel danieljfarrell

View GitHub Profile
@danieljfarrell
danieljfarrell / tree_scroll.py
Created September 14, 2021 15:18
TraitsUI tree editor example
from traits.api import HasTraits, Str, List, Button, Any
from traitsui.api import TreeNode, TreeEditor, View, ModelView, Group, VGroup, Item
from pkg_resources import resource_filename
tree_icon_path = resource_filename("traitsui", "wx/images")
class Measurement(HasTraits):
name = Str("Measurement")
@danieljfarrell
danieljfarrell / code_blocks2.vbp
Last active May 25, 2021 10:45
VB code block for controlling Ronald Dekker's uTracer copt-paste from here (to have nice syntax highlighting) https://www.dos4ever.com/uTracer3/code_blocks2.txt
Note that:
dblCalVar1 = Va Gain
dblCalVar2 = Vs Gain
dblCalVar3 = Ia Gain
dblCalVar4 = Is Gain
dblCalVar5 = Vsupp
dblCalVar6 = Vgrid(40V)
dblCalVar7 = VglowA
dblCalVar8 = Vgrid(4V)
@danieljfarrell
danieljfarrell / cython_c_struct_idioms.pxd
Created February 26, 2021 18:28
Idioms for handling C struct in Cython
# Idiom - C struct container simple values
#
# Idiom - Use ctypedef so we can can pass this
# easily in and out of functions.
#
cdef struct book:
int uid
ctypedef book book_t
@danieljfarrell
danieljfarrell / example.pyx
Created February 12, 2021 13:52
Cython example showing numpy to C struct
#cython: language_level=3
import cython
import numpy
cimport numpy as cnumpy
# Silly example C struct
cdef struct example:
@danieljfarrell
danieljfarrell / vernemq_grafana_dashboard.json
Last active March 27, 2024 15:29
VerneMQ Grafana dashboard configuration. This works with a VerneMQ, docker swarm cluster and swarmprom
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@danieljfarrell
danieljfarrell / solve_ode_sys.nb
Created June 30, 2020 14:06
Solve chemical reaction for steady-state using Mathematica
ClearAll["Global`*"];
eqns = {X'[t] == P - (k1 + k2) X[t] + A k1 X[t], Y'[t] == k1 X[t] - A k1 X[t] - k3 Y[t], X[0] == 0, Y[0] == 0}
s = Assuming[k0 > 0 && k1 > 0 && k2 > 0 && k3 > 0 && P > 0 && A >= 0 && A < 1, Limit[DSolveValue[eqns,{X[t], Y[t]}, t], t -> \[Infinity]]]
@danieljfarrell
danieljfarrell / docker-compose.yml
Last active May 16, 2020 14:23
This is a single file docker-compose.yml version of tutorial https://medium.com/@containeroo/traefik-2-0-docker-a-simple-step-by-step-guide-e0be0c17cfa5 where all static config. is also done in the compose yaml file
version: "3"
services:
traefik:
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
@danieljfarrell
danieljfarrell / treeview_test.py
Last active April 26, 2022 02:36 — forked from nbassler/treeview_test.py
PyQt5 TreeView with QAbstractItemModel
"""
Reworked code based on
http://trevorius.com/scrapbook/uncategorized/pyqt-custom-abstractitemmodel/
Adapted to Qt5 and fixed column/row bug.
TODO: handle changing data.
"""
import sys
@danieljfarrell
danieljfarrell / state_transitions.py
Created June 7, 2019 13:41
Using an @visits decorator with an async generator to monitor and enforce state transitions
import asyncio
import traceback
import enum
import functools
class InvalidVisitedState(Exception):
""" Raised when an state change sequence is incorrect.
"""
pass
if __name__ == "__main__":
from PyQt5.QtCore import QAbstractItemModel, QFile, QIODevice, QModelIndex, Qt
from PyQt5.QtWidgets import QApplication, QTreeView
import sys
from tree_model import TreeModel, TreeNode, RefNode
class NamedElement(object): # your internal structure
def __init__(self, name, subelements):