Skip to content

Instantly share code, notes, and snippets.

@hhsprings
hhsprings / disk_usage_graph.py
Last active April 16, 2021 09:42
visualize disk_usage (mainly for Windows)
# -*- coding: utf-8 -*-
# require: python 3.x, pillow, matplotlib, psutil
import sys, os, io
import time
from datetime import datetime
import pickle
import tkinter
import tkinter.ttk as ttk
from tkinter import E, W, N, S
import multiprocessing
@hhsprings
hhsprings / globffprobe.py
Created March 26, 2021 13:37
nearly equals to "for i in * ; do ffpprobe -hide_banner $i ; done" with a few extra values
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import subprocess
if hasattr("", "decode"):
_encode = lambda s: s.encode(sys.getfilesystemencoding())
else:
@hhsprings
hhsprings / digitalclock_as_curses_example.py
Last active April 11, 2021 14:14
世界一おバカな curses サンプル。デジタル時計。要: pillow(, windows-curses)
# -*- coding: utf-8 -*-
import sys
import time
from datetime import datetime, timedelta
from PIL import Image, ImageDraw, ImageFont
import curses
class _Main(object):
def __init__(self, fontname, fontsize, beep_after):
@hhsprings
hhsprings / urls2htmlcal.py
Last active September 6, 2021 09:28
url list to html calendar
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
import io
import sys
import re
import os
import datetime
from collections import namedtuple
@hhsprings
hhsprings / dfviz_as_curses_example.py
Last active April 3, 2021 02:30
example for "psutil", and "curses"
# -*- coding: utf-8 -*-
import sys
import time
from datetime import datetime
import curses
import psutil
class _Main(object):
def __init__(self):
@hhsprings
hhsprings / pscmdlines.py
Last active April 9, 2022 23:57
A simple example of Python's "psutil" package (with features such as kill, pause, resume)
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import os
import sys
import pipes
import re
import psutil # pip install psutil
@hhsprings
hhsprings / okcancel_or_timeout_dialog.py
Last active March 18, 2022 09:06
Something like a kitchen timer (intended for a tkinter demo)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import re
import time
import operator
import functools
@hhsprings
hhsprings / obs_compressedfilesize.py
Last active April 26, 2021 11:15
An example for ctypes.windll.kernel32.GetCompressedFileSizeW, ctypes.windll.kernel32.GetDiskFreeSpaceExW and curses
#! py -3
# -*- coding: utf-8 -*-
import sys
import os
import time
import ctypes
import functools
from glob import glob
from fnmatch import fnmatch
from datetime import datetime
@hhsprings
hhsprings / chrometabopen.py
Last active May 3, 2021 05:23
more simple version chrome opener than "Tools/script/google.py" (It's just a sample script.)
# -*- coding: utf-8 -*-
import io
import sys
import os
import re
import json
import ctypes
__MYNAME__, _ = os.path.splitext(
@hhsprings
hhsprings / mpplgen.py
Last active March 13, 2022 12:26
minimal playlist generator (for Windows Media Player, MPC-HC, etc)
#! py -3
# -*- coding: utf-8 -*-
# required: python3, mako, dateutil
r"""
easiest usage:
$ python3 mpplgen.py out.m3u8 --from_askopenfilenames --postproc_simple_editor
from pattern:
$ python3 mpplgen.py out.m3u8 --from_pattern='[1-3]*.wav'