Indenting code

Code indentation is a good idea (although probably not as good an idea as the Python people think), so Vim will indent your code for you.

First, put filetype plugin indent on in your .vimrc to enable the smart language-specific indentation algorithms (and other fancy features). If you don’t you’ll be using the simple old-vi-compatible indentation.

That’s mostly it. As you edit, vim will indent.

If you need to reindent an entire file, goto the first line and type =G in non-insert mode.

Published
Categorized as Uncategorized Tagged

DHCP

Now that I have a DNS server that can be easily redirected, I needed a DHCP client that could easily redirect it. I had been using pump, but there didn’t seem to be an easy way to make it write the resolver data to somewhere other than /etc/resolv.conf. I knew that dhcpcd would be able to do it, but it always seemed to be over-complex, and I think it relies on netlink devices.

I tried udhcpc and I was pleased. It has a clear division between DHCPing and configuring the network: it will DHCP then simple sends all the information it received to a seperate configuration script. I can replace this script with anything I want, so I can do all my strange configuration. I liked this so much that I have decided to move all my non-DHCP configuration to a compatible format.

Published
Categorized as Uncategorized Tagged

Caching DNS

I move my GNU/Linux laptop bewteen different networks quite regularly, and I’ve never been totally happy with its configuration. Many other people do the same thing, and they have a few different methods for auto-configuring networking. But none of them seem perfect for me.

I used to use pdnsd, and it worked well when I knew the nameservers for each network I connected to. The pdnsd.conf contains a list of nameserver details, and allows you to configure tests to check if those servers are available. When I move between networks I could also use pdnsd-ctl to explicitly enable an appropriate set of nameservers. But this isn’t very useful when I connect to a new DHCP network where I don’t have the details of the nameservers until I connect. I could write a script to dynamically rewrite the pdnsd.conf, but this seems a bit messy.

After some research (in the Debian package list) I choose dnsmasq. It doesn’t have a persistant cache like pdnsd, and it won’t let me configure a whole set of nameservers like pdnsd, but it does allow me to easily change the default nameservers to use for forwarded queries.

By default, dnsmasq uses /etc/resolv.conf (like everything else) to get the addresses of nameservers to contact, so when dnsmasq is running on a firewall, the internal machines can use the firewall machine as nameserver. But I don’t want that. I want my resolv.conf to have the loopback address as the nameserver, and I want dnsmasq to read from another file. This is trivial to setup, and that is why I’m now using dnsmasq.

Published
Categorized as Uncategorized Tagged

A long time ago…

It’s been more than a month since I’ve written anything here, and lots of things have happened in that time. I’ll like to promise that my blog will catch up with my life, but I’d break that promise tomorrow. Some events from the past may appear here in the future (especially the ones with pictures), but it will not be complete.

So I’m starting afresh. After some helpful advice from Marc (Don’t panic: I only took his advice, not his really bad drugs!) I have a new plan for my blog, starting tomorrow. I hope you like it.

Moving Mouse Tree

I have a pet snake called Scsi (don’t ask!). He eats warm mice, nothing else. I keep the mice in the freezer until needed, then defrost them slowly and finally warm them in a cup of hot water.

A few years ago Scsi was not easy to feed: I had to spend time waving small warm mice in front of him before he would bite. He is much easier to feed now for at least 3 different reasons:

  1. He eats larger mice.
  2. I can tell when he is hungry.
  3. He can recognise his feeding by me.

I have phrased #3 quite carefully, but I’ll explain in more detail: Scsi doesn’t know what I am! When I move in a particular way he knows that I supply food, and he also knows that he can safely climb up my arm; he might think I’m a moving mouse tree!

As Scsi gets older, he will gain increasing experience of being a snake. He might learn new things, but he will never understand who or what I am, and he will always be a snake. Humans are just too different for snakes to comprehend, unless they smell like warm mice.

Unfortunately, many programmers are like Scsi. They live as masters in their own tiny vivariums, and they don’t recognise the greater things outside. They continue to program in the same way, and may gain many years experience without ever becoming more advanced. I have seen programmers with 2 years experience who were much better than other programmers with 10 years.

This effect is common with Perl programmers. Perl has a larger range of expression than most other programming languages, so you are much more likely to find these primitive programmers in a Perl world: they might have 5 years experience of CGI scripting with Perl, and they might even be extremely good at CGI scripting with Perl, but they are not advanced Perl programmers.

This problem is not confined to higher-level languages: I have observed similar situations with lower-level languages like C, C++, and Java.

But let’s not limit this analogy to programmers. Many people (although still a minority) don’t believe in God! They look out of their vivarium and believe they understand the universe despite the constant reminders that they don’t.

My dad’s bigger than your dad!

As I’ve mentioned before, I’m a Java anti-fan. As such, one of my duties is to attempt to correct the misleading Java propaganda. But I have to make sure I don’t go too far and create misleading propaganda of my own.

Someone recently asked: Can Java technology beat Perl on its home turf with pattern matching in large files?

Given the supplied answer, a more accurate question would have been: “Can a poorly written Java program beat a really badly written Perl program?”

I could easily retort with another stupid example showing Perl code kicking Java’s ass, but that wouldn’t help. We need a more objective way of measuring how crap Java is :-)

The Language Level system by Capers Jone is a nice way to rate a language, but other empirical comparisons are needed.

Bypassers will be prosecuted

Bob went to the doctors a few weeks ago. While waiting in the clinic, he started to read through some of the magazines on the little table. Between two of the magazines he found a green ring-bound document decorated with the clinic’s logo. After skimming through a couple of pages, he realised that it was actually part of a confidential file about some of the other patients. He immediately went and told the receptionist and returned the file. Bob told a few of us about his experience, but never revealed any of the information he read, and the incident was almost forgotten…

Yesterday Bob was visited by a police officer who imformed him that he has been accused of some sort of criminal trespass because he read part of the confidential file.

Something isn’t right!