Skip to content

Instantly share code, notes, and snippets.

View DanEdens's full-sized avatar
🧑‍🔬
Checkout my website demo at Madnessinteractive.cc/login

TheMadTinker DanEdens

🧑‍🔬
Checkout my website demo at Madnessinteractive.cc/login
  • United States
View GitHub Profile
@DanEdens
DanEdens / mqtt_handler.py
Created May 12, 2023 13:33
mqtt python logger
import errno
import logging
import os
from datetime import datetime
from pathlib import Path
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
# Create utils specific fallback logger for Debugging debug mode
import errno
import html
import logging
import os
import platform
import re
import socket
import subprocess
import time
from datetime import datetime
@DanEdens
DanEdens / PageUtilities.py
Last active August 25, 2023 14:09
Selenium page utilities
import os
import time
from selenium.common import TimeoutException
from selenium.webdriver import ActionChains
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support import expected_conditions as expect
from selenium.webdriver.support.wait import WebDriverWait
#import testKitUtils
@DanEdens
DanEdens / get.py
Created December 23, 2022 17:11
Get mqtt variable in python
import subprocess
def set_variable_from_mqtt_topic(name: str, awsip: str, awsport: str, topic: str) -> str:
"""
Subscribes to the specified MQTT topic and sets the value of the variable with the specified name to the value
received from the topic.
"""
# Replace any equals signs in the name with colons
name = name.replace("=", ":")
@DanEdens
DanEdens / sql_store_data.py
Created December 23, 2022 17:10
store_sql_data
import sqlite3
def store_data(device, version, results_url, ticket_key, timestamp, test_name, test_config):
conn = sqlite3.connect('tests.db')
c = conn.cursor()
c.execute('CREATE TABLE IF NOT EXISTS tests (device text, version text, results_url text, ticket_key text, timestamp text, test_name text, test_config text)')
c.execute('INSERT INTO tests (device, version, results_url, ticket_key, timestamp, test_name, test_config) VALUES (?, ?, ?, ?, ?, ?, ?)', (device, version, results_url, ticket_key, timestamp, test_name, test_config))
conn.commit()
@DanEdens
DanEdens / heygpt.py
Created December 23, 2022 17:05
python ask chatgpt with screenshot
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Start a new webdriver instance
driver = webdriver.Firefox()
# Navigate to the page with the text field
driver.get('http://www.example.com/chatgpt')
# Find the text field element on the page
@DanEdens
DanEdens / fet.py
Created December 23, 2022 17:03
get file from mqtt in python
import os
import subprocess
def subscribe_to_mqtt_topic(
topic: str, path: str, awsip: str=os.getenv("AWSIP"),
awsport: str=os.getenv("AWSPORT")) -> str:
"""
Subscribes to the MQTT topic with the specified name and writes the received messages to a file with the same name.
Returns the file path of the created file.
"""
@DanEdens
DanEdens / Install-apache-maven.bat
Created December 23, 2022 17:02
Install-apache-maven-windows
@echo off
echo Installing Apache Maven...
rem Set the Maven version to install
set MAVEN_VERSION=3.6.3
rem Set the installation directory for Maven
set MAVEN_INSTALL_DIR=C:\Program Files\Apache\maven
@DanEdens
DanEdens / gist:9d257f82e62072469ebebbe3e3e21b51
Last active December 9, 2022 20:36
.git/hooks/post-commit
#!/bin/sh
# Exit immediately if any command returns a non-zero exit code
set -e
# Check if the current directory is a git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
printf "Error: current directory is not a git repository\n"
exit 1
@DanEdens
DanEdens / LGS_script_template.lua
Created November 4, 2022 12:57 — forked from Egor-Skriptunoff/LGS_script_template.lua
Template script file for Logitech Gaming Software
---------------------------------------------------------------------------------------------
-- LGS_script_template.lua
---------------------------------------------------------------------------------------------
-- Version: 2019-04-19
-- Author: Egor Skriptunoff
--
--
-- This is a template for "Logitech Gaming Software" script file.
-- Four useful features are implemented here:
--