The Fugue Counterpoint by Hans Fugal

3Feb/081

Local Caller ID Database

If you use a VOIP provider for PSTN calls, you will be able to relate to the frustratingly boring caller ID names that get passed down to you. Very infrequently do I get anything better than a city name. Even if you have a direct PSTN connection into Asterisk, you may find the caller ID names from cell phone users (maybe just about everyone that calls you) are less than precise. Here's a solution.

We want to store alternative names in some kind of database that Asterisk can access when a call comes in. AstDB is perfect for this. We also want to leave things unchanged if we haven't manually stored a name for this number. The following will do the trick:

    Set(CALLERID(name)=${IF(${DB_EXISTS(cid/${CALLERID(num)})}?${DB(cid/${CALLERID(num)})}:${CALLERID(name)})})

Now, we just need a way to update the database with names. At first I had grandiose ideas of an AJAX-enabled website that shows you the last few CDR records and lets you edit the names with a spiffy in-place editor. You could still accomplish it, but in the end I came up with a much simpler if less elegant solution. At least, it's simpler if you use the terminal all the time like I do. Put this script in your path:

#! /bin/sh
# usage: $0 number "name"
user=`username`
host=falcon
exec ssh $host asterisk -rx \'database put cid \"$1\" \"$2\"\'

Combine this with jabber notification as I've discussed before, and a little cut & paste from your jabber window, and updating names is cake.

12Aug/060

:set exrc

Let's say you work on more than one project, each of which has different policy
about tabs (e.g. one of the only two sane tab policies: all real tabs or all
spaces). You need vim to behave one way in project A and another way in project
B. You could use modelines, but that's a violation of DRY.

The solution is something I'd often wished for but never realized vim did. set
exrc
in your ~/.vimrc tells vim to search the current directory for a
.vimrc or .exrc file. You might need a few symlinks (automatable with a
Makefile) to reach all the subdirectories of your project tree, but this will
solve all your problems.

Tagged as: , , , No Comments