Skip to content

Instantly share code, notes, and snippets.

View ralphbean's full-sized avatar

Ralph Bean ralphbean

  • Red Hat, Inc
  • Rochester, NY
View GitHub Profile
From 41647e16d5baa704a1dff71efa2bda47680f215d Mon Sep 17 00:00:00 2001
From: Ralph Bean <[email protected]>
Date: Fri, 15 Jun 2012 12:34:36 +0000
Subject: [PATCH 1/5] gitolite fedmsg hooks.
---
modules-staging/git/files/post-receive-chained | 5 ++
modules-staging/git/files/post-receive-fedmsg | 46 ++++++++++++++++++++
modules-staging/git/manifests/init.pp | 15 ++++++
.../gitolite/files/distgit/reestablish-git-hooks | 34 ++++++++++++++
_last_called = time.time()
def animate():
global r
global _last_called
now = time.time()
if now - _last_called > 2: # 2 is in seconds
# Remember when I was called last
_last_called = now
@ralphbean
ralphbean / insanity.py
Created June 25, 2012 19:15 — forked from rossdylan/insanity.py
Pure insanity in one line
(
lambda args: map(
lambda repo: __import__("os").system('git clone {0} {1}/{2}'.format(
repo.git_url,
args.backupdir,
repo.name)
),
__import__("pygithub3").Github().repos.list(args.username).all()
)
)(
@ralphbean
ralphbean / coder-shell.py
Created July 4, 2012 19:52
Having fun with coderwall
""" Run like: $ python coder-shell.py
First you need to: $ pip install coderwall requests fabulous
"""
from coderwall import CoderWall
import fabulous.image
import fabulous.text
import os
import requests
@ralphbean
ralphbean / reduced-list.py
Created July 11, 2012 19:25
Reduce a list of packages down to only the root packages.. no dependencies.
#!/usr/bin/env python
""" Use like:
cat list-of-packages.txt | ./reduced-list.py
You're going to need python-sh for this to work.
sudo yum -y install python-sh
"""
@ralphbean
ralphbean / monsters.py
Created July 12, 2012 18:50
You guys are monsters!
#!/usr/bin/env python
""" You guys are monsters! """
import fabulous.image
import tempfile
import urllib
import os
handle, filename = tempfile.mkstemp(suffix=".png")
urllib.urlretrieve(url="http://threebean.org/monsters.png", filename=filename)
@ralphbean
ralphbean / nagios-fedmsg.patch
Created August 5, 2012 16:01
Requires fedmsg-0.2.7 or greater.
diff --git a/modules/nagios/files/nagios/misccommands.cfg b/modules/nagios/files/nagios/misccommands.cfg
index 19ce5b8..18425e9 100644
--- a/modules/nagios/files/nagios/misccommands.cfg
+++ b/modules/nagios/files/nagios/misccommands.cfg
@@ -98,6 +98,12 @@ define command{
command_line /usr/local/bin/xmppsend -a /etc/nagios/private/xmppnagios.ini "Host '$HOSTALIAS$' is $HOSTSTATE$\nInfo: $HOSTOUTPUT$\nDate: $LONGDATETIME$" $CONTACTEMAIL$
}
+# 'notify-by-fedmsg' command definition
+define command{
#!/bin/bash
for repo in $(cat /srv/git/pkgs-git-repos-list); do
if [ ! -e /srv/git/rpms/$repo/hooks/post-receive ] ; then
echo $repo
fi
done
@ralphbean
ralphbean / topics_sub.py
Created August 23, 2012 19:50
Subscribe to a zmq PUB socket
#!/usr/bin/env python
"""Simple example of publish/subscribe illustrating topics.
Publisher and subscriber can be started in any order, though if publisher
starts first, any messages sent before subscriber starts are lost. More than
one subscriber can listen, and they can listen to different topics.
Topic filtering is done simply on the start of the string, e.g. listening to
's' will catch 'sports...' and 'stocks' while listening to 'w' is enough to
catch 'weather'.
@ralphbean
ralphbean / topics_pub.py
Created September 18, 2012 19:44
pub/sub zeromq testing utils
#!/usr/bin/env python
"""Simple example of publish/subscribe illustrating topics.
Publisher and subscriber can be started in any order, though if publisher
starts first, any messages sent before subscriber starts are lost. More than
one subscriber can listen, and they can listen to different topics.
Topic filtering is done simply on the start of the string, e.g. listening to
's' will catch 'sports...' and 'stocks' while listening to 'w' is enough to
catch 'weather'.