Blog O' Matty


Finding words with look

This article was posted by Matty on 2006-05-28 23:56:00 -0400 -0400

If you have ever had a moment when you couldn’t recall a word from memory, but knew something about the word, you probably wandered to one of the numerous online dictionaries to find the name. If you happen to have a Solaris box handy, you can avoid the web and use the look utility to find the word. Look is run with a string that you want to match to a word, and it uses the word list in /usr/share/lib/dict/words during the comparison. The following examples show this nifty utility in action:

$ look liti
litigant litigate litigious

$ look oth
Othello other otherwise otherworld otherworldly

Awesome SIP Tutorial

This article was posted by Matty on 2006-05-28 14:32:00 -0400 -0400

I have been spending a bit of my time reading up on VOIP protocols. While searching the ‘net for good SIP/RTP/RTCP documentation, I came across an awesome SIP tutorial. This tutorial is extremely well written, and definitely one of the best I have found so far!

Cool write up on AMD Opteron frequency scaling and TSC drift

This article was posted by Matty on 2006-05-28 14:26:00 -0400 -0400

This is a nifty write up on AMD Opteron frequency scaling and the issues associated with TSC drift:

http://lkml.org/lkml/2005/11/4/173

Using BIND to reduce ad server content

This article was posted by Matty on 2006-05-27 15:01:00 -0400 -0400

Internet advertising has become big business, and we see the effects of it in almost every page we view. The ad content typically comes from one or more well known ad servers, and some folks have come up with some clever ways (e.g., hosts files, DNS integration, etc.) to minimize the “ad effect” in the content we view. I have been using Mike’s host file for quiet some time, but for some reason OS X (actually lookupd) doesn’t handle large hosts files real well. Since OS X would get bogged down during DNS resolution, I decided to merge all of the ad domains into DNS to centrally fix the problem for the clients I support.

This was super easy to do, and only required two steps (assuming you are already running bind). The first step is to add one “zone” statement to named.conf for each ad domain you want to nix. The following example shows the named.conf entry you would add for the ad domain adservers.com:

zone "adservers.com"
{
type master; notify no; file "master/null.zone";
};

You can get a comprehensive list of the well known ad server domains from the ad blocking website. Once you retrieve the list, you can merge the domains into the named.conf using a combination of shell utilities, or you can download the Perl script (updateads.pl) I wrote to automate this process. The Perl script grabs the latest host file from the ad blocking website, formats the data, and spits out several lines that can be appended to named.conf:

$ updateads.pl |more

zone "ad1.com" { type master; notify no; file "master/null.zone"; };
zone "ad2.com" { type master; notify no; file "master/null.zone"; };
zone "ad3.com" { type master; notify no; file "master/null.zone"; };
[ ..... ]

Once you add all of the domains to named.conf, you need to create a zone file with one wildcard A record (this record is what is used to remove the ad servers, since the wildcard record will translate all entries in a given domain to 127.0.0.1). I am currently using the following zone file (with different domain names) to implement my ad blocking solution:

; File: null.zone
; Last modified: 07-10-2005
$TTL 86400 

@ IN SOA ns.mydomain.com hostmaster.mydomain.com. (
2005071005 ; serial number YYYYMMDDNN
28800 ; refresh 8 hours
7200 ; retry 2 hours
864000 ; expire 10 days
86400 ) ; min ttl 1 day
NS ns.mydomain.com.

A 127.0.0.1
IN A 127.0.0.1

I have found that using this technique speeds up the time it takes to render a page, enhances privacy, and will also cut down on the amount of traffic consumed by your site. Tis good stuff!

Splitting files with csplit

This article was posted by Matty on 2006-05-24 21:22:00 -0400 -0400

Periodically I find that I need to split a file into several pieces. There are a number of utilities that can be used to split a file, but I have grown to adore csplit. Csplit can split files based on regular expressions, or by quantity. The following example uses csplit to split /etc/services into a series of 10-line files:

$ csplit -f services.bak.00 /etc/services 10 {10}

172
208
225
372
408
188
450
392
256
325
434
521

$ ls -la service

-rw-r--r-- 1 root root 172 May 24 12:36 services.bak.0000
-rw-r--r-- 1 root root 208 May 24 12:36 services.bak.0001
-rw-r--r-- 1 root root 225 May 24 12:36 services.bak.0002
-rw-r--r-- 1 root root 372 May 24 12:36 services.bak.0003
-rw-r--r-- 1 root root 408 May 24 12:36 services.bak.0004
-rw-r--r-- 1 root root 188 May 24 12:36 services.bak.0005
-rw-r--r-- 1 root root 450 May 24 12:36 services.bak.0006
-rw-r--r-- 1 root root 392 May 24 12:36 services.bak.0007
-rw-r--r-- 1 root root 256 May 24 12:36 services.bak.0008
-rw-r--r-- 1 root root 325 May 24 12:36 services.bak.0009
-rw-r--r-- 1 root root 434 May 24 12:36 services.bak.0010
-rw-r--r-- 1 root root 521 May 24 12:36 services.bak.0011

Tis good stuff!