Skip to content

Instantly share code, notes, and snippets.

View lmacken's full-sized avatar

Luke Macken lmacken

  • Colorado
View GitHub Profile
@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 / 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 / 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 / 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 / gist:26520f6b9e1651dde231
Created May 16, 2014 21:12
Calculate the percentage of Fedora accounts that have package commit privileges
# Calculate the percentage of Fedora accounts that have package commit privileges
import os
import getpass
import pkgdb2client
from fedora.client import AccountSystem
pkgdb = pkgdb2client.PkgDB()
num_packagers = len(pkgdb.get_packagers('*')['packagers'])
@lmacken
lmacken / keybase.md
Last active May 16, 2016 00:01
keybase.md

Keybase proof

I hereby claim:

  • I am lmacken on github.
  • I am lmacken (https://keybase.io/lmacken) on keybase.
  • I have a public key whose fingerprint is A89B D347 9921 19D2 6B6B 2F8A 1471 8698 9DFC 42B5

To claim this, I am signing this object:

@lmacken
lmacken / gist:f38389869e69d511a0b7
Last active August 29, 2015 14:08
Benchmarks the fastest way to pull 'rawhide' out of 'atomic-compose-rawhide.service' in Python
#!/bin/sh -x
# 1000000 loops, best of 3: 1.29 usec per loop
python3 -m timeit --setup "import re" "re.match(r'atomic-compose-(.*)\.service', 'atomic-compose-rawhide.service').groups()[0]"
# 1000000 loops, best of 3: 0.807 usec per loop
python3 -m timeit --setup "import re; r = re.compile(r'atomic-compose-(.*)\.service')" "r.match('atomic-compose-rawhide.service').groups()[0]"
# 1000000 loops, best of 3: 0.575 usec per loop
python3 -m timeit "'atomic-compose-rawhide.service'.split('.')[0].split('-')[-1]"
@lmacken
lmacken / journalmon.py
Created January 9, 2015 15:51
Monitoring the systemd journal with Twisted
from systemd import journal
from twisted.internet import reactor
UNITS = ['suricata.service']
class JournalMonitor(object):
def __init__(self):
self.journal = journal.Reader()
@lmacken
lmacken / journalmon.py
Created January 9, 2015 15:51
Monitoring the systemd journal with Twisted
from systemd import journal
from twisted.internet import reactor
UNITS = ['suricata.service']
class JournalMonitor(object):
def __init__(self):
self.journal = journal.Reader()
@lmacken
lmacken / fedorahosted-active.py
Last active August 29, 2015 14:21
Analyze the activity of Fedora Hosted projects over a period of time.
import operator
import feedparser
import multiprocessing.pool
DAYS_BACK = 498 # 2014-1-1 -> 2015-05-14 https://daycalc.appspot.com/01/01/2015
RSS = 'https://fedorahosted.org/{}/timeline?ticket=on&changeset=on&milestone=on&wiki=on&max=50&format=rss&daysback={}&authors='
active_projects = {}
def handle(project):