Skip to content

Instantly share code, notes, and snippets.

View blueyed's full-sized avatar
💭
❤️ not eating nor abusing animals 🍀

Daniel Hahler blueyed

💭
❤️ not eating nor abusing animals 🍀
View GitHub Profile
@blueyed
blueyed / xterm-bg.sh
Last active March 19, 2024 01:02
Query background setting from terminal (xterm / rxvt-unicode)
#!/bin/sh
#
# Query a property from the terminal, e.g. background color.
#
# XTerm Operating System Commands
# "ESC ] Ps;Pt ST"
oldstty=$(stty -g)
# What to query?
@blueyed
blueyed / _tmux_pane_words.zsh
Last active May 26, 2023 07:39
ZSH configuration to complete words from tmux pane(s)
# Complete words from tmux pane(s) {{{1
# Source: http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
# Gist: https://gist.github.com/blueyed/6856354
_tmux_pane_words() {
local expl
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
@blueyed
blueyed / _pip.zsh
Last active February 6, 2023 00:53
Zsh completion for pip (a tool for installing and managing Python packages), to be added to Zsh soonish.
#compdef -P pip[0-9.]#
#
# Completion script for pip (http://pypi.python.org/pypi/pip).
#
# Taken from https://github.com/zsh-users/zsh-completions/commit/890f3701
# (where it got removed). Original source:
# https://github.com/technolize/zsh-completion-funcs.
#
# Currently maintained in https://gist.github.com/blueyed/54a257c411310a28805a.
-- Do not grab global / client keys when the xev event tester window is focused.
do
local saved = {}
function xev_globalkeys_focus(c)
if c.name == 'Event Tester' then
saved.root, saved.client = root.keys(), c.keys
root.keys({})
-- Only map alt-f4.
c.keys = {awful.key({ "Mod1", }, "F4", function (c) c:kill() end)}
end
@blueyed
blueyed / test_django_data_migration.py
Last active December 9, 2020 16:20
Test Django data migrations
"""
Test (data) migrations in Django.
This uses py.test/pytest-django (the `transactional_db` fixture comes from there),
but could be easily adopted for Django's testrunner:
from django.test.testcases import TransactionTestCase
class FooTestcase(TransactionTestCase):
def test_with_django(self):
client.connect_signal("manage", function (c)
-- Enable sloppy focus
local sloppy_focus_last_coords = mouse.coords()
c:connect_signal("mouse::enter", function(c)
-- bnote("mouse::enter::focus", 2)
local coords = mouse.coords()
local last = sloppy_focus_last_coords
-- bnote("coords: " .. coords.x .. "/" .. coords.y )
-- bnote("last : " .. last.x .. "/" .. last.y )
if coords.x == last.x and coords.y == last.y then
@blueyed
blueyed / awesome-rename-tag.rc.lua
Last active November 6, 2019 13:46
awesomeWM: rename the current tag
-- Rename tag
awful.key({ modkey, "Shift", }, "F2", function ()
awful.prompt.run({ prompt = "Rename tab: ", text = awful.tag.selected().name, },
mypromptbox[mouse.screen].widget,
function (s)
awful.tag.selected().name = s
end)
end),
@blueyed
blueyed / Puppet config snippet to define a Launchpad PPA
Created February 25, 2011 23:48
This defines pparepo which allows to add a PPA (Personal Package Archive) repository from Launchpad to a client. It uses apt::key, which I have taken (and maybe modified) from http://projects.puppetlabs.com/projects/1/wiki/Apt_Keys_Patterns (blog post at
# Setup a PPA repo, where the name is "user/ppaname", e.g. "blueyed/ppa" ("ppa" being the default)
define pparepo($apt_key = "", $dist = $ppa_default_name, $supported = ["lucid", "hardy"], $ensure = present, $keyserver = "keyserver.ubuntu.com") {
$name_for_file = regsubst($name, '/', '-', 'G')
$file = "/etc/apt/sources.list.d/pparepo-${name_for_file}.list"
file { "$file": }
case $ensure {
present: {
if ($dist) and ($dist in $supported) {
File["$file"] {
#!/bin/bash
# script for pyenv installation of pygtk3 in ubuntu 12.04
# Adapted from https://gist.github.com/mehcode/6172694
system_package_installed() {
if ! dpkg -l | grep -q $1; then
sudo apt-get install $1
fi
}
# Awesome window manager framework version 4.0 changes
Awesome 4.0 is the first release of the v4 API level, breaking the proven
v3.5 API level after 4 years. This requires to port existing user
configuration and extensions to the new API.
This document offer an overview of the new features and required changes for
existing users.
## New features