Merge branch 'master' of waschsauger.bl0rg.net:dirty-helpers
commit
ff88888282
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# List XXXs, FIXMEs and TODOs in files
|
||||
ag '^(?!.*mktemp).*XXX|FIXME|TODO' "$@"
|
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python3
|
||||
# Convert an image to CSS/HTML base64 foo
|
||||
|
||||
from __future__ import division, print_function
|
||||
import base64
|
||||
import magic
|
||||
import sys
|
||||
|
||||
if not hasattr(magic, "from_file"):
|
||||
print("wrong magic module installed? try pip install python-magic")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if len(sys.argv[1:]) == 0:
|
||||
print("Usage: " + sys.argv[0] + " IMAGE.PNG ...")
|
||||
sys.exit(1)
|
||||
|
||||
for filename in sys.argv[1:]:
|
||||
mimetype = magic.from_file(filename, mime=True)
|
||||
with open(filename, "rb") as f:
|
||||
encoded = base64.b64encode(f.read())
|
||||
print("url(data:{};base64,{})".format(mimetype, encoded))
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python2
|
||||
# Check Java versions against the newest one installed
|
||||
#
|
||||
# This assumes that there's OpenJDK installed and kept up to date.
|
||||
|
||||
from __future__ import division, print_function
|
||||
from distutils.version import LooseVersion
|
||||
from subprocess import check_output
|
||||
import re
|
||||
|
||||
|
||||
def is_java(package):
|
||||
filelist = check_output(['rpm', '-ql', package])
|
||||
return re.search(r'bin/java$', filelist, re.MULTILINE)
|
||||
|
||||
|
||||
def package_version(package):
|
||||
version_query = ['rpm', '--queryformat', '%{VERSION}', '-q']
|
||||
version_query.append(package)
|
||||
|
||||
version = check_output(version_query)
|
||||
|
||||
version = re.sub('_', '.', version)
|
||||
return version
|
||||
|
||||
|
||||
def java_packages():
|
||||
all_packages = check_output(['rpm', '-qa']).split('\n')
|
||||
packages = [package
|
||||
for package in all_packages
|
||||
if re.search(r'jdk|jre', package)]
|
||||
return [package for package in packages if is_java(package)]
|
||||
|
||||
|
||||
versions = [LooseVersion(package_version(package))
|
||||
for package in java_packages()]
|
||||
wanted_version = max(versions)
|
||||
old_versions = [version for version in versions if version < wanted_version]
|
||||
|
||||
print('Too old:', old_versions)
|
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# list all redhat/networkmanager connections without ipv6 privacy
|
||||
set -e
|
||||
cd /etc/sysconfig/network-scripts
|
||||
for c in ifcfg-*; do
|
||||
if [ "$c" == "ifcfg-lo" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! grep -q IPV6_PRIVACY=rfc3041 $c; then
|
||||
echo $c
|
||||
fi
|
||||
done
|
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# Discover DBUS session bus
|
||||
# Source: can't remember where this from...
|
||||
|
||||
# Remember to run this script using the command "source ./filename.sh"
|
||||
|
||||
# Search these processes for the session variable
|
||||
# (they are run as the current user and have the DBUS session variable set)
|
||||
compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd )
|
||||
|
||||
# Attempt to get a program pid
|
||||
for index in ${compatiblePrograms[@]}; do
|
||||
PID=$(pidof -s ${index})
|
||||
if [[ "${PID}" != "" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "${PID}" == "" ]]; then
|
||||
echo "Could not detect active login session"
|
||||
return 1
|
||||
fi
|
||||
|
||||
QUERY_ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
|
||||
if [[ "${QUERY_ENVIRON}" != "" ]]; then
|
||||
export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}"
|
||||
echo "Connected to session:"
|
||||
echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
|
||||
else
|
||||
echo "Could not find dbus session ID in user environment."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Fix wrong "Flash outdated" error message by Firefox
|
||||
killall firefox
|
||||
rm .mozilla/firefox/*.default/pluginreg.dat
|
||||
rm .mozilla/firefox/*.default*/pluginreg.dat
|
||||
firefox
|
||||
|
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
# Restart all running libvirt domains
|
||||
|
||||
from __future__ import division, print_function
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
|
||||
conn = libvirt.open('qemu:///system')
|
||||
if not conn:
|
||||
print('Failed to open connection to the hypervisor!')
|
||||
sys.exit(1)
|
||||
|
||||
for domain in conn.listAllDomains():
|
||||
name = domain.name()
|
||||
if domain.isActive():
|
||||
print('Restarting {}...'.format(name))
|
||||
domain.destroyFlags(flags=libvirt.VIR_DOMAIN_DESTROY_GRACEFUL)
|
||||
domain.create()
|
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# List Firefox bookmarks
|
||||
places=~/.mozilla/firefox/*default*/places.sqlite
|
||||
|
||||
# tags are parents with their parent = 4, so these have to be filtered
|
||||
sqlite3 $places "select pl.url, b.title from moz_bookmarks as b join moz_bookmarks as pa on b.parent=pa.id join moz_places as pl on b.fk=pl.id where pa.parent != 4"
|
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# check for common problems + junk
|
||||
|
||||
echo "== Dangling symlinks in /etc"
|
||||
symlinks -r /etc | grep ^dangling | egrep -v 'blkid.tab|/var/log/dropbear'
|
||||
|
||||
echo "== Trashes"
|
||||
du -s /home/*/.local/share/Trash | awk '{ if ($1 > 100000) { print } }'
|
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# check for things not installed via dpkg/apt and other junk
|
||||
|
||||
saubermann-common
|
||||
|
||||
echo "== Packages not in installed state"
|
||||
dpkg -l | egrep -v "^(ii|Desired|\||\+)"
|
||||
|
||||
echo "== Orphan packages"
|
||||
deborphan | egrep -v 'libc6-i686|lib.*-ruby$|opensync|gstreamer0.10-plugins.*|libtime-modules-perl|vpim|gnome-session-fallback|.*-globalmenu|gcalctool|clive|unity-scope'
|
||||
|
||||
echo "== *.dpkg in /etc"
|
||||
find /etc -name "*.dpkg-*" -or -name "*.ucf-*"
|
||||
|
||||
echo "== Orphan packages according to aptitude"
|
||||
aptitude search "~o"
|
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# check for things not installed via RPM and other junk
|
||||
|
||||
saubermann-common
|
||||
|
||||
echo "== should be installed via RPM or pip install --user:"
|
||||
for site_packages in /usr/lib/python2.7/site-packages/; do
|
||||
rpm -qf $site_packages/*.egg-info 2>&1 | grep "not owned"
|
||||
done
|
||||
|
||||
echo "== /usr/local"
|
||||
find /usr/local/ -type f \
|
||||
-and -not -name mimeinfo.cache \
|
||||
-and -not -name defaults.list \
|
||||
-print0 | xargs -0 rpm -qf 2>&1 | grep "not owned"
|
||||
|
||||
echo "== /usr/bin etc."
|
||||
find /usr/bin /usr/sbin /usr/lib -type f \
|
||||
\( \
|
||||
-path '/usr/lib/modules/*/modules.*' -prune \
|
||||
-or -path '*/__pycache__/*.py?' -prune \
|
||||
-or -print0 \
|
||||
\) | xargs -0 rpm -qf 2>&1 | grep "not owned"
|
||||
|
||||
echo "== *.rpmnew etc."
|
||||
find /etc/ /usr/ \
|
||||
-path '/usr/share/eclipse/dropins' -prune \
|
||||
-or -name "*.rpm*" -and -not -name "*.rpm"
|
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
"""Find files starting with null bytes"""
|
||||
|
||||
from __future__ import division, print_function
|
||||
import argparse
|
||||
import os
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Find files starting with null bytes')
|
||||
parser.add_argument(
|
||||
'directories', metavar='dir', default=['.'], nargs='*',
|
||||
type=str, help='directory to be searched')
|
||||
parser.add_argument(
|
||||
'-n', dest='nullbytes', default=16,
|
||||
type=int, help='number of null bytes')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
for directory in args.directories:
|
||||
for dirpath, _, filenames in os.walk(directory):
|
||||
for filename in filenames:
|
||||
filename = os.path.join(dirpath, filename)
|
||||
|
||||
if not os.path.isfile(filename):
|
||||
continue
|
||||
|
||||
with open(filename, 'rb') as f:
|
||||
firstbytes = f.read(args.nullbytes)
|
||||
if firstbytes == b'\0'*args.nullbytes:
|
||||
print(filename)
|
Loading…
Reference in New Issue