Skip to content

Instantly share code, notes, and snippets.

View zoni's full-sized avatar

Nick Groenen zoni

View GitHub Profile
@zoni
zoni / run-or-raise
Created July 28, 2012 16:24
Run application or switch to it if already active
#!/bin/sh
if [ -z "$2" ]
then
wmctrl -x -a "$1" || exec $1 &
else
wmctrl -x -a "$1" || exec $2 &
fi
@zoni
zoni / asciionly.py
Created August 18, 2012 18:32
asciionly
def asciionly(input):
"""Return only us-ascii characters from input string"""
return ''.join([x for x in input if ord(x) < 128])
@zoni
zoni / quotewrap.py
Created October 3, 2012 15:09
quotewrap - Word-wrap or apply quotation marks to input. Accepts either data on stdin or a list of filenames to read.
#!/usr/bin/env python
"""quotewrap
Word-wrap or apply quotation marks to input
Accepts either data on stdin or a list of filenames to read
Released into public domain, originally written by Nick Groenen <zoni@zoni.nl>
"""
@zoni
zoni / template.imaprc
Created October 16, 2012 09:25
offlineimap template to backup GMail
[general]
accounts = Gmail
maxsyncaccounts = 3
[Account Gmail]
localrepository = Local
remoterepository = Remote
[Repository Local]
type = Maildir
@zoni
zoni / tweak.sh
Created November 5, 2012 19:10
Make gnome-shell more usable
#/bin/sh
# Turn on debugging, makes it clearer what is happening
set -x
# I don't want the overlay bound to Super_L, it messes with other shortcuts
gsettings set org.gnome.mutter overlay-key ''
# That huge 24-pixel notification area sucks. Whoever thought that was a good idea....
sudo sed -i -e 's/SOURCE_ICON_SIZE:\ 48,/SOURCE_ICON_SIZE:\ 24,/g' /usr/share/gnome-shell/js/ui/messageTray.js
@zoni
zoni / test_commands.py
Last active December 10, 2015 13:58
err-skeleton unittests attempt
from errbot.backends.test import *
from os.path import dirname, abspath
pluginpath = dirname(abspath(__file__)) + "/../"
class TestCommands(FullStackTest):
def setUp(self):
from errbot import holder
holder.plugin_manager.updatePluginPlaces([pluginpath])
@zoni
zoni / 2and3.pp
Last active December 14, 2015 19:19
Install Err using Puppet
Exec { path => '/usr/bin:/bin:/usr/sbin:/sbin' }
package { "git":
ensure => present,
}
vcsrepo { "/usr/share/err/repo":
ensure => latest,
provider => git,
source => "git://github.com/gbin/err.git",
@zoni
zoni / jekyll_version.rb
Last active December 15, 2015 08:38
A Jekyll plugin to expose a `jekyll_version` Liquid template tag which returns the Jekyll version number
module Jekyll
class JekyllVersionTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
Jekyll::VERSION
@zoni
zoni / requirements.txt
Last active March 7, 2019 00:04
Example Python WSGI app which displays the hostname of the system it runs on when accessing /hostname
flask
@zoni
zoni / iptables
Created November 26, 2013 09:20
Ansible module to manage iptables rules
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Ansible module to manage iptables rules
Written by Nick Groenen <zoni@zoni.nl>. If you get your hands on a
copy of this code, please feel free to do with it whatever you like.
"""