Skip to content

Instantly share code, notes, and snippets.

View vdcrim's full-sized avatar

Diego Fernández Gosende vdcrim

View GitHub Profile
@vdcrim
vdcrim / ddc-ci.py
Created February 11, 2015 00:35
Python script for adjusting the settings of my monitor, by using DDC/CI
#!/usr/bin/env python3
"""
Show and adjust display parameters on an Iiyama ProLite XB2483HSU-B1 monitor
Requirements:
- mentioned monitor (27' should also work) with DDC/CI setting on
- Windows Vista+
- Python 3
@vdcrim
vdcrim / optimize_images.py
Created October 24, 2014 15:36
Optimize image files
#!/usr/bin/env python3
"""
Optimize image files
- Convert losslessly compressed files to PNG
- Optimize PNG and JPEG compression
- Optionally, convert PNG to JPEG when it would result in an
output/input size ratio below a given value
- Optionally, recompress JPEG files above a given quality level
@vdcrim
vdcrim / sync_tree_timestamps.py
Created October 24, 2014 15:29
Update the timestamps of a directory tree with the ones from a different tree
#!/usr/bin/env python3
"""
Update the timestamps of a directory tree with the ones from a different
tree. Optionally timestamps can be changed only for directories or for
files, or only when they are older or newer.
Requeriments:
- python 3.3+
- pywin32 (Windows, to sync also creation date, optional)
@vdcrim
vdcrim / Encode selected text as UTF-8.py
Created February 8, 2014 03:40
For AvsPmod posterior to v2.5.1 + ffms2 + utf8
import sys
sys_encoding = sys.getfilesystemencoding()
if sys_encoding != 'utf8':
text = avsp.GetSelectedText()
if text:
text = text.encode('utf8').decode(sys_encoding)
avsp.InsertText(text, pos=None)
@vdcrim
vdcrim / unread count.py
Last active December 21, 2015 00:39
Python script for HexChat 2.9.6+ that sets the program's title to the last channel with activity and its unread count
"""Show last channel with activity and its unread count as the program's title
- Requires HexChat 2.9.6+
- Only thought for single window
Copyright (C) 2013, 2014 Diego Fernández Gosende (dfgosende [at] gmail [dot] com)
GPL v2 or later <http://www.gnu.org/licenses/gpl-2.0.html>
"""
# activity in the following channels is ignored
@vdcrim
vdcrim / python 2.7 bindings for vapoursynth C API.py
Last active December 19, 2015 03:39
Incomplete and not very well thought out Python 2.7 bindings for the VapourSynth C API, just for playing around
# coding: utf8
# Python 2.7 bindings for the VapourSynth C API
# last updated: VapourSynth R19
from __future__ import print_function
import sys
import os
import os.path
from collections import Iterable
import subprocess
@vdcrim
vdcrim / mkv_suid_duration.py
Last active December 12, 2015 09:18
Parse SegmentUID and Duration on Matroska files, for ordered chapters
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Parse SegmentUID and Duration on Matroska files, for ordered chapters
Usage (Python 2 or 3):
$python mkv_suid_duration.py file1 [file2...]
$python mkv_suid_duration.py directory
Copyright (C) 2013 Diego Fernández Gosende (dfgosende [at] gmail [dot] com)