Skip to content

Instantly share code, notes, and snippets.

@xi
xi / dbusmenu.py
Last active November 3, 2023 18:00
dmenu wrapper around dbus menues
# dmenu wrapper around dbus menues
#
# Example Usage:
# python3 dbusmenu.py org.freedesktop.network-manager-applet /org/ayatana/NotificationItem/nm_applet/Menu
#
# https://github.com/tetzank/qmenu_hud/blob/master/com.canonical.dbusmenu.xml
import subprocess
import sys
import time
@xi
xi / cron.py
Created October 31, 2021 14:44
simple cron implementation with useful logging
import datetime
import logging
import subprocess
import sys
import time
MINUTE = datetime.timedelta(seconds=60)
logging.basicConfig(
stream=sys.stderr,
@xi
xi / Makefile
Created November 6, 2016 14:08
Build a Debian package that adds guest-account functionality to LightDM.
# Build a Debian package that adds guest-account functionality to LightDM.
#
# For guest accounts to work LightDM needs a binary "guest-account" which it
# will run to create / destroy guest accounts.[0] The default Debian package
# does not provide one.[1] However, the Ubuntu package does.[2]
#
# The simple way to use this script is simply to call `make install`. This will
# fetch the Ubuntu package, unpack it and install only the files that are
# relevant for guest accounts. However, this is strongly discouraged because
# it bypasses the package system.
@xi
xi / package.json
Last active September 12, 2018 13:14
Run multiple linters
{
"name": "polylint.sh",
"description": "Run multiple linters efficiently.",
"homepage": "https://gist.github.com/xi/63216e505a6d55562eaf695811c6fc9c",
"version": "0.0.4",
"os": ["darwin", "linux"],
"files": ["polylint.sh"],
"bin": {
"polylint": "./polylint.sh"
}
@xi
xi / leo.py
Last active February 9, 2018 14:12
#!/usr/bin/env python3
"""Get translations from leo.org on the command line."""
import argparse
import itertools
import collections
import xml.etree.ElementTree as ET
import requests
@xi
xi / contrast.scss
Created July 20, 2017 23:09
flexible contrast function inspired by css-color-4
// This implements a flexible contrast function similar to the one
// proposed in <https://github.com/w3c/csswg-drafts/issues/1627>.
//
// Note that it uses some approximations and RGB instead of HWB
// interpolation.
@function srgb($channel) {
$x: $channel / 255;
@if $x <= .03928 {
@return $x / 12.92;
@xi
xi / makepkg
Last active April 8, 2017 15:38
wrapper around checkinstall that supports a subset of arch linux' PKGBUILD format
#!/bin/bash -e
# This script is a wrapper around checkinstall that supports a subset of arch
# linux' PKGBUILD format. This means that it can be used to build debian
# packages from a single file.
#
# PKGBUILD files are written in bash and can define the following variables:
#
# - pkgname [required]
# - pkgver [required]
@xi
xi / SassMeister-input.scss
Created February 25, 2016 18:21
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// This provides some common mathemetical functions implemented in pure sass:
//
// - $PI
// - ln($x, $steps: 32)
// - pow($x, $exponent, $steps: 32)
// - sqrt($x, $exponent: 2, $steps: 32)