Skip to content

Instantly share code, notes, and snippets.

View eqhmcow's full-sized avatar

Daniel S. Sterling eqhmcow

View GitHub Profile
@eqhmcow
eqhmcow / check_time.pl
Created August 20, 2009 10:58
script that automatically resets a virtual machine's system time after the host resumes from sleep. This is handy e.g. when using vmware on a laptop
#!/usr/bin/perl
use strict;
use warnings;
=pod
check_time.pl
This script automatically resets a virtual machine's system time after the
host resumes from sleep. This is handy e.g. when using vmware on a laptop.
@eqhmcow
eqhmcow / git-add-svn-trunk.pl
Created September 3, 2009 17:43
script to track multiple svn repos in one git repo
#!/usr/bin/perl
use strict;
use warnings;
use File::Path;
# This script pulls in subversion files and history into a git repo.
# The subversion files are merged into the master branch under a specific
# subdirectory. This is useful if you have multiple svn repos that you want
# track in a single git repo, with a separate directory for each repo.
@eqhmcow
eqhmcow / macports-reinstall.sh
Created September 30, 2009 01:59
This automates (more or less) the process described at http://trac.macports.org/wiki/Migration
#!/bin/bash
# This automates (more or less) the process described at http://trac.macports.org/wiki/Migration
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
port installed active | /usr/bin/perl -p -e 'undef $_ unless $b++; # the first line is info for humans
s/^\s*(.*)\s*\(active\).*/$1/; s/\s\@[^+\n]+//; # remove (active) and the version number
s/(\+[^+\n]+)/ $1/g' > active.macports # put spaces before each +
port clean --all all
port -f uninstall installed
#!/usr/bin/perl -w
use strict;
use warnings;
use Benchmark qw(:all);
use YAML::Syck ();
use Data::Dumper ();
use Storable ();
use JSON::XS ();
use YAML::XS ();
From: Niko Tyni <ntyni@debian.org>
Subject: Add support for Abstract namespace sockets.
Closes: 490660, 329291
blead commits
99f13d4c3419e967e95c5ac6a3af61e9bb0fd3c0
89904c08923161afd23c629d5c2c7472a09c16bb
by Lubomir Rintel <lkundrak@v3.sk>
trivially backported for 5.10.1 by Niko Tyni <ntyni@debian.org>
@eqhmcow
eqhmcow / sp.sh
Created December 30, 2009 16:00
interactive aspell
#!/bin/bash
while read i
do echo "$i"; for w in $(echo "$i" | aspell list)
do echo "$w" | aspell pipe | grep --color=auto '^&'
done
done
@eqhmcow
eqhmcow / puppet NFS
Created December 23, 2010 14:12
share NFS mounts on RHEL/CentOS with puppet, using augeas to manage exports file
# modules/nfs/manifests/init.pp
class nfs_server {
file { "destroy_exports":
path => "/etc/exports.puppet",
ensure => present,
source => "puppet://$servername/modules/nfs/empty",
}
package { "portmap":
@eqhmcow
eqhmcow / divide.pl
Created January 3, 2012 19:09
safe divide by zero
#!/usr/bin/perl
sub divide {
($a, $b) = @_;
$c = eval { $a / $b };
$@ =~ m/Illegal division by zero/ && rand() > .5 ? ($b = 1) : ($b = -1);
$@ && ($c = $a / $b);
return $c;
}
@eqhmcow
eqhmcow / interfaces
Created May 25, 2012 23:51
ubuntu network interfaces file - needed to rmmod bonding before it would reliably work over reboots
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto bond0
iface bond0 inet manual
# bizarre, but this works...
@eqhmcow
eqhmcow / iscsi-blockdev-uid.pl
Created July 21, 2012 06:14
generate an id based on a block device's iscsi target name and lun number
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Digest::SHA1 qw(sha1_base64);
my $hash;
GetOptions("hash" => \$hash);