Skip to content

Instantly share code, notes, and snippets.

@plu5
plu5 / ntfs3gcr.py
Created February 11, 2025 12:17
NTFS-3G creation date of a file in Python
import subprocess
from datetime import datetime, timezone
def get_ntfs3g_file_creation_date(path):
# type: (str) -> str
c = subprocess.run([
'getfattr', '--only-values', '--name=system.ntfs_crtime', path
], capture_output=True)
# Convert getfattr output's little-endian bytes to int, and convert
@plu5
plu5 / toggle_kbd.sh
Created January 14, 2025 01:26
Linux X toggle keyboard script
#!/bin/bash
# use `xinput list` to check your keyboard name. this one is for laptop internal keyboard
deviceName="AT Translated Set 2"
builtInId=$(xinput list | grep "$deviceName" | sed 's/^.*id=//' | sed 's/\t.*//')
case $1 in
disable)
xinput disable $builtInId
echo "Keyboard '${deviceName}' disabled"
@plu5
plu5 / line_edit.py
Last active December 11, 2022 20:35
A widget for PyQt5; QPlainTextEdit subclass which mimics QLineEdit. | Adapted from ssokolow’s OneLineSpellTextEdit: https://gist.github.com/ssokolow/abb20a30415fa4debce912c38060ca6a
"""QPlainTextEdit subclass which mimics QLineEdit. The idea is to make it
hotswappable for QLineEdit with no changes needed, so that you can have a
QLineEdit without its inherent limitations, like not being able to modify the
undo behaviour, not being able to use QCursor, etc.
Adapted from ssokolows OneLineSpellTextEdit:
https://gist.github.com/ssokolow/abb20a30415fa4debce912c38060ca6a
NOTE:
* textEdited probably works differently from QLineEdits textEdited, because I
am not sure yet how to replicate it exactly. For now it emits when the text
@plu5
plu5 / thl-buddenbrooks.py
Created April 10, 2022 09:49
Reddit tally number of comments on a list of threads per user using PRAW [yet yet yet yet again]
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/thehemingwaylist/comments/rthfhy/buddenbrooks_chapter_1/",
"https://www.reddit.com/r/thehemingwaylist/comments/ru7p9c/buddenbrooks_chapter_2/",
"https://www.reddit.com/r/thehemingwaylist/comments/rv0o67/buddenbrooks_thomas_mann_chapter_3_discussion/",
"https://www.reddit.com/r/thehemingwaylist/comments/rvsc05/buddenbrooks_thomas_mann_chapter_4_discussion/",
"https://www.reddit.com/r/thehemingwaylist/comments/rwluwr/buddenbrooks_thomas_mann_chapter_5_discussion/",
"https://www.reddit.com/r/thehemingwaylist/comments/rxdycb/buddenbrooks_thomas_mann_chapter_6/",
@plu5
plu5 / yodq.py
Created December 22, 2021 01:18
Reddit tally number of comments on a list of threads per user using PRAW [yet yet yet again]
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/yearofdonquixote/comments/ko1iws/don_quixote_volume_1_chapter_1/",
"https://www.reddit.com/r/yearofdonquixote/comments/kp9k3b/don_quixote_volume_1_chapter_2/",
"https://www.reddit.com/r/yearofdonquixote/comments/kqm5jk/don_quixote_volume_1_chapter_3/",
"https://www.reddit.com/r/yearofdonquixote/comments/ks194a/don_quixote_volume_1_chapter_4/",
"https://www.reddit.com/r/yearofdonquixote/comments/ktfu6a/don_quixote_volume_1_chapter_5/",
"https://www.reddit.com/r/yearofdonquixote/comments/kur1nv/don_quixote_volume_1_chapter_6/",
@plu5
plu5 / yoak.py
Created December 21, 2021 21:27
Reddit tally number of comments on a list of threads per user using PRAW [yet yet again]
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/yearofannakarenina/comments/ko1iwm/anna_karenina_part_1_chapter_1/",
"https://www.reddit.com/r/yearofannakarenina/comments/kok3s8/anna_karenina_part_1_chapter_2/",
"https://www.reddit.com/r/yearofannakarenina/comments/kpv8vg/anna_karenina_part_1_chapter_3/",
"https://www.reddit.com/r/yearofannakarenina/comments/kr8xw6/anna_karenina_part_1_chapter_4/",
"https://www.reddit.com/r/yearofannakarenina/comments/kvg5vg/anna_karenina_part_1_chapter_5/",
"https://www.reddit.com/r/yearofannakarenina/comments/kw1u5d/anna_karenina_part_1_chapter_6/",
@plu5
plu5 / yopp.py
Created January 24, 2021 16:09
Reddit tally number of comments on a list of threads per user using PRAW [yet again]
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/Yogscast/comments/ete47v/did_you_hear_about_the_guy_who_ate_kevin_bacons/",
"https://www.reddit.com/r/Yogscast/comments/ews83c/did_you_hear_about_the_tortoise_that_had_800/",
"https://www.reddit.com/r/Yogscast/comments/f0e71c/nasa_says_this_10_plant_will_save_your_life/",
"https://www.reddit.com/r/Yogscast/comments/f3vz67/haunted_elsa_doll_returns_from_the_dead_twice/",
"https://www.reddit.com/r/Yogscast/comments/f7eydi/grandma_falls_from_7th_storey_window_and_survives/",
"https://www.reddit.com/r/Yogscast/comments/fayroa/uks_first_cheesethemed_hotel_opens_for_business/",
@plu5
plu5 / yomc.py
Created December 19, 2020 21:39
Reddit tally number of comments on a list of threads per user using PRAW [again]
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/AReadingOfMonteCristo/comments/eiazxw/chapter_1_reading_discussion_spoilers_up_to/",
"https://www.reddit.com/r/AReadingOfMonteCristo/comments/ejo9bh/chapter_2_reading_discussion_spoilers_up_to/",
"https://www.reddit.com/r/AReadingOfMonteCristo/comments/ekkjuq/chapter_3_reading_discussion_spoilers_up_to/",
"https://www.reddit.com/r/AReadingOfMonteCristo/comments/elk7ti/chapter_4_reading_discussion_spoilers_up_to/",
"https://www.reddit.com/r/AReadingOfMonteCristo/comments/emz5ol/chapter_5_reading_discussion_spoilers_up_to//",
"https://www.reddit.com/r/AReadingOfMonteCristo/comments/env31y/chapter_6_reading_discussion_spoilers_up_to/",
@plu5
plu5 / yolm.py
Created December 31, 2019 12:45
Reddit tally number of comments on a list of threads per user using PRAW
import praw
from collections import defaultdict
discussion_threads = \
["https://www.reddit.com/r/AYearOfLesMiserables/comments/abcufy/111_chapter_discussion_spoilers_up_to_111/",
"https://www.reddit.com/r/AYearOfLesMiserables/comments/abnlbx/112_chapter_discussion_spoilers_up_to_112/",
"https://www.reddit.com/r/AYearOfLesMiserables/comments/ac0a73/113_chapter_discussion_spoilers_up_to_113/",
"https://www.reddit.com/r/AYearOfLesMiserables/comments/acbssc/114_chapter_discussion_spoilers_up_to_114/",
"https://www.reddit.com/r/AYearOfLesMiserables/comments/acpdhv/115_chapter_discussion_spoilers_up_to_115/",
"https://www.reddit.com/r/AYearOfLesMiserables/comments/acy1xz/116_chapter_discussion_and_plot_summary_spoilers/",