Skip to content

Instantly share code, notes, and snippets.

View ap's full-sized avatar

Aristotle Pagaltzis ap

View GitHub Profile
@ap
ap / spindown.sh
Created April 20, 2014 12:33
Spin down unused ATA disks on Linux
#!/bin/sh
echo -n 'Spinning down unused ATA drives:'
/usr/bin/lsscsi | /bin/grep -w -F ATA | /bin/cut -c54- \
| while read dev ; do
if /bin/mount | /bin/grep -q -E "^$dev[^/]* " ; then continue ; fi
echo -n " $dev,"
/sbin/hdparm -q -Y "$dev"
done
echo ' done.'
@ap
ap / faster-header-utils-bench.pl
Last active August 29, 2015 14:14
Pull request benchmarks for Plack#495
#!/usr/bin/env perl
use 5.012;
use warnings;
use Benchmark 'cmpthese';
use lib 'lib';
use Plack::Util ();
BEGIN { *header_iter = \&Plack::Util::header_iter }
@ap
ap / http-dav.conf
Created October 17, 2008 12:40
minimal Apache WebDAV configuration
# this is actually a collage of bits from various config files
LoadModule dav_module lib/httpd/modules/mod_dav.so
LoadModule dav_fs_module lib/httpd/modules/mod_dav_fs.so
DavLockDB "/var/db/httpd/davlock"
# the following BrowserMatch lines were part of the sample config from the Slackware Apache package
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
@ap
ap / gist:30399
Created November 30, 2008 07:03
usable git log output format
git log --pretty='format:%x1B[33m%H%Creset%n%Cgreen%ar%Creset %an <%ae>%n%x20 %x20 %x1B[1m%s%Creset%n'
git config --global format.pretty 'format:%x1B[33m%H%Creset%n%Cgreen%ar%Creset %an <%ae>%n%x20 %x20 %x1B[1m%s%Creset%n'
@ap
ap / userChrome.css
Created December 1, 2008 13:17
Use Unsorted folder icon for ★ folders in FF3
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
.bookmark-item[container="true"][label="★"] {
list-style-image: url('chrome://browser/skin/places/unsortedBookmarks.png') !important;
-moz-image-region: rect(0px 16px 16px 0px) !important;
}
@ap
ap / proxy.pac.js
Created December 14, 2008 14:20
Efficient ad blocking via proxy autoconfig
/* the network your computer is on, and the subnet mask of that network */
var local_network = '192.168.1.0';
var local_netmask = '255.255.255.0';
/* the host and port of your regular proxy, if any; otherwise an empty string */
var upstreamProxy = '';
/* space-separated list of hosts or domains that should always be connected to directly without using a proxy */
var directZones = 'plasmasturm.org delicious.com paulgraham.com yahoo.com';
@ap
ap / termtitle.sh
Created December 31, 2008 07:58
Set terminal title then run a command
#!/bin/bash
TITLE="$1"
shift
printf '\e]0;%s\007' "$TITLE"
"$@"
@ap
ap / gist:66108
Created February 18, 2009 00:41
Polyglot Makefile (embedding a Perl script)
# polyglot Makefile (embedding a Perl script)
output.txt: input.txt Makefile
perl -x Makefile $< > $@
#!/usr/bin/perl
q-ignore:
-;
use strict;
# rest of Perl script;
@ap
ap / gist:94251
Created April 13, 2009 04:10
Broken dvipdft fix (failed trying to mkdir tempdir that it had already created)
--- /usr/share/texmf/bin/dvipdft 2007-06-28 04:50:14.000000000 +0200
+++ dvipdft 2009-04-13 06:13:05.000000000 +0200
@@ -31,7 +31,14 @@
$progname --help
$progname --version"
-tmpdir=`mktemp -d ${TMP-/tmp}/$progname.XXXXXX`
+# before we create the tmpdir, set trap for cleanup
+trap 'rm -rf $tmpdir ; exit 1' 1 2 3 7 13 15
+trap 'rm -rf $tmpdir' 0
%s![^\x00-\xff]!\= '&#' . char2nr(submatch(0)) . ';' !g