Skip to content

Instantly share code, notes, and snippets.

@eliasp
eliasp / use-cases.md
Last active January 4, 2016 12:59
Describing some use-cases for hooks in Taskwarrior (task + taskd)

Use cases for hooks in task/taskd

General notes on hooks

While outlining the use-cases below, the following general requirements came up:

RC integration

Each hook should have its own configuration namespace which allows the hook to read its own RC values. Not only root-items should be allowed in the hooks RC, so hooks.hookname.some.thing could be used instead of hooks.hookname.some_thing.

diff -ruN scripts/test/HTMLUtils/LinkQuote.t.orig scripts/test/HTMLUtils/LinkQuote.t
--- scripts/test/HTMLUtils/LinkQuote.t.orig 2013-12-01 16:04:54.920957053 +0000
+++ scripts/test/HTMLUtils/LinkQuote.t 2013-12-01 16:07:08.909366227 +0000
@@ -300,6 +300,14 @@
Name => 'LinkQuote - just TLD given;',
Target => '',
},
+ {
+ Input =>
+ 'http://geizhals.de/?cat=prl&xf=720_LAN+10%2F100~1435_HP~2899_Farblaser~721_Duplexeinheit#xf_top',
@eliasp
eliasp / docker-volume-cleanup.py
Created November 30, 2013 16:11
A short python script to remove orphaned Docker volumes
#!/usr/bin/python
import json
import os
import shutil
import subprocess
import re
dockerdir = '/var/lib/docker'
volumesdir = os.path.join(dockerdir, 'volumes')
@eliasp
eliasp / salt#master.sls
Last active December 27, 2015 20:29
Saltmaster Dockerfiles
python-pip:
pkg.installed
docker-py:
pip.installed:
- require:
- pkg: python-pip
# TODO: ensure docker-py is declared a requirement for all dockerio states without having to explicitely declare the requirement in each container state again
@eliasp
eliasp / ldap.py
Last active December 25, 2015 11:19
# -*- coding: utf-8 -*-
'''
Provide authentication using simple LDAP binds
:depends: - ldap Python module
'''
# Import python libs
from __future__ import absolute_import
import logging
Facter.add(:macaddress) do
confine :kernel => 'Linux'
has_weight 10 # about an order of magnitude faster
setcode do
begin
result = nil
Dir.glob('/sys/class/net/*').each do |path|
mac = File.read(path + "/address").chomp
unless /^(?:00:)+00$|^\s*/.match(mac)
result = mac
diff --git a/spec/unit/macaddress_spec.rb b/spec/unit/macaddress_spec.rb
index 638ef2a..8bc26b1 100755
--- a/spec/unit/macaddress_spec.rb
+++ b/spec/unit/macaddress_spec.rb
@@ -49,6 +49,15 @@ describe "macaddress fact" do
proc { Facter.value(:macaddress) }.should_not raise_error
Facter.value(:macaddress).should be_nil
end
+
+ # when ifconfig isn't installed, nil is returned which should be handled gracefully without any