Skip to content

Instantly share code, notes, and snippets.

View lad1337's full-sized avatar
🤔
💡

Dennis Lutter lad1337

🤔
💡
View GitHub Profile
@lad1337
lad1337 / ElementImporter.gd
Created February 7, 2024 21:18
csv to resource godot
@tool
extends EditorPlugin
@export_file(".csv") var csv_path = "res://data/elements/elements.csv"
@export_dir var tres_dir = "res://resources/elements/"
const converter_path = preload("res://addons/elementimporter/ElementImporter.tscn")
var dockedScene
@lad1337
lad1337 / spinner.py
Created January 29, 2021 21:52
octoprint physical spinner poller
#!/usr/bin/env python
from time import sleep
import requests
import pigpio
API_KEY = "put you octoprint api key here"
GPIO = 18
PI = pigpio.pi()
@lad1337
lad1337 / globimport.py
Created March 23, 2018 08:43 — forked from mdomke/globimport.py
Python glob import
import importlib
import pkgutil
def globimport(pattern):
base, found, rest = pattern.partition('*')
if not (found or rest):
try:
importlib.import_module(base.rstrip('.'))
except ImportError:
@lad1337
lad1337 / sliding_window.py
Last active March 2, 2018 16:37
a sliding window generator in python
def sliding_window(iterable, size, overlap=0):
"""
>>> list(sliding_window([1, 2, 3, 4], size=2))
[(1, 2), (3, 4)]
>>> list(sliding_window([1, 2, 3], size=2, overlap=1))
[(1, 2), (2, 3)]
>>> list(sliding_window([1, 2, 3, 4, 5], size=3, overlap=1))
[(1, 2, 3), (3, 4, 5)]
>>> list(sliding_window([1, 2, 3, 4], size=3, overlap=1))
[(1, 2, 3), (3, 4)]
@lad1337
lad1337 / Copy as JIRA
Last active February 26, 2018 11:31
SequalPro: copy as Jira/MD table in python (very very naive)
#!/usr/bin/env python
# choose "Select Rows (TSV)"
import sys
import os
table = ""
separator = '||'
for line in sys.stdin.readlines():
table += "{sep}{c}{sep}\n".format(c=line.replace('\t', separator).strip(), sep=separator)
separator = '|'
@lad1337
lad1337 / pcp.py
Last active September 5, 2017 12:18
#!/usr/bin/env python
import sys
# run this: pip install git+https://github.com/lad1337/python-plexapi@feature/download-progress
USAGE = "usage: python pcp.py <username> [<password>]"
from plexapi.myplex import MyPlexAccount
from plexapi.video import Episode
from plexapi.video import Movie
from plexapi.video import Show
#!/usr/bin/env python
import sys
from graphviz import Digraph
dot = Digraph(comment='alembic')
def split_line(line):
bases, _, name_and_target = line.partition('->')
id_and_stuff, _, desc = name_and_target.strip().partition(',')
@lad1337
lad1337 / cec.py
Created April 11, 2016 18:01
simple cec client on top of the cec lib
import cec
class PowerStatus():
def __init__(self, power_on):
self.power_on = power_on
def __str__(self):
if self.power_on:
return 'on'
from Crypto.Cipher import AES
import base64
import re
from codecs import open
PADDING = '{'
BLOCK_SIZE = 32
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
@lad1337
lad1337 / coldroms
Last active January 1, 2016 06:49
hacky easy rom loader
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
import requests, clint, easydict
except ImportError:
import pip
pip.main(["install", "requests", "clint", "easydict"])
import requests, clint, easydict
import tempfile, re, sys, os, zipfile