Skip to content

Instantly share code, notes, and snippets.

@hhsprings
hhsprings / chrometabopen.py
Last active May 3, 2021
more simple version chrome opener than "Tools/script/google.py" (It's just a sample script.)
View chrometabopen.py
# -*- coding: utf-8 -*-
import io
import sys
import os
import re
import json
import ctypes
__MYNAME__, _ = os.path.splitext(
@hhsprings
hhsprings / obs_compressedfilesize.py
Last active Apr 26, 2021
An example for ctypes.windll.kernel32.GetCompressedFileSizeW, ctypes.windll.kernel32.GetDiskFreeSpaceExW and curses
View obs_compressedfilesize.py
#! 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 / okcancel_or_timeout_dialog.py
Created Apr 18, 2021
Something like a kitchen timer (intended for a tkinter demo)
View okcancel_or_timeout_dialog.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import re
import time
import operator
@hhsprings
hhsprings / pscmdlines.py
Last active Apr 28, 2021
A simple example of Python's "psutil" package (with features such as kill, pause, resume)
View pscmdlines.py
# -*- 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 / dfviz_as_curses_example.py
Last active Apr 3, 2021
example for "psutil", and "curses"
View dfviz_as_curses_example.py
# -*- coding: utf-8 -*-
import sys
import time
from datetime import datetime
import curses
import psutil
class _Main(object):
def __init__(self):
@hhsprings
hhsprings / urls2htmlcal.py
Last active Apr 9, 2021
url list to html calendar
View urls2htmlcal.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
import io
import sys
import os
from collections import namedtuple
import locale as _locale
import calendar
@hhsprings
hhsprings / digitalclock_as_curses_example.py
Last active Apr 11, 2021
世界一おバカな curses サンプル。デジタル時計。要: pillow(, windows-curses)
View digitalclock_as_curses_example.py
# -*- 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 / globffprobe.py
Created Mar 26, 2021
nearly equals to "for i in * ; do ffpprobe -hide_banner $i ; done" with a few extra values
View globffprobe.py
# -*- 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 / disk_usage_graph.py
Last active Apr 16, 2021
visualize disk_usage (mainly for Windows)
View disk_usage_graph.py
# -*- 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 / video_to_x265.py
Last active Apr 28, 2021
shorthand of "ffmpeg ... -c:v libx265 ..."
View video_to_x265.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
import re
import subprocess
import shutil
import tempfile
import logging