Older blog entries for dalke (starting at number 22)

How about a Python solution to the Scheme problem? Of course, I made a more general solution allowing any number of "f"s :)

class f:
    def __init__(self, s):
        self.s = s
    def __add__(self, other):
        return Merge(self, other)
    def __getitem__(self, i):
        return self.s[i]

class Merge: def __init__(self, left, right): self.left = left self.right = right def __getitem__(self, i): return self.left[i] + self.right[i] def __len__(self): return min(len(self.left), len(self.right)) def __str__(self): s = "" for i in range(len(self)): s = s + self[i] return s __repr__ = __str__ def __add__(self, other): return Merge(self, other)

>>> f("Js nte ceeWnae")+f("utAohrShm anbe") Just Another Scheme Wannabee >>> f("123") + f("ABC") + f("abc") + f("!@#") 1Aa!2Bb@3Cc# >>>

This uses Python 1.5.2. With Python 2.0 I would probably do

class f(UserString.UserString):
    def __add__(self, other):
        return Merge(self, other)
An uglier version of __str__ using 2.0 tricks is
def __str__(self):
    return "".join(x[0]+x[1] for x in \
                    zip(self.left, self.right))

I could probably cut the line count in half if I got rid of the generality, so no fair doing a direct line count comparison between this and the Scheme solutions!

jdybnis asked:
Does anybody have any others [points to regexp package]?

There's pcre at pcre.org. Python 2.0 includes the sre regexp library. There are a lot more. A quick web search also found Regex++ and the ORO library for Java which is part of Jakarta. Then there's my bastardized regular expression converter to the mxTextTools state machine as part of Martel. (Bastardized since it doesn't do full backtracking.)

I wrote an article for Dr. Dobb's Journal. It's in the January 2000 edition, which I understand is starting to arrive in the mail. Soon, yes, you too will be able to own a copy of words written by yours truely! As an added bonus, this is their 25th year anniversary edition.

3 Dec 2000 (updated 3 Dec 2000 at 21:05 UTC) »
deekayen:
You can't have safe sex when you're having sex with someone infected with HIV or AIDS. There are pores in latex condoms. Sure, you can't see them... they're small... but HIV is still 1/100 the size of the pores in the condom and can easily slip right through.

This statement is completely incorrect. Here are some STD virus sizes from The Big Picture Book of Viruses:

  • Retroviridae (HIV) are spherical; 80-100 nm in diameter
  • Herpesviruses (herpes and cytomegalovirus) are spherical; 120-200 nm in diameter
  • Papillomavirus (from http://www.uct.ac.za/depts/mmi/stannard/papillo.html) are about 550 nm in diameter.
  • Hepadnaviridae (Hepatitis B) are filamentous; 40-48 nm in diameter
  • Flaviviridae (Hepatitis C) are spheroidal; enveloped; 40-60 nm in diameter
  • Poxviridae (Molluscum contagiosum) are ovoid, or brick- shaped; 140-260 nm in diameter; 220-450 nm long

So Hepatitis B and C are both smaller than HIV, and the ratio of smallest HIV to largest Molluscum contagiosum is still less than a factor of 4. (The volume is about a factor of 100, but that's for the extreme case and you're talking about pore size.)

Second, what is the pore size of a condom and how important is that in transmission? I found claims like yours which state it as fact but don't back it up. On the other hand, sites like http://www.fda.gov/cdrh/ost/reports/fy98/INFECTION.HTM and http://hivinsite.ucsf.edu/topics/condoms/2098.32ca.html point out the results of tests on the permeability of condoms and find them effective barriers. Yes, the pore size is larger (seems to be about 1000nm if I read the reports correctly) but pore size isn't the only consideration on transmittability. These are back up with theoretical, laboratory and epidemiological studies.

So you are incorrect both on the relative sizes of the viruses and the importance of pore size on transmissability of viruses through condoms. Unless you have evidence to back yourself up?

Update

*Chagrin* Oops, I misread the "1/100" and thought deekayen said the HIV virus was 1/100th the size of other viruses. He did not say that. He said they were 1/100th the size of the pores in condoms. The numbers I found suggest it's more towards 1/10th than 1/100th, but not enough to be seriously wrong on that account.

Still, there have been tests upon tests which show that condoms are an effective means to prevent STD infection.

My apologies for the misinterpretation.

Today's my birthday (okay, it's tomorrow in most of the world, but not according to my watch :). I am now 30 years old. Oh my.

As my present to the world, I released Martel- 0.2 today and put up my poster from BOSC.

The short description is that it's a parser generator written in Python and designed for stateful *regular* grammers, as compared to context free grammers where you can lexically tokenize with very little knowledge of where you are in the file. This is very handy when parsing files designed to be read by humans or hand-written parsers (that is, written by people with no knowledge of recusive descent).

I use a modified version of a subset of the Perl5 regular expression language to describe the file format. I take the expression and convert it to a table for mxTextTools, which parses the string and returns a taglist describing the file as a tree. (?P<named>groups) are used to label interesting nodes in the tree.

The tree is traversed in prefix order and sent to the callback object as events. I reuse the SAX API for the event names and meanings, so I can leverage off of a lot of existing code and ideas, like DOM.

I'm pretty proud of it. It took a lot of thought and work, and the result is quite nice, and I haven't come across anything like it elsewhere. (Pointers anyone?)

Oh, I see I forgot to mention the license. It's the old Python license "with the serial numbers scratched off", which is basically BSD but without the adversiting clause. Enjoy!

This morning - early morning - Mitch and I hiked up Atalaya Mountain (7 miles round trip, from 7340 to 9121ft elevation). It's the biggest mountain closest to Santa Fe, and is the boundary between Sante Fe and the watershed. From the top you get a great view of the city and all up and down the Rio Grande valley.

This was the first non-easy hike I did since the forests reopened after the fires. I've done the hike during the day a couple of times, but always ended up too hot and tired to really enjoy it. The problem being I was doing it during the day, in summer, in a desert, on a trail which is only 1/4th under the trees. (Hint: take lots of water.)

Instead, I figured on doing it at night, which would be cooler, with no need for sun block, and with no chance for an afternoon thunderstorm popping up while on the trail. All good things. I figured the best time to go would be to make it to the top at sunrise, so I could see the city and the valley with all the lights, and also see the change as the sun appears. I'll also point out I chose yesterday because it's a couple of days after a full moon, so the still bright moon will be high in the sky before dawn.

It's about 2 hours up to the top, in the daytime when you need more breaks to drink and cool off. We started about 4:20 for a 6:04 sunrise, and made it just in time. As we climbed up, we were surprised to see the lights of Los Alamos and White Rock in the distance. Climbing even higher and the light of northern Albuquerque appeared in the south-west. The moonlight did help a lot, but we walked off the trail a few times. The timing worked out well since the sky was getting that dawn glow when we did the last bit of trail, which is the most complicated.

At the top. Sun slowly rising up. Watching the rose tipped peaks across the valley. Looking towards Sandia Mountain, we see part of the horizon sky still dark, with no hint of red. Turned out to be the shadow of Atalaya. Coyotes howled handshakes (it seemed :) at the base of the mountain. Rising higher, the new, now golden light brought out the relief of the far mountains. You could see the bright street and highway signs directly downlight - the ones with retro-reflectors in them.

Gorgeous. Highly recommended. But might not want to do it in winter with snow on the ground and rather sub-freezing temperatures. Also, the peak had excellent cell phone coverage.

Heard a neat trick yesterday. A friend of mine is starting grad school this fall. She's paying for her own schooling, but instead of paying the school directly, she started her own company, which costs about US $100 to do. The company is paying her to go to school. The university regards that as corporate sponsership, which means she (or rather, the company) gets some copyright and patent protection - students don't really own their graduate work these days :( - as well as some financial and other perks.

I need to open a business account for my LLC. A few weeks ago I went to about 6 banks asking them about their rates, available services, etc. and to see environmental aspects, like if they were crowded, how the staff dealt with me (a long-haired freaky - oh, wrong song) and how far the walk is from my place to the bank. I do have the advantage of having about 10 banks and credit unions within a 30 minute walk from my apartment.

There's one I liked, so today I want back to open the account, bringing with me my state tax id, my articles of organization, and a check from my company's first gig.

They wanted my EIN (employer identification number?), which is the corporate version of a SSN. I told them I'm an LLC with only one person, who is the sole owner, so I don't need an EIN - my SSN is good enough. The bank representative said, no that's only for sole proprietorships. So I walked back home, went to www.irs.ustreas.gov and dug up the forms. SS-4 says

An LLC with a single owner can be an association taxable as a corporation or an entity disregarded as an entity separate from its owner
There is only one owner, who has limited liability, and doesn't to be taxed as a corporation, so I don't need an EIN. I called my accountant to double check, and they agreed with me.

So I drove back to the bank and arrived at 4:32. They were closed. It's Y2K and banks still have banker's hours - some day a service economy would be nice.

So now I have an accountant, and a lawyer, and an LLC, and contracts. Guess that makes me a running-dog capitalist?

In other news, I called for jury duty in the local petite court. I've got meetings and conferences to attend, so I checked to see how flexible they are. They are.

One of the conferences is the Bioinformatics Open Source Conference in San Diego. I want to give a talk on Martel, my regular language scanner generator. There are many bioinformatics file formats which are regular but which cannot easily be tokenized by looking at a word - you need state. (Eg, the word "gene" can mean 4 different things in the same file.) Lex/yacc gets pretty complicated when you start passing state data back and forth, so I'm working on a way to simplify things. Problem is, if I want to get a talk, I should have code ready.

My Mom graduates at the end of summer with her bachelor's degree in EE. Go Mom!

Aargh, the battery on my laptop (a Thinkpad 600E) is busted. I've only got about 30 minutes of use before it wants to shut down. I used to get 2 hours. :(

This is the last week for me at NCGR. I've been feature complete since last Thursday, which means this is also the week of documentation. Blech. Doc'ing the technical parts is easy - my problem has always been doing the higher level docs which explain the intent.

There's a quote I came across a couple of years ago. Can't find it now but perhaps someone here can help. It something like "software should be written so you can enjoy reading in the evening in your comfortable chair while sipping a glass of wine." This is a backwards translation from my memory, which is of someone at night wearing a smoking jacket while sitting in a large, soft chair in front of a fire, glass of wine at hand, and reading source code as if it were a novel.

I tried searching for it on-line, but there wasn't enough context to prevent loads of false positives. I tried using google but my browser wouldn't bring it up. Me being the suspicious sort, I telnet'ed elsewhere to do an nslookup then tried google's IP using my browser. That worked. Hope that doesn't say anything bad about my ISP.

Complaint coming up.

I must be really paranoid about my code, or something. decklin presented the following:

echo -n "Entries mentioning '$2': "
wget -qO - "http://www.advogato.org/person/$1/diary.xml" | \
   awk "/<entry>/ {s=1} /$2/ {if(s) n++; s=0;} END {print n}"
I know it's meant to be a one-off bit of code, but I don't like seeing the bug/security problem in it.

Suppose you want to search for "1//0". This gets expaneded to the awk program /1//0/, which is legal syntax. You'll be surprised at the results and it will be a bit annoying to track down.

The problem comes in once you've used the program enough to feel comfortable about what it does - so you make it available as part of some library, or you copy&paste it into another script, or you use it in a web search, or ... That bug is just sitting there waiting to trip you up. Perhaps even someone can use it as an explot, since some awks (gawk? nawk?) let you make shell calls.

The only way you can reliably pass information to other programs with the shell is as strict ARGV parameters. Don't embed it as part of a larger, eval'able string, since it's hard to escape all the special characters. Or if you do, don't promote it as a good practice.

End of complaint.

And it's my fault for offering to do a security review of one of my client's CGI scripts, after the first 3 I looked at all had these sorts of problems in them.

13 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!