Skip to content

Instantly share code, notes, and snippets.

@dperelman
dperelman / x11_watch_active_window.py
Last active January 9, 2024 16:16 — forked from ssokolow/x11_watch_active_window.py
python-xlib example which reacts to changing the active window
#!/usr/bin/env python3
# Based on code by Stephan Sokolow
# MIT-licensed
# Source: https://gist.github.com/ssokolow/e7c9aae63fb7973e4d64cff969a78ae8
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
#!/usr/bin/env python
# pkg-config --variable=xcbincludedir xcb-proto
import six
import re
import sys
from collections import namedtuple
def err(*args):
sys.stderr.write(' '.join(str(a) for a in args) + '\n')
@dperelman
dperelman / SansBullshitSans.ttx
Created April 3, 2015 20:35
SansBullshitSans.ttx file generated by ttx with behdad/fonttools master from official SansBullshitSans.ttf
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="2.5">
<GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
<GlyphID id="0" name=".notdef"/>
<GlyphID id="1" name=".null"/>
<GlyphID id="2" name="nonmarkingreturn"/>
<GlyphID id="3" name="space"/>
<GlyphID id="4" name="exclam"/>
@dperelman
dperelman / SansBullshitSans.ttx
Created April 3, 2015 20:17
SansBullshitSans.ttx file generated by ttx on Ubuntu with fonttools 2.4-1 from official SansBullshitSans.ttf
<?xml version="1.0" encoding="ISO-8859-1"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="2.4">
<GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
<GlyphID id="0" name=".notdef"/>
<GlyphID id="1" name=".null"/>
<GlyphID id="2" name="nonmarkingreturn"/>
<GlyphID id="3" name="space"/>
<GlyphID id="4" name="exclam"/>
@dperelman
dperelman / ligature_xml_to_list.py
Created March 21, 2015 00:54
List ligatures in .ttx file.
#!/usr/bin/env python
# This takes in just the ligatures section of a .ttx file:
# USAGE: sed -n '/<LigatureSubst /,/<\/LigatureSubst>/p' FOO.ttx \
# | ./ligature_xml_to_list.py
from __future__ import print_function
import lxml.etree
import sys
#!/usr/bin/env python
from __future__ import print_function
import collections
import fileinput
import sys
plop = collections.defaultdict(list)
@dperelman
dperelman / blend.sh
Created March 8, 2015 10:40
Create simple slideshow video with blend effect between images.
#!/bin/sh
# Need at least an outfile and two images for this command to make sense.
if [ $# -lt 3 ]
then
echo USAGE: "$0" OUTFILE IMAGES...
echo Create simple slideshow video with blend effect between images.
echo
echo OUTFILE is video file to create, .mkv extension is recommended.
echo IMAGES is a sequence of images for the slideshow.
@dperelman
dperelman / htoprc
Created March 5, 2015 04:29
My configuration for htop. Goes in ~/.config/htop/htoprc
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=47
sort_direction=1
hide_threads=0
hide_kernel_threads=0
hide_userland_threads=0
shadow_other_users=1
show_thread_names=0
@dperelman
dperelman / download_podcast.py
Last active January 27, 2020 02:10
Download all items in a podcast.
#!/usr/bin/env python
from __future__ import print_function
import datetime
import feedparser
import time
import os
import sys
from six.moves import urllib
@dperelman
dperelman / ssh-reclaim
Last active August 29, 2015 14:15
Share an ssh-agent session among multiple shells on the same computer.
#!/bin/sh
# $Id$
#
# Limitations: if $ssh_auth_sock exists and an ssh-agent is running
# which doesn't use it, ssh-reclaim will be tricked into thinking
# that they correspond. This will happen if the computer shuts down
# uncleanly.
#
# Possible workarounds:
# * Check the command line of ssh-agent to see if we started it