April 13, 2008 Archives

2008/04/13 20:35:57

april 12th

http://flickr.com/photos/25587586@N03/2410049114/in/set-72157604508371285/

The only picture of me at the protest, and it had to be while I was reading the paper?

Posted by bbot | Permanent Link | Categories: Etc

2008/04/13 14:40:32

from hell's heart I stab at thee, vi

So the previous blog entry looks pretty simple, right?

Wrong!

You see, I pasted the chat transcript directly into vi, which nanoblogger uses to edit blog entires. Nanoblogger uses direct html formatting, so the greater than/lesser than names were interpreted as tags, and thus didn't render. Lame!

HTML being a proper markup language, however, implements a kinda sorta escape code sequence, where you can use "&lt;" and "&gt;" (lesser-than and greater-than, get it?) to render < and > without your html interpreter (read: web browser) invisibly erasing them.

But the problem was, I had about twelve instances of < and > to replace. Text navigation in vi, while not impossibly difficult, is still awkward; and in any event, doing all that crap by hand was ideologically impure. Whatever was I to do?

Search and replace, of course!

Vi, being a Real Man's text editor, uses sed-style regex expressions for search and replace, and as I was about to discover, sed-style wildcards. The command string I first tried using was "%s/<bbot>/&lt;bbot&gt;/g" (%s/ to search every line, /g to replace every instance. The regex is of form /search string/thing to replace search string with/)

That command, of course, resulted in "<bbot>lt;bbot<bbot>gt;" instead of "<bbot>", since motherfucking sed uses & in the replacement string to mean what the search string matched. This lets you do all sorts of enormously clever things, but is a giant pain in the fucking ass when you're messing with HTML enity codes.

Now, normally, you would use shell style quoting to tell sed to ignore &, but vi isn't the shell! It ignores quotes! I, of course, only figured this out after running through every permutation I could think of, before just using the \ escape character.

Builds character, right?


Posted by bbot | Permanent Link | Categories: Linux

2008/04/13 13:45:07

talking the talk II

07:34 -!- Irssi: Starting query in freenode with bjwebb
07:34 <bjwebb> hi
07:34 <bbot> Hey?
07:36 <bjwebb> erm, are you a real person?
07:39 <bbot> Indeed I am.
07:39 <bjwebb> lol, im making an irc bot, and it was supposed to join as bbot
07:40 <bbot> Too bad, sucker. This is my nick!
07:40 <bjwebb> lol, okay
07:40 <bjwebb> im not managing to get it to work anyway

Posted by bbot | Permanent Link | Categories: Etc