Skip to content

Instantly share code, notes, and snippets.

View cronnelly's full-sized avatar

Michael Cronnelly cronnelly

View GitHub Profile
@cronnelly
cronnelly / image-analyse
Created October 23, 2012 19:30
Find PNGs which should be re-encoded to JPG
find . -type f -iname "*.png" -print0 | while read -d $'\0' fn; do os=$(stat -c%s "$fn"); js=$(gm convert -quality 80 "$fn" jpg:- | wc -c); ratio=$(echo "scale=3; ($js * 100) / $os" | bc); echo "$ratio% $js $os $fn"; done | sort -n
@cronnelly
cronnelly / screen_serve.sh
Created October 25, 2012 13:32
Serve X display snapshot over HTTP
#!/bin/bash
# Call from inet with this config:
# www stream tcp nowait node /usr/local/bin/screen_serve.sh
export XAUTHORITY=/home/node/.Xauthority
export DISPLAY=:0
filename="/tmp/screen-"$(uuidgen)".jpg"
for i in `seq 100`; do
@cronnelly
cronnelly / zram
Created November 25, 2012 14:42
A munin plugin to graph zram usage
#!/bin/bash
# -*- sh -*-
: << =cut
=head1 NAME
zram - Plugin to monitor zram usage
=head1 CONFIGURATION
@cronnelly
cronnelly / multi-tail-filter.sh
Created March 30, 2013 19:00
Tail and filter log files on multiple SSH hosts.
for i in $(seq 2); do ssh -A sl-shortlist-0$i "tail -f /var/log/apache2/other_vhosts_access.log | cut -f 4,5,6,7,8,13 | awk -F'=' '{if (\$NF > 500000) print \"$i:\", \$0; fflush()}'" & true; done | cat
@cronnelly
cronnelly / node-upstart-template.conf
Last active December 17, 2015 17:09
Template Upstart script for Clock's Node.js applications, using nave.
author "Michael Cronnelly"
env NODE_ENV=testing
env NODE_START=/var/application/<site>/server.js
env NODE_VERSION=0.10.7
env PORT=3310
setuid node
env HOME=/home/node
# Fix PuTTY's bad ACS handling in Unicode
set-option -ga terminal-overrides ',*:enacs@:smacs@:rmacs@:acsc@'
# Start from 1
set -g pane-base-index 1
set -g base-index 1
# Colours
set-option -g default-terminal screen-256color
@cronnelly
cronnelly / gist:8382688
Created January 12, 2014 09:39
A crude test for UDP packet loss, with bash and netcat
# On server:
COUNT=0; while true; do nc -ulw0 1234 > /dev/null; echo $((++COUNT)); done
# On client:
for i in $(seq 6000); do echo "hello" >/dev/udp/<server>/1234; sleep 0.1; done
qemu-kvm (1.0+noroms-0ubuntu14.13) precise-security; urgency=medium
* SECURITY UPDATE: privilege escalation via REPORT LUNS
- debian/patches/CVE-2013-4344.patch: support more than 256 LUNS in
hw/scsi-bus.c, hw/scsi.h.
- CVE-2013-4344
-- Marc Deslauriers <[email protected]> Tue, 28 Jan 2014 09:08:09 -0500
qemu-kvm (1.0+noroms-0ubuntu14.12) precise-proposed; urgency=low
@cronnelly
cronnelly / gist:9862978
Created March 29, 2014 21:04
anthracite error
Traceback (most recent call last):
File "/home/anthracite/anthracite/bottle.py", line 763, in _handle
return route.call(**args)
File "/home/anthracite/anthracite/bottle.py", line 1622, in wrapper
rv = callback(*a, **ka)
File "/home/anthracite/anthracite/bottle.py", line 1572, in wrapper
rv = callback(*a, **ka)
File "./anthracite-web.py", line 123, in events_timeline
(range_low, range_high) = backend.get_events_range()
File "/home/anthracite/anthracite/backend.py", line 272, in get_events_range
@cronnelly
cronnelly / client.sh
Last active August 29, 2015 14:05 — forked from nstielau/client.sh
#!/bin/bash
echo '{
"handlers": ["debug"],
"name": "push_woot_test",
"output": "woot!",
"status": 0
}' > /dev/udp/127.0.0.1/3030