Skip to content

Instantly share code, notes, and snippets.

View lmacken's full-sized avatar

Luke Macken lmacken

  • Colorado
View GitHub Profile
@lmacken
lmacken / bench-tracker-miner.py
Created April 7, 2014 20:32
A script to benchmark GNOME Tracker overhead during an RPM transaction
# How much does tracker affect package installation?
#
# Average with tracker: 21.754451847076417
# Average without tracker: 21.509078884124754
import os
from timeit import Timer
cmd = 'sudo dnf reinstall -y kernel-3.13.8-200.fc20.x86_64.rpm'
t = Timer(stmt="os.system('%s')" % cmd, setup="import os")
@lmacken
lmacken / rehashmd.sh
Created March 28, 2014 05:42
rehash yum repo metadata
#!/bin/bash -x
# Re-hash yum repodata objects
# Pulls pieces of metadata out of the repodata and re-injects them, in order to
# use a different hash algorithm.
arch=x86_64
repo=/mnt/koji/mash/updates/el5-epel/$arch/repodata
cp -Rv $repo repodata
cp -R repodata repodata.$arch
@lmacken
lmacken / Wall-format-security-critpath-ftbfs.py
Last active December 29, 2015 09:39
Determine how many critical path packages failed to build from source using gcc -Werror=format-security
# Determine how many critical path packages failed to build from source using
# gcc -Werror=format-security. https://fedoraproject.org/wiki/Changes/FormatSecurity
import os
import subprocess
from collections import defaultdict
from fedora.client import PackageDB
pkgdb = PackageDB('https://admin.fedoraproject.org/pkgdb')
@lmacken
lmacken / reboot_suggested.py
Last active December 25, 2015 17:49
List which Fedora updates suggest that the user reboot after
import urllib
from BeautifulSoup import BeautifulSoup
from yum.update_md import UpdateMetadata
repos = {
'testing': 'http://dl.fedoraproject.org/pub/fedora/linux/updates/testing/20/x86_64/repodata/',
'stable': 'http://dl.fedoraproject.org/pub/fedora/linux/updates/20/x86_64/repodata/',
}
filename = 'updateinfo.xml.gz'
@lmacken
lmacken / check_updateinfo.py
Last active December 23, 2015 18:29
Download the updateinfo.xml from Fedora updates-testing and stable repos and check it for notices with duplicate update IDs.
# Download the updateinfo.xml from fedora stable & testing repos and check it
# for notices with duplicate update IDs.
import os
import urllib
from yum.update_md import UpdateMetadata
ver = 20
testing_url = 'http://dl.fedoraproject.org/pub/fedora/linux/updates/testing/%d/x86_64/repodata/updateinfo.xml.gz' % ver
@lmacken
lmacken / countdown.py
Last active March 29, 2022 11:45
A fullscreen countdown timer
#!/usr/bin/env python
# ----------------------------------------------------------------------------
# A fork of pyglet's timer.py by Luke Macken
#
# Copyright (c) 2006-2008 Alex Holkner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@lmacken
lmacken / fedmsg-sessions.py
Last active December 17, 2015 08:09
Count the number of current and maximum fedmsg zeromq connections
# A script to count the number of current and maximum fedmsg zeromq connections
# Author: Luke Macken <lmacken@redhat.com>
# License: GPLv3
import requests
from multiprocessing.pool import ThreadPool
from BeautifulSoup import BeautifulSoup
num_proxies = 8
@lmacken
lmacken / gist:5013514
Last active December 14, 2015 02:28
bzgrep apache logs for stuff and xz compress them over ssh to another box
bzgrep 'stuff' /var/log/hosts/app0[1-8]*/*/*/*/http/access_log.bz2 \
| cut -d':' -f2- \
| xz --compress --stdout -3 \
| ssh -c blowfish another_box \
"cat - > ~/log.xz"
@lmacken
lmacken / tempofinder.py
Created May 25, 2012 19:46
Add tempo metadata to your music collection. This script has been rewritten and turned into a new project: http://github.com/lmacken/tempi
# NOTE: I re-wrote this code and turned it into a real project:
# http://github.com/lmacken/tempi
# tempofinder - Add tempo metadata to your music
# ==============================================
# Sign up for an EchoNest API key: https://developer.echonest.com/docs
# sudo yum -y install python-virtualenv python-eyed3
# virtualenv env
# source env/bin/activate
# pip install pyechonest
@lmacken
lmacken / sshtail.py
Last active October 3, 2015 07:08
A script to tail a file across many systems at once
# sshtail.py
# A script to tail a file across many systems at once
# Author: Luke Macken <lmacken@redhat.com>
# License: GPLv3+
import getpass
import subprocess
servers = ['app1', 'app2', 'app3', 'app4', 'app5', 'app6', 'app7']
logfile = '/var/log/httpd/access_log'