Skip to content

Instantly share code, notes, and snippets.

View darrida's full-sized avatar

Ben Hammond darrida

  • Aurora, IL
  • 17:21 (UTC -05:00)
View GitHub Profile
@darrida
darrida / app.py
Last active August 19, 2024 16:02
shinylive-sample
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_widget
import ipyleaflet as ipyl
city_centers = {
"London": (51.5074, 0.1278),
"Paris": (48.8566, 2.3522),
"New York": (40.7128, -74.0060),
}
@darrida
darrida / async_ha_matter_thread_commission.py
Last active June 11, 2023 19:40
Home Assistant: Async workaround to help with commissioning Thread Matter devices
# Source that assisted me with this: https://github.com/home-assistant-libs/python-matter-server
#
# DEPENDENCIES
# - websockets
# - loguru
# - pydantice
#
# ASSUMPTIONS
# - You are using the Home Assistant Sky Connect usb module
# - Module is setup successfully
@darrida
darrida / ha_matter_thread_commission.py
Last active June 11, 2023 19:40
Home Assistant: Workaround to help with commissioning Thread Matter devices
# Source that assisted me with this: https://github.com/home-assistant-libs/python-matter-server
#
# DEPENDENCIES
# - websocket-client
# - loguru
# - pydantice
#
# ASSUMPTIONS
# - You are using the Home Assistant Sky Connect usb module
# - Module is setup successfully
import os, hashlib, binascii
def hash_password(password):
"""Hash a password for storing."""
salt = hashlib.sha256(os.urandom(60)).hexdigest().encode('ascii')
pwdhash = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'),
salt, 100000)
pwdhash = binascii.hexlify(pwdhash)
return (salt + pwdhash).decode('ascii')
from configparser import ConfigParser
# manage configuration file
def config_update(file, section, option, value):
config = ConfigParser()
config.read(file)
cfgfile = open(file, 'w')
if config.has_section(section) == True:
config.set(section, option, value)
else:
@darrida
darrida / md_file_tree.py
Created December 4, 2019 23:35 — forked from elfnor/md_file_tree.py
Generate a file tree table of contents for a directory of markdown files
# -*- coding: utf-8 -*-
"""
Generate a file tree table of contents for a directory of markdown files
run from command line:
$ python md_file_tree.py
will generate a markdown index of all markdown files in the current working
directory and its sub folders and insert it into a file `index.md`.