Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

View lad1337's full-sized avatar
🤔
💡

Dennis Lutter lad1337

🤔
💡
View GitHub Profile
importlogging
importsys
importstructlog
fromstructlog.typesimportEventDict,Processor
# https://github.com/hynek/structlog/issues/35#issuecomment-591321744
defrename_event_key(_,__,event_dict:EventDict)->EventDict:
"""
@lad1337
lad1337 /ElementImporter.gd
CreatedFebruary 7, 2024 21:18
csv to resource godot
@tool
extendsEditorPlugin
@export_file(".csv")varcsv_path="res://data/elements/elements.csv"
@export_dirvartres_dir="res://resources/elements/"
constconverter_path=preload("res://addons/elementimporter/ElementImporter.tscn")
vardockedScene
@lad1337
lad1337 /spinner.py
CreatedJanuary 29, 2021 21:52
octoprint physical spinner poller
#!/usr/bin/env python
fromtimeimportsleep
importrequests
importpigpio
API_KEY="put you octoprint api key here"
GPIO=18
PI=pigpio.pi()
@lad1337
lad1337 /globimport.py
CreatedMarch 23, 2018 08:43— forked frommdomke/globimport.py
Python glob import
importimportlib
importpkgutil
defglobimport(pattern):
base,found,rest=pattern.partition('*')
ifnot (foundorrest):
try:
importlib.import_module(base.rstrip('.'))
exceptImportError:
@lad1337
lad1337 /sliding_window.py
Last activeJune 14, 2024 01:43
a sliding window generator in python
defsliding_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 activeFebruary 26, 2018 11:31
SequalPro: copy as Jira/MD table in python (very very naive)
#!/usr/bin/env python
# choose "Select Rows (TSV)"
importsys
importos
table=""
separator='||'
forlineinsys.stdin.readlines():
table+="{sep}{c}{sep}\n".format(c=line.replace('\t',separator).strip(),sep=separator)
separator='|'
@lad1337
lad1337 /pcp.py
Last activeSeptember 5, 2017 12:18
#!/usr/bin/env python
importsys
# run this: pip install git+https://github.com/lad1337/python-plexapi@feature/download-progress
USAGE="usage: python pcp.py <username> [<password>]"
fromplexapi.mypleximportMyPlexAccount
fromplexapi.videoimportEpisode
fromplexapi.videoimportMovie
fromplexapi.videoimportShow
@lad1337
lad1337 /alembic-graph
Last activeDecember 17, 2025 07:09
#!/usr/bin/env python
importsys
fromgraphvizimportDigraph
dot=Digraph(comment='alembic')
defsplit_line(line):
bases,_,name_and_target=line.partition('->')
id_and_stuff,_,desc=name_and_target.strip().partition(',')
@lad1337
lad1337 /cec.py
CreatedApril 11, 2016 18:01
simple cec client on top of the cec lib
importcec
classPowerStatus():
def__init__(self,power_on):
self.power_on=power_on
def__str__(self):
ifself.power_on:
return'on'
fromCrypto.CipherimportAES
importbase64
importre
fromcodecsimportopen
PADDING='{'
BLOCK_SIZE=32
pad=lambdas:s+ (BLOCK_SIZE-len(s)%BLOCK_SIZE)*PADDING
NewerOlder

[8]ページ先頭

©2009-2025 Movatter.jp