Skip to content

Instantly share code, notes, and snippets.

View lmacken's full-sized avatar

Luke Macken lmacken

  • Colorado
View GitHub Profile
@lmacken
lmacken / lightning_invoice_watcher.py
Last active June 8, 2023 14:14
A simple pylightning invoice handler
import os
import json
import asyncio
import aioredis
from lightning import LightningRpc
LN_RPC_URI = os.path.expanduser("~/.lightning/lightning-rpc")
LN_RPC = LightningRpc(LN_RPC_URI)
@lmacken
lmacken / migrate-pass.py
Created June 5, 2016 06:00
Migrates a 'pass' setup to a different GPG key
#!/usr/bin/env python3
# Re-encrypt all pass files with a different GPG key
# 1) First, add your new key to ~/.password-store/.gpg-id
# 2) Run this script.
# 3) Confirm that things work
# 4) Remove the old backup keys with `find ~/.password-store -name '*.old' | xargs rm`
import os
import shutil
import subprocess
@lmacken
lmacken / fixsubmitters.py
Created August 24, 2015 01:42
A script to fix the update submitters bug with the bodhi1 -> bodhi2 migration.
#!/usr/bin/env python
import __main__
__requires__ = __main__.__requires__ = 'WebOb>=1.4.1'
import pkg_resources
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
@lmacken
lmacken / bodhi-signable.py
Created June 8, 2015 04:57
A script that prints out the packages that are ready to be signed
#!/usr/bin/python
"""
Print out a list of builds that need signing.
"""
__requires__ = 'bodhi'
import pkg_resources
import os
import sys
@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):
@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 / 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 / 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: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'])