Skip to content

Instantly share code, notes, and snippets.

@D4koon
D4koon / raspberry_pi_software_button_debounce.py
Created August 14, 2022 09:31
Raspberry pi software button debounce
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
def main():
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
button_pin = 19
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
ButtonHandler(button_pin, GPIO.FALLING, button_callback)
@D4koon
D4koon / rename.py
Created November 26, 2020 11:51
Rename files with Python
import os
def list_files(path):
abs_path = os.path.abspath(path)
files = []
for name in os.listdir(abs_path):
it_path = os.path.join(abs_path, name)
if os.path.isfile(it_path):
files.append(it_path)
@D4koon
D4koon / xmlTreeview.py
Created April 14, 2020 08:38
Python XML-Treeview
#-*- encoding: utf8 -*-
# Call with "python parseXML.py test.xml"
# Tested with Python 3.5
from tkinter import *
from tkinter.ttk import Treeview
import xml.etree.ElementTree as ET
class App:
@D4koon
D4koon / MedianDox.user.js
Last active April 14, 2020 07:01
Median Documentation Enhancer
// ==UserScript==
// @name MedianDox
// @version 5.1.0
// @description Median Documentation Enhancer
// @author D4koon
// @include http*://docs.median-xl.com/doc/*
// @grant GM_addStyle
// @grant GM.setValue
// @grant GM.getValue
// @namespace https://gist.github.com/D4koon/
@D4koon
D4koon / parseXML.py
Last active April 9, 2020 18:31
Simple example parsing an XML and showing it in an Treeview
#-*- encoding: utf8 -*-
# Call with "python parseXML.py test.xml"
from tkinter import *
from tkinter.ttk import Treeview
import xml.etree.ElementTree as ET
class App:
def __init__(self, root):
@D4koon
D4koon / settings.json
Created March 26, 2020 15:45
VSCode color configuration for overviewRuler
{
"workbench.colorCustomizations": {
//"editor.selectionBackground": "#2789f815",
"editor.selectionHighlightBackground": "#f8ea2757",
// Ka was das ist
//"editorOverviewRuler.bracketMatchForeground": "#27f84ada",
// Strg + f farbe
"editorOverviewRuler.findMatchForeground": "#ff7b00",
// Rahmen um selection
//"editor.selectionHighlightBorder": "#ff0000",
@D4koon
D4koon / BitmapToIcon.cs
Last active March 21, 2024 14:48
Create a Icon that calls DestroyIcon() when the Destructor is called.
public class IconExtensions
{
/// <summary>
/// Create a Icon that calls DestroyIcon() when the Destructor is called.
/// Unfortunatly Icon.FromHandle() initializes with the internal Icon-constructor Icon(handle, false), which sets the internal value "ownHandle" to false
/// This way because of the false, DestroyIcon() is not called as can be seen here:
/// https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,f2697049dea34e7c,references
/// To get arround this we get the constructor internal Icon(IntPtr handle, bool takeOwnership) from Icon through reflection and initialize that way
/// </summary>
private static Icon BitmapToIcon(Bitmap bitmap)