quick and dirty dns lint

I run a DNS server that I and a lot of my friends use. The problem with it being “free” and being between friends is sometimes people forget to tell you if they have switched DNS serving arrangements or just haven’t kept the registration.  I wrote a quick and dirty script, thanks to the whois ruby gem, to check to see if all the domains listed in Bind9‘s named.conf are still registered and if so do they still have our nameserver listed as one of the nameservers.  g0ff asked me for a copy, so I thought it might be useful to share with others.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'rubygems'
require 'whois'
 
zones = Array.new
ZONE_RE = /^zone "(\w+.\w+)" in/
File.open(ARGV[0]) do |f|
  f.each_line do |line|
    md = ZONE_RE.match(line.chomp)
    zones << md[1] unless md.nil?
  end
end
 
NS_RE = /^#{ARGV[1]}$/i
 
zones.each do |zone|
  c = Whois::Client.new
 
  begin
    domain = c.query(zone)
 
    if domain.registered?
      if domain.nameservers.detect { |ns| !NS_RE.match(ns.name).nil? }.nil?
        puts "#{domain.domain} doesn't seem to have us as a dns server"
      end
    else
      puts "#{zone} doesn't appear to be registered"
    end
  rescue Whois::ResponseIsThrottled
    sleep 120
    c = Whois::Client.new
    retry
  end
end

Movember early termination: no mo

At dinner, my beautiful wife Sarah made the suggestion that she would match my donations if I shave it all off today.  At the start of this month, Lena had been asking “When do we pay you to shave it off?” Today is apparently the day.

I failed at my goal of growing a mustache for the full month of november, but when I could double the $611 I raised, I had to have some serious consideration.  After consulting with my mo bro, Chad, taking off the mustache was the right thing to do for the fund raising aspect of men’s health and in the spirit of Movember.

The fact that I looked like a 15 year old miscreant with what little mustache I could grow is just icing on the cake. At the end of this post are three photos detailing the end of the mustache and the early termination of Movember.  I do not regret any of it, but given how poorly my facial hair comes in, I think I’m unlikely to do it again.

At this point in time, I’ve raised $1,222 for men’s health issues to fight prostate cancer and testicular cancer.  There is still time, as these are excellent things to raise money for! I like all my man parts and I aim to keep them!  If you want to donate, please do!  http://mobro.co/ktgeek

Movember Day 29: Thanks @ana_crt! (Also, orthodontist mo!)

Special and awesome thanks to Ana for donating! 2 more days to go, get your donation in now and be awesome like Ana!  http://mobro.co/ktgeek  With her donation and one from Jason, I’m at $586.  It would be awesome to break 600. (More awesome would be $1000, but I’m being realistic.)

To celebrate, Ana (and everyone else) gets a “I’m at the orthodontist” picture!

Movember Day 24: Mustache in the Huddle House

I haven’t posted in a bit, but I haven’t thrown in the towel yet. I’ve been so busy I haven’t been able to say: seriously, I’m being goofy for a good cause, if you can, please donate. It’s only 6 days until the stache goes away. The mustache is temporary, a cure for testicular or prostate cancer can be forever!

20121124-084350.jpg

FFI for Ruby and an mp4v2 example

Previously on my blog: In my TiVo2Podcast stuff I automated the process of putting chapters around commercials, but had to call out to a small C++ app I wrote to put the chapters in using libmp4v2.

A few weeks ago I was looking at some ruby gems for a project I was working on and stumbled across ffi, a foreign function interface gem for ruby, or as its docs put it: “a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code.”  As long as you know the function signatures that you need, its pretty trivial to make the calls from Ruby. You do need to be aware of memory management stuff sometimes, but overall its pretty easy, especially for basic use. If you’re only going to be working in Ruby and need access to a C library, this is much easier than mucking with swig, that’s for sure.

The mind-blowing part for me is that the authors of the gem have made it smart enough to know what flavor of ruby vm and platform the code is running in and it does the right thing, no matter if its JRuby or on Windows or whatever. While I haven’t had a chance to use it yet, I suspect this property will be useful with JRuby at work in the future.
Continue reading FFI for Ruby and an mp4v2 example

Keith's attempts to fix the cable of life