Skip to content

Instantly share code, notes, and snippets.

@jonjensen
jonjensen / extract-har-hostnames.bash
Last active January 2, 2023 18:16
Script to extract hostnames from request URLs in HAR files from Firefox & Chrome
#!/bin/bash
set -e -u -o pipefail
# Include user's home directory bin/ to use locally-installed jq
PATH=~/bin:$PATH
for f in "$@"
do
echo "Unique hostnames found in request URLs in: $f"
@jonjensen
jonjensen / lame-histogram.txt
Created October 25, 2016 15:35
LAME MP3 encoding bitrate histogram
LAME 3.99.5 64bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 18671 Hz - 19205 Hz
Encoding 11 - Rialdo 'lascia ch'io Pianga.wav
to 11 - Rialdo 'lascia ch'io Pianga.mp3
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III VBR(q=2)
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA
11417/11417 (100%)| 0:06/ 0:06| 0:06/ 0:06| 48.768x| 0:00
32 [ 33] %
40 [ 1] %
48 [ 3] %
@jonjensen
jonjensen / decode-GECommonSettings
Created May 12, 2015 16:09
Decode Google Earth settings pseudo-URL Unicode
#!/bin/env python2
import fileinput
import re
import urllib
def decode_ucs(matchobj):
c = matchobj.group(0)[2:]
i = int(c, 16)
return unichr(i)
@jonjensen
jonjensen / convert-png-to-webp
Last active June 17, 2021 10:18
Batch convert PNG files to WebP in 1 directory
#!/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
# cd to the directory of the image so we can work with just filenames
dir="$(dirname "$1")"
cd "$dir" || exit 1
base="$(basename "$1" .png)"
# create a WebP version of the PNG
@jonjensen
jonjensen / rpmdb-compare
Created September 27, 2013 10:29
Script to compare installed RPMs between two servers using ssh and the rpm command.
#!/bin/sh
test -n "$TMPDIR" || TMPDIR=/tmp
tmpfilebase="$TMPDIR/rpmdb-compare.$$"
if test $# -ne 2
then
echo "Usage: $0 [user@]server1 [user@]server2" >&2
echo "Special name localhost means this server, without ssh" >&2
exit 1
@jonjensen
jonjensen / postgresql-9.2.4-RHEL5.spec-ep.diff
Last active December 17, 2015 10:29
Patch to adapt PGDG PostgreSQL 9.2.4 SRPM to build against End Point's local-perl for PL/Perl in https://packages.endpoint.com/ and without integer datetime so that it's compatible with pg_upgrade back to 8.3.
Patch against specfile of:
http://yum.pgrpms.org/srpms/9.2/redhat/rhel-5-x86_64/postgresql92-9.2.4-1PGDG.rhel5.src.rpm
--- postgresql-9.2.spec.orig 2013-04-01 23:10:41.000000000 +0000
+++ postgresql-9.2.spec 2013-05-16 21:22:23.000000000 +0000
@@ -57,7 +57,7 @@
%{!?pltcl:%define pltcl 1}
%{!?plperl:%define plperl 1}
%{!?ssl:%define ssl 1}
-%{!?intdatetimes:%define intdatetimes 1}
+%{!?intdatetimes:%define intdatetimes 0}
@jonjensen
jonjensen / collect-server-stats
Created November 17, 2012 02:38
Simple script to collect server statistics
#!/bin/bash
# sample command to purge collected stats older than 6 days in e.g. a crontab:
# find /var/tmp/stats -mindepth 1 -maxdepth 1 -type d -mtime +6 -print0 | xargs -r -0 rm -rf
trap "exit 1" INT
cd /var/tmp || exit 1
[ "`id -u`" = 0 ] || {
echo "This must be run as root to be very useful. Aborting." >&2
exit 1
@jonjensen
jonjensen / kill-large-processes.pl
Created August 30, 2012 20:52
Script to automatically kill large processes
#!/usr/local/bin/perl
use strict;
use warnings;
use Proc::ProcessTable;
my $table = Proc::ProcessTable->new;
for my $process (@{$table->table}) {
# skip root processes
@jonjensen
jonjensen / rhel6-ipv6-network
Created February 27, 2012 20:03
RHEL 6 IPv6 default source address
# Linux's default source address selection for multiple IPv6 addresses on the
# same interface leaves a lot to be desired. See:
# http://www.akkadia.org/drepper/linux-rfc3484.html
#
# The RFC 3484 method described there and used in gai.conf feels like the
# wrong way to me, so I used the approach documented here:
# http://www.davidc.net/networking/ipv6-source-address-selection-linux
# and mark all but the main IPv6 source address as "deprecated" so they
# won't be used as default source addresses (but otherwise function fine).
#
@jonjensen
jonjensen / data-tag-cache.patch
Created February 3, 2012 21:38
Interchange data tag cache
From pbg@web55.eppg.com Tue Apr 2 12:02:15 2002
Date: Fri, 22 Mar 2002 17:05:37 -0600
From: pbg <pbg@web55.eppg.com>
To: jon@redhat.com
Subject: diff
--- X Fri Mar 22 17:03:55 2002
+++ lib/Vend/Data.pm Fri Mar 22 17:03:00 2002
@@ -191,7 +191,9 @@
return '' unless defined $db->test_column($field_name);