Skip to content

Instantly share code, notes, and snippets.

View dgl's full-sized avatar

David Leadbeater dgl

View GitHub Profile
@dgl
dgl / README.md
Created July 25, 2010 18:08
PowerDNS MySQL monitoring

Simple PowerDNS MySQL replication monitoring

Replace domain in "ucheck.domain" with a domain of yours in both the SQL below and ucheck-check.sh. Normally use the one the DNS servers are in (this assumes your servers are called a.ns.domain, b.ns.domain, etc, change in ucheck-check.sh).

Do something like this in MySQL:

CREATE SQL SECURITY DEFINER VIEW ucheck AS
  SELECT id, domain_id, name,type, content, ttl, prio, change_date from records where (name = 'ucheck.domain') WITH CASCADED CHECK OPTION;

GRANT UPDATE on pdns.ucheck to ucheck@localhost;

use v5.10;
use JSON;
use JSON::PP();
use Data::MessagePack;
use MongoDB (); # For MongoDB::BSON, which needs the whole driver it seems.
use Storable qw(freeze thaw);
use Benchmark qw(cmpthese);
my $fat = {
@dgl
dgl / vcat
Created August 5, 2010 18:37
#!/usr/bin/perl
use Text::VimColor;
# This is the output of :hi pasted in, season to taste
my $colors = <<EOF;
SpecialKey xxx term=bold cterm=bold ctermfg=4 guifg=Cyan
NonText xxx term=bold cterm=bold ctermfg=4 gui=bold guifg=Blue
Directory xxx term=bold cterm=bold ctermfg=6 guifg=Cyan
ErrorMsg xxx term=standout cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red
IncSearch xxx term=reverse cterm=reverse gui=reverse
@dgl
dgl / gdb-data
Created August 22, 2010 22:30
Use GDB to examine a non-executable file
#!/bin/sh
# © 2010 David Leadbeater; https://dgl.cx/licence
# Use GDB to examine a non-executable file. The file will be loaded starting at
# byte 0 in memory, you can then use normal GDB commands such as "x/s 0".
if [ $# -lt 1 ]; then
echo "Usage: $0 file"
exit 1
fi
use Test::More tests => 1;
ok 0;
unless(Test::More->builder->is_passing) {
diag `cat config.h`;
}
@dgl
dgl / installblead
Created January 23, 2011 16:52
An install script that installs a development version of perl (from git) and keeps a particular set of modules installed. Sort of perlbrew for blead, but not quite.
#!/bin/sh
# installblead: An install script that installs a development version of perl
# (from git) and keeps a particular set of modules installed. Sort of perlbrew
# for blead, but not quite.
# Usage:
# wget -O ~/bin/installblead https://gist.github.com/raw/792206/installblead
# chmod +x ~/bin/installblead
#
# git clone git://perl5.git.perl.org/perl # or git pull, whatever
package Aaaaaaaa::Test;
use Test::More ();
sub import {
local $_[0] = "Test::More";
goto \&{Test::More->can("import")};
}
1;
package a;
sub foo {
warn "foo";
}
sub rebind {
no warnings "redefine";
eval q{delete $a::{foo}};
eval q{*foo = sub { warn "bar" }};
@dgl
dgl / search_cpan.pl
Created October 11, 2011 19:45
acme's search_cpan.pl with threads
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
use warnings;
use 5.12.0;
use Archive::Peek::Libarchive;
use Parse::CPAN::Packages;
use Path::Class;
use Term::ANSIColor;
### Keybase proof
I hereby claim:
* I am dgl on github.
* I am dgl (https://keybase.io/dgl) on keybase.
* I have a public key whose fingerprint is 8EDA D6F5 ADC2 1C86 D1E2 32F3 F2E7 F1A7 E4D4 D21B
To claim this, I am signing this object: