Skip to content

Instantly share code, notes, and snippets.

View lkraider's full-sized avatar

Paul Eipper lkraider

View GitHub Profile
@lkraider
lkraider / photo-timestamps.py
Last active November 3, 2023 02:00
Synchronize the modified timestamps of files between a backup folder and a destination folder.
import os
from datetime import datetime
def sync_timestamps(backup_folder, destination_folder, dry_run=False):
# Loop through the files in the destination folder
for file_name in os.listdir(destination_folder):
destination_file_path = os.path.join(destination_folder, file_name)
destination_modified_time = os.path.getmtime(destination_file_path)
# Check if there is a corresponding file in the backup folder with the same name
# parsed report from: https://gist.github.com/lkraider/729223f16025c1ff6223536896465e36
# using online tool: http://eleccelerator.com/usbdescreqparser/
0x05, 0x86, // Usage Page (Power Pages)
0x09, 0x04, // Usage (0x04)
0xA1, 0x01, // Collection (Application)
0x05, 0x84, // Usage Page (Power Pages)
0x09, 0x1E, // Usage (0x1E)
0xA1, 0x00, // Collection (Physical)
0x85, 0x01, // Report ID (1)
0x09, 0x1F, // Usage (0x1F)
@lkraider
lkraider / spam_decode.py
Created June 14, 2020 21:25
X-OVH-SPAMCAUSE decoder
def decode(msg):
text = []
for i in range(0, len(msg), 2):
text.append(unrot(msg[i: i + 2]))
return str.join('', text)
def unrot(pair, key=ord('x')):
offset = 0
for c in 'cdefgh':
@lkraider
lkraider / nut-nsys-qx.log
Created January 8, 2020 20:45
nut NSYS E series - nutdrv_qx driver log
~# /lib/nut/nutdrv_qx -a nsys1 -DDDDD -x vendorid=0001
Network UPS Tools - Generic Q* USB/Serial driver 0.28 (2.7.4)
USB communication driver 0.33
0.000000 send_to_all: SETINFO driver.parameter.vendorid "0001"
0.000033 debug level is '5'
0.000975 upsdrv_initups...
0.014797 Checking device (1D6B/0003) (002/001)
0.030369 - VendorID: 1d6b
0.030398 - ProductID: 0003
0.030408 - Manufacturer: unknown
@lkraider
lkraider / nut-nsys-blazer.log
Last active January 8, 2020 20:36
nut NSYS E series - blazer driver log
~# /lib/nut/blazer_usb -a nsys1 -DDDDD -x vendorid=0001
Network UPS Tools - Megatec/Q1 protocol USB driver 0.12 (2.7.4)
0.000000 send_to_all: SETINFO driver.parameter.vendorid "0001"
0.000038 debug level is '5'
0.021080 Checking device (1D6B/0003) (002/001)
0.036745 - VendorID: 1d6b
0.036778 - ProductID: 0003
0.036819 - Manufacturer: unknown
0.036842 - Product: unknown
0.036856 - Serial Number: unknown
@lkraider
lkraider / nut-nsys-hid-explore.log
Last active January 8, 2020 20:38
nut NSYS E series HID explore
~# /lib/nut/usbhid-ups -a nsys1 -DDDDD -x vendorid=0001 -x explore
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
0.000000 send_to_all: SETINFO driver.parameter.vendorid "0001"
0.000042 send_to_all: SETINFO driver.flag.explore "enabled"
0.000061 debug level is '5'
0.001022 upsdrv_initups...
0.017350 Checking device (1D6B/0003) (002/001)
0.037392 - VendorID: 1d6b
0.037425 - ProductID: 0003

Keybase proof

I hereby claim:

  • I am lkraider on github.
  • I am lkraider (https://keybase.io/lkraider) on keybase.
  • I have a public key ASCtuhrH3CmFPAr8qYr8m8Q0gFEV8h9kXkKNBplfdp_LrAo

To claim this, I am signing this object:

@lkraider
lkraider / pbm_to_png.py
Created November 2, 2017 22:50
PPM to PBM to PNG
from PIL import Image
from io import BytesIO
import itertools
def as_pbm(w, h, data): # -> bytes
ret = bytes()
ret += b'P4\n'
ret += (str(w) + ' ' + str(h) + '\n').encode('ascii')
@lkraider
lkraider / How to link Sublime Text Build system to Python 3.md
Last active December 9, 2018 05:12 — forked from zaemiel/How to link Sublime Text Build system to Python 3
Parse python error message and display in overlay
@lkraider
lkraider / 1478-square-matrix-ii.py
Last active July 21, 2017 01:56
Square Matrix II
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# https://www.urionlinejudge.com.br/judge/pt/problems/view/1478
from sys import stdout
w = stdout.write
m = ''.join('%03s ' % l for l in range(100, 0, -1) + range(2, 101))
n = input('')
while n > 0:
nn = n * 4
for ss in xrange(396, 396 - nn, -4):