darkness

Tuesday, 29 October 2002

News from the kitchen

darkness @ 02:58:17

I’m in the kitchen with my laptop. I love wireless.

Was working on a Perl Wiki last night and instead got distracted by making interface.pm work. It was doing something like this:

package A;

use B;  # B is playing the role of interface here.

package B;

sub import
{
  # It expected this to force Perl to finish loading A so it could
  # read the methods defined in A.
  eval "use A";

  ... do stuff with methods in A ...
}  # import

The problem here is that… it didn’t work. In the above case, I think package A does get loaded twice, but never until B finishes loading. Instead I had to basically translate the package name from Foo::Bar to Foo/Bar.pm, look in %INC for the file, then do $INC{$fileName}. I’m a bit worried because in this case (and the original implementation of interface for that matter), A will get loaded twice. I hope there’s nothing like $myInstanceVariable++ in its initialization.

I also made an abstract.pm so I could define interfaces like this:

package SomeInterface;

use abstract;

abstract someMethod;

Pretty useless, perhaps, but it makes me feel better. Plus it automatically stubs out the method with a call to croak. I’ll have to post my interface.pm and abstract.pm some time.

I’m on to writing the Wiki again tonight. I’m actually sitting down and working out the object model. I think XP says not to do this, but this isn’t an XP project (entirely). I’m trying to figure out how to make it totally extensible. I’m undoubtedly going to look back on this entire project later and say “why the hell did I do this?” Back off to coding, though.

Saturday, 26 October 2002

Software 2, darky 0

darkness @ 16:12:42

Battled TWiki last night when I couldn’t fall asleep at 0230. Ended up staying awake until like 0530 (only to wake at 1000-ish; I haven’t had my nap yet). While I appreciate all the great work the TWiki people have undoubtedly done: the fucking thing does not run in mod_perl. I’m almost positive that, for example, there’s something lurking around in the code that assigns your user name to a global variable, and then somehow that’s getting kept between requests, so if you keep hitting “refresh” on your browser enough it seems like you’ll get a different users’ session eventually. It’s probably the fault of my SessionPlugin.pm. By the way: don’t use my SessionPlugin.pm! Something is broken, and I’m tired of fucking with it.

None of the other big Wikis like PhpWiki or UseModWiki have user authentication. I’m not even real sure I want user authentication yet, but… I’m pretty certain that I will, or that I’ll want it later. I’ve already devised a simple Perl Wiki in my head which can be backed by a DB and will run cleanly in mod_perl (with any luck). I probably won’t be writing unit tests for anything, though; I’d like to get this done really quickly. We’ll see.

I came home to start work on this Perl Wiki, but then I thought, “you know, my Perl stuff for Emacs doesn’t do auto-indenting as nice as JDE does in Java. I bet it wouldn’t be hard to make it do better indenting.” Next think you know I’m learning how to make major modes. I’ve devised a set of Perl indenting stuff for Emacs which works in my FSF Emacs 21 and works for my indenting style. It only plays with braces, not lining up continued expressions (I think that’d be significantly harder). I’ll post the updates to my .emacs.

So now it’s 1610 and I need to go to sleep. We’re going to Scarowinds tonight at 1900, which means I need to be in the shower by at least 1800, which means I won’t get all too much sleep. At least my Perl indents nicely though. For now.

Friday, 25 October 2002

Working with TWiki

darkness @ 18:02:03

I started playing with setting up TWiki at work. TWiki is not really very pretty code. TWiki will not run under mod_perl using Apache::Registry, though supposedly using Apache::PerlRun is OK. I’m using the latter right now and it seems to be fine. TWiki’s authentication and access controls are supposedly quite advanced and still aren’t very good, IMHO. Sigh.

I ended up rewriting almost all of SessionPlugin.pm so it would not use globals, play nice with mod_perl, etc. Additionally, the TWiki beta I got (TWiki 2002-08-03 I think) was calling CGI::header() after which SessionPlugin would try to call CGI::header() too. If you look at CGI.pm you might notice:

$CGI::revision = '$Id: CGI.pm,v 1.49 2001/02/04 23:08:39 lstein Exp $';
$CGI::VERSION='2.752';

...

sub header {
    my($self,@p) = self_or_default(@_);
    my(@header);

    return undef if $self->{'.header_printed'}++ and $HEADERS_ONCE;

(I quoted the two lines from the top so you could see what version I’m using. Additionally, running Red Hat 7.2’s perl-5.6.1-26.72.3.) Maybe my version is just old, or maybe I missed something in the code where they fudge $HEADERS_ONCE to non-zero value, but it was annoying as shit to see SessionPlugin calling a method that, it seemed to me, it shouldn’t have been calling. (P.S.: CGI.pm is no beauty either.) I also had to patch TWiki.pm to trick CGI into thinking it wasn’t running in mod_perl before it calls the writeHeaderHandlers from plug-ins:

diff -ur misc/build/twiki-beta/lib/TWiki.pm twiki/lib/TWiki.pm
--- misc/build/twiki-beta/lib/TWiki.pm  Sun Aug  4 00:15:20 2002
+++ twiki/lib/TWiki.pm  Fri Oct 25 02:11:41 2002
@@ -290,6 +290,8 @@
     # of other types of page, with expiry time driven by page type.
     my( $pluginHeaders, $coreHeaders );
 
+    local ($CGI::MOD_PERL) = 0;
+
     if ($pageType eq 'edit') {
        # Get time now in HTTP header format
        my $lastModifiedString = formatGmTime(time, 'http');

For your perusal, my modified SessionPlugin.pm. Note that you still need all the other files from SessionPlugin.zip for this to work.

Now that I have SessionPlugin working, I can hit bin/login (distributed with SessionPlugin) from a browser, authenticate once, and it’ll stick with me for the rest of my session. Minor joy masking annoyance. I should write a good Wiki; we’ll just put that on the “to-do list”.

Now I’m working on a good way to edit Wiki pages from Emacs. There’s WikiRemote, but that seems to be unmaintained, and further I worry about being authenticated (which I require). At the bottom of WikiRemote you’ll notice the bit about using w3m and GnuClient (or emacsclient in my case, I hope) to edit text fields in w3m. w3m appears to do cookies and I hope HTTP basic auth, so this will probably be the first thing I’ll try. Another option is XmlRpcToWiki, but this doesn’t appear to use any authentication with TWiki, so I’d end up having to hack that up. Then I think I’d have to hack together some stuff into a mode, though thankfully xml-rpc.el exists.

Wednesday, 23 October 2002

Emacs: How do you want to be distracted today?

darkness @ 04:30:32

Perhaps unsurprisingly, my coding was side-tracked by some work on Emacs.

Really it started with a customer call about a WAN turn-up that’s supposed to happen next week (*snicker*). Then I remembered the network things that were on my plate so I tried to tackle them first. Unfortunately the requisite documentation was at work, and by then it was too close to deadly traffic time for me to voyage out of my apartment.

So after I handled the customer call/interfacing with telco, I was going to start coding. I had previously decided that I needed to extend java.nio.ByteBuffer, which wasn’t going to be pleasant. ByteBuffer has no interface that defines many of its methods, is an abstract class, and has two static constructor methods. So this means I have to make a concrete proxy class and override the static constructor methods to return my proxy class. ByteBuffer has plenty of methods, so I thought “hey, why can’t JDE make the proxy class for me?”

[Laughing ensues.]

It actually kind of does what I want. (It may do exactly what I want, but I’ll be damned if I can find where. I’ll check in to that in a minute via Google, actually.) It has a “extend abstract class” wizard. This makes little template methods for every abstract method in the superclass. Still, I will have to go into each method, delete the JDE default statement (which is usually something like “return null” or “return false” for methods which return; I’d imagine it’s non-existent for a void method), and then enter in the proxy dispatch. Something that should be automated.

Then I find that JDE is inserting Javadoc over each of the methods. I have no desire to delete this. It’s also not doing formatting of the methods the way I like. Unacceptable. I tracked down most of what I need to modify to jde-gen.el. The formatting was easy to fix. The method Javadoc, however, is part of the whole method template, which is basically a list of strings eventually parsed by something called “tempo”. I didn’t really want to quote this whole thing verbatim into my .emacs, so instead I wrote a function to do a regular expression search-and-replace on all strings in a list. I don’t think the function I came up with might be the right thing to do, since I think it creates a whole bunch of intermediate lists, but it does appear to work. Then I had to copy the contents of the :set property from the defcustom statement for jde-gen-method-template, since a simple setq of the property wasn’t cutting it.

After all this, I no longer generate Javadoc, and my methods are formatted the way I like them. You can see the results in (yet another update of) my .emacs.

I have what I believe to be a second degree burn on my right hand, on the top of the hand between my thumb and first finger, or so. It was kind of disturbing when I quickly stuck a Band-Aid on it last night (I had to finish dinner!) only to pull it off later… with a patch of skin on the adhesive part. Whoops. I’ve got gauze on it now, and I think I look like I have a much more serious injury than I really do. I feel like a gimp, though, since I’m doing everything one-handed – including showering. (Get your minds out of the gutter. Besides, it’s barely big enough for one hand.)

Tuesday, 22 October 2002

Preemptive log entry

darkness @ 14:58:53

I’m logging in the morning rather than the night since I’ve forgotten to do it the past few days.

Reverse engineered a simple program the other day. They appeared to have left debugging symbols in and didn’t optimize the program, so this was real easy. I used gdb to print out the value of some symbols and do some disassembly, but I preferred the output of objdump -d since it printed the opcodes with the instructions. It took me a few to discover this, but with ELF binaries on Linux/x86, you can subtract 0×08000000 from an address and gets its offset within the file, it seems. Spiffy, that.

Played with IntelliJ IDEA. It’s a cool editor/IDE, works in Linux, is probably Pure Java, and is fast. Interface was decent, though it started doing some weird stuff a time or two WRT those windows that pop out from the sides. It a preset key map for Emacs-like keys, and a lot of good indentation options. However, it does not do tab width independent indenting! (I suspect that “tab width independent” should be hyphenated.) So I will stick with Emacs.

Tried out Xrefactory for Emacs as well. Pretty spiffy, worked reasonably well, but it wanted to put its menu in the global map, which meant it was in every buffer. I’m posting my Xrefactory menu patch as well as updating my .emacs. Note that the patch only applies to FSF Emacs, if the code I commented out from it is to be believed. (Apparently XEmacs builds menus in a different way? Unsurprising, perhaps.)

Haven’t done much coding. Feeling a bit under the weather. Did go investigating uninterruptable power supplies (UPS’s) for work. Found a few good places. APC’s web site has some calculators. You can use the one where you type in Watts (or VA, a.k.a. volt amperes) and how long you want it to last and it’ll make suggestions. Alternatively you can just go to a product line page and it should have a combo box at the top where you enter in how many Watts (or VA) you need to support and it’ll show you all the UPS’s that will handle that load with their expected battery operating time. Best has become Powerware apparently. If you go to their products section they have a single phase UPS selector that is even nicer than APC’s. Moreover I hear tell these UPS’s are probably better and have more features (like actual power cleaning kind of stuff?) than the APC UPS’s of comparable price. Indeed they recommended a PW9120 with some extra battery packs. I recommended this to my boss. If you’re looking for some information on VAC, Watts, and UPS’s in general, you can try a UPS article on extremetech.com.

Hopefully going to do some coding today since a meeting I had at work was canceled (and I was barely informed of this cancellation in time to not waste part of my day trying to make it).

I’ve become interested in another random web log. It makes me nostalgic, and worries me some too. It’s always interesting to get insight into how other people live. (If you’re wondering, here’s the last web log I was interested in.)

Next Page »

Powered by WordPress