Due to some friendly ribbing in the comments in my post about dnsmasq, I thought I would make an attempt to explain some of the alphabet soup. All of this stuff is readily available on the web and can be found with a little googling, but I’ll try to give a one cent synopsis. Obviously, if you’re net savvy there’s not going to be anything beyond this point that you don’t know already.
Category: Computers
Man, coordinating host files on multiple computers sucks. I wish there was a way to map computer names to IP addresses and have the other computers just query a central one for the names and addresses so I can just update host names in one spot.
Sigh.
WAIT!
That’s what DNS is for! And since I’m running a Debian server, I can just install a DNS server!!
Oh man, that’s just another thing I have to learn. Now I have to figure out about MX records and zones and new config files. Plus, what do I need a full-blown DNS server for? I’ve got a network with like, 6 computers on it including the mobile ones. So I’m going to setup a full blown DNS server, to handle my local network of 6 or so computers? That seems like a touch overkill.
I wish there was a simple alternative that could be simply configured to handle a local network. I suppose it would be perfect if it could just serve up a version of a hosts file or something and then forward non-local names to a real nameserver.
Sigh.
What’s that you say? dnsmasq? A caching DNS server? It has just 3 dependencies? It reads the hosts file as well as other files if configured to do so? It has 1 config file? With all options documented? Plus it has a DHCP server that can handle multiple networks? It automatically adds host addresses assigned via DHCP? I can probably have it running in 5 minutes? No tutorials?
Really? Can it really be that simple?
Why, yes.
Yes it can.
Closures
I recently implemented a feel-good bit of functionality with my awesome window manager. I figured out how to use the builtin popup menu to drive the uzbl browser. In doing so, I thought I understood how it worked. To be thorough; however, I decided to do an investigation. I learned that my original understanding was flawed and that I had inadvertantly stumbled across a software concept I’d heard of but never properly understood- the closure.
Going Backwards
The current window manager I’m using, awesome, is a fork off another window manager named dwm- dynamic window manager. It’s supposed to be smaller and faster than most WM’s. I felt like awesome was becoming sluggish with some of the recent changes. Most noticably on my EEE.
So, I’ve decided to go backwards a second time and try dwm on my EEE for a bit. So far, the most interesting exercise was converting the mercurial repository to a git repository. Fortunately, there’s hg-fast-export which was easy enough to get and use. I didn’t want to get cluttered up learning another DVCS, this saved me from having to do that.
My dwm impressions later.
Respect My Authoritah!
For those interested in being their own certificate authority, as opposed to self-signed certificates, this site is a fantastic resource. I used it a year ago to setup certificates for my mail server and I used it again today to update the certificates.
Definitely worth a read through.
uzbl and dmenu
I’ve been playing around with uzbl again and decided it was high time I tried out dmenu. What I’d read made it sound pretty slick, I was just leery of having to learn how to work with another application. Thankfully, dmenu is extremely easy to use. It isn’t available as a deb package, but the source is readily available. I built it with the vertical patch.
As practice I figured I’d rewrite one of the stock uzbl scripts as a python script. I chose the load_url_from_bookmarks.sh
script since it was pretty easy for me to decipher. That’s not sayin’ much since my bash scripting foo is, well- ‘miserable’ is probably the right word.
The exercise proved valuable for a couple of reasons.
More EEE Touchpad Nonsense
Oh for F!@#$%’s sake.
Another update to the xserver and my touchpad is broken. After googling for about 10 minutes, I come up with this thread from just a few days ago. Apparently udev configuration is out and the xorg.conf is back in.
This is definitely a weak point in open source stuff. Changes like this should be documented better or some kind of warning or explanation that current configuration techniques are about to be broken should be available.
I suppose this is what I get for using the ‘testing’ distro.
UPDATE:
Here’s the relevant section to add to xorg.conf:
Section "InputClass"
Identifier "Synaptics"
driver "synaptics"
MatchProduct "ETPS/2"
MatchDevicePath "/dev/input/event9"
Option "VertEdgeScroll" "1"
Option "MaxSpeed" "1"
Option "AccelFactor" "0.05"
Option "TapButton1" "1"
Option "TapButton2" "2"
Option "TapButton3" "3"
EndSection
See the InputClass
section of the xorg.conf man page.
UPDATE II:
The two Match
lines can be replaced with a MatchIsTouchpad "1"
line. I don’t know if this is better or not- but it seems like it might be preferrable since InputClass sections are applied to anything that matches according to the man page. At least it’s limited to touchpads this way.
Dynamic Modules in Python
I have defined a rather simple class for an XML proxy server to facilitate interacting with a blog. Right now, I’ve implemented a WordPress version so I can work with my own blog. Theoretically, it should be possible to implement other classes specific to other blog types thus making my program more general, and useful to others.
What I hadn’t figured out was how to structure the code so as to minimize monkeying around with multiple files when adding the new class. My goal was to come up with a structure that simply called for adding a module to extend the functionality.
Today, I finally came up with something and it utilizes the dynamic module loading capabilities of python.
Installing ProFont on Debian
I wish I could say it was a rewarding experience, alas, I cannot. At least not without descending into maniacal laughter for a few moments.
One of my personal quirks is an inability to let something go. Especially if it’s computer related. Being unable to just let-it-go has it’s pluses as minuses. On the plus side, I’ve solved some pretty tricky computer related problems and learned some interesting lessons along the way. On the minus side, I can waste hours working the problem, finding a solution and feel like I’ve wasted that time.
This experience goes in the minus column.
Debian Updates?
I’ve got apt-mirror setup here to serve updates for my debian based computers here at home. The update script hasn’t downloaded an update for AMD64 squeeze or my EEE laptop for almost a week. I’ve done sanity checks as well by swapping out my sources.list
file to pull directly from the debian servers and I get the same result. Very odd for that amount of time to pass with no updates.
I’m assuming that ‘squeeze’ is in the process of being frozen and this has also temporarily frozen the ‘testing’ repo. I actually pull updates from ‘testing’ as opposed to ‘squeeze’ so I’m a little surprised that I’m affected. More than likely this is a consequence of my ignorance regarding the actual management of the repos. I haven’t seen any announcements regarding freezing the current testing code, so that’s my main cause for confusion.
Hopefully we get back to normally scheduled updating soon.
UPDATE: Apparently a main server has failed so updates are frozen for the time being. Thanks to Willian in the comments.
UPDATE 4/4/10: Cool beans- repo’s available again. Back to regularly scheduled updating.
Starting to ‘git’ it
The hardest part for me, so far, about using git is to actually use it. I mean, I’m checking out branches, making changes and the like. But mentally I’m still in the mode of organizing file versions in my head and then futzing with command line stuff (mv
, `cp and the like), as opposed to using git to help me do that.
More recently I had a couple minor git revelations that indicate I’m starting to grok this whole VCS thing a little more.
A Personal Milestone
Having been using open source software for years now, I’ve never really done any thing to try and reciprocate, as it were. Well, I’ve finally gotten my chance and contributed a 3-line bug fix to the python-markdown package.
Here’s the fixi, marked for posterities sake.
We’ve been Quicken users for quite awhile now. However, under the premise that there isn’t that much new under the sun in the world of personal accounting, we haven’t updated our version for about 5 years now. To compound my particular situation, I had fallen behind on the bookeeping by about 3 months. I’ve made up for more time before; but, frankly, I wasn’t in the mood to make it up.
Unfortunately, the version of Quicken we had did not support OFX direct connect. So we looked at getting Quicken 2010- probably the Deluxe version because it supported budgeting as opposed to the baseline version. I took a look at the price tag and wondered what the state of Gnucash was.
Python Unicode
I’ve been working on a piece of code to convert a blogpost into Markdown text. Yes, I’m aware of the html2text.py module (mine is html2md, so nyeah!) All I’ll say is how the heck does one learn anything if they keep relying on other people’s work?
Anyway, I’ve got a naive implementation working now (won’t handle more complicated nestings like lists in blockquotes) when I ran into a snag involving unicode. Upon retrieval of a particular post, I got the following error:
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’xa0′ in position 174: ordinal not in range(128)
It came up in the context of passing a string to the iterparse
function of the cElementTree module. The character in question is a ‘non-breaking space.’ Frankly, I wasn’t sure how it got there, but I verified it’s presence in the string and then set to figuring a way to deal with it. I believe this is an instance of mixing strings and unicode together, rather than dealing solely in one or the other.
I found the unicodedata
module for a solution. There is a function call normalize
which will map unicode characters to the local encoding. In this case, ASCII. Now this solution is far from perfect, since special characters (say, from the Russian alphabet or characters with tildes above them) are just converted to rough ASCII equivalents.
The following code additions fixed my problem:
import unicodedata as ud
.
.
.
uthml = ud.normalize('NFKD', unicode(html))
Where html
is a string of html directly from the website. I can then pass uhtml
to the iterparse
function and the error is gone (because the u’xa0′ characters are translated to ASCII space characters) and the rest of the program is able to do it’s thing.
I don’t know if this will be the final solution, but it allows me to continue with the development I had been originally interested in. I was aware of the potential for unicode issues, but had hoped they wouldn’t crop up. This gives me a simple 2 line way to deal with it for the now.
Learned Something New
I’m in the process of learning how to use lxml- a fast, powerful XML parser for python that relies on libxml2. I don’t know much in the way of details regarding xml so I got stuck as soon as I got started.
I was passing straight markdown generated XHTML into the various xml parser methods and objects for lxml. All of them were dying with the same error. The only parser that worked was the HTML parser.
The xml parsers kept coughing up the following error:
lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 1, column 222
I really had know clue as to what this might mean. Since the output was from markdown, I reasoned there was little likelihood of malformed XHTML or some such. Besides, I knew that it rendered fine on web pages. Liekly, there was some significant detail I was missing. Unfortunately, my lack of xml knowledge meant I didn’t have anything to fallback on for solving the problem.
Finally, I turned up a comment thread where I learned that xml documents require a “root element.” I had seen the term “root” but only had a vague notion of what it meant. Now, I know exactly what is meant.
Prior to passing the markdown string to the parser, I performed the following operation:
rootedhtml = "<post>%s</post>" % html
Where html
was the markdown output. I then passed rootedhtml
to the parser and it no longer chokes.
Now I can get back to solving my original problem.
Python-markdown Strike
I’ve incorporated markdown into my blog client and in the course of doing so, I saw that it could be extended. So I thought I’d give it a go and see if I could add a ‘strike’ extension to the markdown module.
It turned out to be almost trivially simple thanks to the documentation. I chose to use a double hyphen around a word to create the strike. I looked elsewhere and double tildes seems to be another nice way to do it. The code below shows it for the double hyphen but the code would be identical in either case except for the RE definition.
Here’s the code:
import re
import markdown
from markdown import etree
STRIKE_RE = r'(-{2})(.+?)\2'
class StrikeExtension(markdown.Extension):
def extendMarkdown(self, md, md_globals):
md.inlinePatterns.add('strike', markdown.inlinepatterns.SimpleTagPattern(STRIKE_RE, 'strike'), '>strong')
def makeExtension(configs = None):
return StrikeExtension(configs = configs)
That’s it.
The SimpleTagPattern
object is a general purpose object that’s part of the markdown library and it’s used to create text rules involving inline patterns such as emphasis or strong. That’s all my version of the strike rule is.
I implemented my extension as a module, so I had to put it in the ‘extensions’ directory of my markdown library. It’s also possible to just incorporate the extension in project code and make markdown aware of it, but I haven’t tried that yet.
Those of you who receive emails from myself may have noticed that my emails now have some funny business attached to them. There is a simple explanation- I’m using PGP to sign my outgoing emails. Ultimately, I’d like to start exchanging emails using full encryption, but it takes two to tango.
Here is my public key. Using this, it’s possible for email software to verify my signature. Further, the public key can be used to encrypt email text so that only I, with my private key (no, you can’t see- it’s PRIVATE) can decrypt and read what’s been sent to me.
I’ve been checking around and it appears that gmail is experimenting with PGP support through their web interface. Additionally, just about any email program (Thunderbird and so forth) can be setup to use PGP. Therefore, those out there using 3rd party email clients should take the time to install GnuPG and join the encryption bandwagon.
The hardest part is the initial setup. Once that’s done, composing and sending email is more or less the same as it ever was.
Building xpdf for Debian
For whatever reason, xpdf has disappeared from the Debian testing repository. It’s a nuisance since it seems to be the best combination of fast and usable among the various non-adobe pdf readers. It appears that a version has been reintroduced to sid, but it’s been awhile now and I wanted a working pdf reader.
So I opted to build it from source.
apt-mirror Update
The download took all night. It ended a little after 7 this morning, which pegs it at about 14 hours to download 65GB. My internet connection is a 10Mbit cable line, so there’s a bench mark of sorts.
When I embarked on this little project, my goal was to come up with a way to force apt-cacher-ng to update all of its cache on a schedule. For the native machine/architecture all that is required is to schedule an apt-get update
which can be done by enabling it in the apt config files. But I couldn’t figure out how to force the same thing for a foreign architecture (ie- for another computer running i386 based stuff) so the files would already exist on the network.
The more I thought about it, I realized there wasn’t any bandwidth savings to be had because, though both machines run debian/testing
, they both required different sets of package files because of the different architectures. Therefore, anything I was doing was going to be for creating a more convenient update process by having the files already present on the local network. The apt-mirror
package isn’t ideal since it downloads an entire repository for a debian branch rather than caching and updating just the packages I need. However, it’s better than a full-blown mirror and, once it’s initially setup, the downloading is merely a matter of updating the local repository. In the end, it seemed like the best compromise.
apt-mirror
Prior to the server mobo dieing I had been using apt-cacher-ng to minimize internet traffic. The setup worked well since both my EEE and my server were running i386 packages from the testing distribution.
With the new mobo in the server, all the packages are amd64 based packages. Thus, I’m not really gaining any advantages with apt-cacher since different packages are going to the two computers. So I’m trying out the apt-mirror package since it can be configured to download packages for different architectures.
Since it’s a mirror as opposed to a caching application, it’s downloading all of the packages related to testing for both i386 and amd64. I started it about 5:15PM. The download size is ~65GB. It’s still downloading.
More later… once this step is complete.