Skip to content

Instantly share code, notes, and snippets.

@danricho
danricho / mount_samba_shares.py
Created July 21, 2022 06:44
Python script to mount SAMBA shares available to SAMBA user within linux - tested on Raspberry Pi.
# USE PYTHON3
from ast import Pass
import os, json, getpass
if os.geteuid() != 0:
print("Must be run with sudo to manipulate mounts.")
exit()
def get_cifs_mounts():
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danricho
danricho / keepalive_ngrok.py
Created January 30, 2022 23:18 — forked from just4give/keepalive_ngrok.py
ngrok forever on raspberry pi
import json
import subprocess
import time
from pathlib import Path
import atexit
import boto3
import requests
import datetime
#path where you have extracted ngrok execution file. Follow readme file to install on Pi
@danricho
danricho / govee_h5074.py
Created January 19, 2022 06:31
Govee Receive
# needs to run as sudo (probably to lock the use of the RPi bluetooth).
# based on gist by tchen @ https://gist.github.com/tchen/65d6b29a20dd1ef01b210538143c0bf4
# changed to look for H5074 and decode its data messages
from datetime import datetime
from time import sleep
from bleson import get_provider, Observer
# pip install bleson
govees = {}
@danricho
danricho / UniFiClients.py
Last active July 30, 2022 12:59
Unifi API Access
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# BASED ON ALCHEMYDC'S GREAT SCRIPT HERE:
# https://github.com/alchemydc/unifi_device_manager
#
# > ADDED FUNCTIONS FOR GETTING CLIENT LIST AND ACTIVE CLIENT LIST
# > HAD TO ADD "verify=False" TO ALL REQUESTS CALLS
# BECAUSE I HAVEN'T GOT A CERT SORTED IN UNIFI YET
# > TESTED ON CLOUD KEY GEN2 PLUS
@danricho
danricho / Arduino Python Comms
Created January 1, 2021 05:04
Arduino Python Comms
This is a simple communication scheme between python and Arduino over Serial.
@danricho
danricho / Tkinter_Simple.py
Created January 1, 2021 04:45
Simple wrapper for some of TKinter
from tkinter import *
from tkinter import ttk
from datetime import datetime
# A SMALL PYTHON CLASS I WROTE TO SIMPLIFY GUI DEVELOPMENT.
def myPrinter(str):
print(datetime.now().strftime('%H:%M:%S ') + str)
@danricho
danricho / tester.py
Last active December 20, 2020 04:55
Test of XInput-Python library with Xbox Series X controller.
# library: https://github.com/Zuzu-Typ/XInput-Python
# install using: pip install XInput-Python
#
# Tested with Xbox Series X controller on Windows 10, Python 3.8.6
# Controller firmware up to date on 20/12/2020 (Xbox Accessory app on PC)
# New "Share" Button inoperative.
# Got status of battery pack (Xbox Rechargable Battery with USB-C Cable)
# Tested with cable not bluetooth.
from XInput import *
@danricho
danricho / MSFS2020ControlBox
Last active October 27, 2020 07:44
MSFS2020 Arduino based control box with Python SimConnect interface
Ignore - Gist Naming File
@danricho
danricho / Log.py
Last active November 21, 2021 23:02
def logPrint(*args, sep=" ", system=None, color=Style.RESET_ALL, **kwargs):
if system:
print(datetime.now().strftime('%H:%M:%S.%f')[:-3] + " : " + color + str(system).ljust(10)[0:10] + Style.RESET_ALL + " : " + sep.join(map(str,args)), **kwargs)
else:
print(datetime.now().strftime('%H:%M:%S.%f')[:-3] + " : " + sep.join(map(str,args)), **kwargs)