::::: : the wood : davidrobins.net

My name is David Robins: Christian, lead developer (resume), writer, photographer, runner, libertarian (voluntaryist), and student.

This is also my son David Geoffrey Robins' site.

SCons: adding a post-processing step

Technical ·Monday November 16, 2009 @ 22:58 EST (link)

I got annoyed by this warning generated by compiling my project's Flex scanner:
flex --header-file=scanner.h -DECHO= -t scanner.l > scanner.cc
g++ -o scanner.o -c -ggdb -Wall scanner.cc
<stdout>: In function 'int yy_get_next_buffer()':
<stdout>:1340: warning: comparison between signed and unsigned integer expressions
I looked it up and it turns out that although it's not fixed in Flex itself, it is logged and fixed as Debian bug 466793 in the Debian package: the YY_INPUT macro in the generated code (scanner.cc here) should have size_t in one place where it has int. Since my system is Gentoo, not Debian, I couldn't (consistently) install the patched Flex, but I could patch the generated scanner.cc file before compilation in the SCons build file, by adding a post-processing step to the action list for .l (Flex lexer definition) files as follows:
c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
cxx_file.cmdgen['.l'] += [
 r"perl -pwli -e 's/^(\t\t)int( n; \\)$/$1size_t$2/" +
 r" if /^#define YY_INPUT/ .. /^#endif/' $TARGET"]
Now the relevant build steps become:
flex --header-file=scanner.h -DECHO= -t scanner.l > scanner.cc
perl -pwli -e 's/^(\t\t)int( n; \\)$/$1size_t$2/ if /^#define YY_INPUT/ .. /^#endif/' scanner.cc
g++ -o scanner.o -c -ggdb -Wall scanner.cc
I have, of course, glossed over exactly how I knew to call SCons.Tool.createCFileBuilders, and that adding to cxx_file.cmdgen['.l'] would work and do what I wanted; as it happens, I had to browse the sources for that, although it's all in the inline documentation. On my system the SCons modules are under /usr/lib64/scons-1.2.0/SCons. It turns out that cxx_file is a SCons Builder.CompositeBuilder object, whose cmdgen field is a Builder.DictCmdGenerator whose values are SCons action lists. It might be better if it were not necessary to access the un(py)documented cmdgen field (one might assume that the add_action method would do what I wanted, but unfortunately it replaces the old action, that of running Flex in this case).

It's sufficiently elegant for a postmodern high-level language.

Books finished: Night of Power.

DVDs finished: Harry Potter and the Prisoner of Azkaban.

CCW training with "University Defenders"

News, Guns, School ·Sunday November 15, 2009 @ 17:07 EST (link)

Some UW students were being robbed around the University District area, both in their residences and on the street, and Stanley Luong and a few others had decided to carry concealed weapons to prevent being robbed again (article from The Daily). I don't blame him in the least. Where he got into trouble was starting a Facebook group with "vigilante" in the title and description, talking about going after or attempting to decoy potential robbers; it was deleted by Facebook and later reappeared with the less provocative title University District Defenders. Richard Walker, an NRA-certified instructor with his own firearms training company, Black Dawg Partners, offered the group a free CCW (concealed carry weapon) training class, and Champion Arms in Kent donated classroom time. I decided to attend to meet the group and see what the training was like. The range isn't hard to find, and it's not that far away: I-405S to WA-167S, get off on E. Valley Hwy., and follow it to 18801: about 30 minutes, but surely double that in traffic. I got there exactly at the start time, 1230, but most people were late. There were six UW students and another interested party, and two trainers (Richard and David).

Richard is extremely well qualified and was friendly and a good teacher, making his points clearly and without talking down to anyone. I confess I had my doubts about him before we met—I was worried that he would encourage the group in their early "vigilante" ideas, or try a hard sell of more advanced courses (this class was free—"free" always makes me suspicious), or would put the group down unnecessarily. None of those happened: he came across as serious and knowledgeable and any "vigilante" ideas melted away as he went over firearms safety, best practices, local laws, and some court cases. The rest of the group went down to the range afterward, but the class took four hours, longer than I'd expected (and told Honey), so I left right after it finished and got home at around 1700.

This is the message Stanley Luong sent to the Facebook group after the event:
Thanks to everyone who showed up and helped out. The day began at 12:30pm with Richard teaching safety guidelines and handling techniques. We had a break to give an interview with KIRO 7 and the Seattle Times. After that, we continued our meeting with Richard leading the discussion on legal issues, ramifications, and several case studies of self-defense scenarios. Overall, yesterday was a great forum in raising our awareness of gun rights and safety, and ended with us shooting at the range. Special thanks to Black Dawg for their pro-bono training and Champion Arms in Kent for hosting us.

Next time, we will try to have an event closer to campus. If we had one on campus, there would definitely be a large turnout but we would all have to go unarmed because of the regulations there.

This is what I sent to msgun Monday:
I attended—free training, not too far way (~30 mins), what's not to like?, plus I wanted to meet some of the people in the group.

First, the group has indeed toned down. There was some hare-brained scheme proposed in the Facebook group to cruise around with a "decoy" wearing an iPod and several other shadowy figures with nonlethal weapons ready to pounce, so I did my best to shoot that down (no pun intended) and point out its many flaws (you're not the police, you're not trained, if you're in fear of grave bodily injury you don't want to bring anything less than deadly force, you could be hurt/killed, you could hurt someone else, jail, civil court costs, even with a "good shoot", etc.). The original poster agreed that his was a foolish idea.

Second, this training outfit looked legit—Rick Walker (http://www.blackdawgpartners.com - not the most pro site in the world though) is a class act and knows his stuff, ex-military (weapons expert), certified as instructor by several reputable groups, etc. He teaches various courses including the Utah permit course. He went over some basics of weapons and CCW with a PowerPoint deck in a classroom at Champion Arms (they offered the room free)—starting from Cooper's 4 rules, then things like where you may or may not carry, Castle doctrine, reacting to scenarios—run if you can, call 911 if you're not in immediate danger; importance of practice; all stuff I've seen but nice to have it all in one place. He went over some cases, what people did, what they were convicted of, and their civil costs. I can reproduce the quiz he passed out before the class and discussed if people want. I believe it was sufficiently sobering to cause the "Defenders" to change their course, which is great: more armed good guys on the streets that know the law and practice with their particular defense weapon is a good thing.

I also talked to him about doing training for a Microsoft group; he said he could do something similar (a basic CCW class) for just cost of gas and materials; perhaps if we were interested he could give us a rate on doing a Utah permit course or something else for those interested.

The session Sunday got the group some better coverage; the image now should be of a group of serious people armed and able to protect themselves and others from grave bodily harm.

DVDs finished: Butterfly Effect: Revelation, Harry Potter and the Sorcerer's Stone, Harry Potter and the Chamber of Secrets.

A comfortable violence

Political ·Friday November 13, 2009 @ 18:56 EST (link)

This piece is by Elliott Prechter, via the Austrian Economics Discussion list at work. I'm forever curious as to what makes non-libertarians, especially big-government supporters, tick. Why are they not libertarian? What do they have against freedom? I tend to get two kinds of answers: one involves greed, and the other involves fear, sometimes for themselves as Elliott describes so well below, and sometimes for hypothetical groups, frequently "poor people", who will imaginably (usually counter to fact) be so much worse off in a truly free society.

I think a lot of people don't want liberty. At a deep level, many voters want good, kind, motherly totalitarianism—so they can feel safe and secure. I understand where they're coming from on an emotional level, but it's just that I don't believe such a thing as "good despotism" exists, or has ever existed. Freedom isn't perfect, but history has shown it to be the best system we've got—as Winston Churchill said "Democracy is the worst form of government except all those other forms that have been tried from time to time."

As an example of many people's natural draw towards big government, many survivors of Communism—who faced imprisonment, poverty, starvation, death—said they still believed the system to be good, but just that the people in charge just happened to be evil and greedy. In their minds, with the right people in charge, despotism would have been paradise!

I think one fundamental reason that despotism has never produced paradise is that it is a system based on coercive violence rather than voluntary action. Violence will tend to escalate due to the perverse incentives in such a system. For example, in a voluntary system starting a business, employing people, and producing wealth is beneficial to the self. Under Communism, this incentive does not exist. However, the incentive to seek bureaucratic control over others—by entering the government—is the only path towards wealth and individual "success". So such a system will encourage more and more corruption because corruption is so immensely rewarded, and virtuous activity (i.e. wealth producing) is punished. It is ironic that the insatiable desire of individuals to better their own lot (which is the common cry against freedom and capitalism) is what causes despotism to fail, and conversely it is this same incentive that powers the immense wealth-producing capacity of capitalism. The only difference is that in the former case force is chosen as the primary means of dealing with one another, whereas in the latter all human interaction is mutual.

The U.S. is very far from despotism of course, but we can still clearly see elements of the "escalation of violence" already in effect as government power grows. Take Goldman Sachs as an example. Under a voluntary, non-coercive system, they would be spending their time innovating and researching to produce better products, which would in turn help everybody and increase net wealth. However, since the US has a large non-voluntary component to our society (namely the massive U.S. government), they are instead using resources, time and effort to get "friends" into government that can bend the rules in their favor; such rule bending (and even outright theft) destroys wealth rather than creates it. This trend—rewarding those who seek to use violent means to control others, rather than rewarding those who work hard and produce wealth—is dangerous for the long-term health of any country. I don't particularly mean to single out Goldman (it's just a great example at present) since this type of corruption occurs all over the world in every government—some more than others.

My main point here has nothing to do with any particular specifics of any political party's agenda—the battle between freedom and despotism is not primarily about details such as healthcare, or firearms, or abortion, or education, or any other specific debates and issues that divide the nation, but rather primarily that the long-term effects of institutionalized violence are to destroy wealth and prosperity, thereby rendering all specific political debates about how to "split the pie" meaningless once everyone is equal in poverty.

A key element of this piece is 'I don't believe such a thing as "good despotism" exists.' Whenever people rule over others, even elected by a system such as ours, they will use violence for advantage. The best system is one where power is fully distributed to individuals and all transactions voluntary, with use of force limited to stopping or punishing initiation of force. Rather than a central government guaranteeing a Republican form of government, how much better if the states made a confederation to mutually guarantee to each other a non-coercive form of government?

DVDs finished: The Puppet Masters.

EOTech 512.A65/1; dead fridge

News, Guns ·Thursday November 12, 2009 @ 20:15 EST (link)

My EOTech 512.A65/1 "red dot" holographic weapon sight arrived today, and M-Pro 7 gun cleaner (32 oz. bottle—seemed the best value for money size that I could actually use) arrived yesterday. It had been delayed a long time: the first time the gun cleaner leaked and they returned the entire package; then they claimed they were out of that size, but managed to find a bottle and send it to me. I'd ordered both on October 20th.

I mounted the sight on my AR-15; it was quite simple, and just required a (provided) Allen key. Range test coming soon.

Our fridge gave out yesterday (maybe earlier?): we moved some dairy to the freezer but it was having trouble keeping things toward the front cold. They sent a guy to fix it in the morning, but they said they'd be there at 0900 and we had to call at 0930 when they hadn't showed yet, but they arrived right after that. We lost some milk, maybe some (formerly) frozen waffles, and some spaghetti sauce. We called the apartment office on the "It doesn't hurt to ask" theory, asking if they would compensate us for a claimed $30 loss; they said they'd give us a $50 credit. Color me generally impressed with Avalon at Bear Creek (Avalon Bay Communities, I suppose).

I stayed home for the fridge repair guy, and I was going to take Honey to school today since she's still feeling unwell, but she decided she hadn't studied enough for the test and would make it her dropped test in that class.

Books finished: Stock Market Wizards.

Cases in Constitutional Law #3: taxpayer rights further trampled

Law ·Thursday November 12, 2009 @ 00:48 EST (link)

[] Flast v. Cohen (1968): A federal taxpayer challenged the Education Act of 1965, under which Congress had spent about $1 billion, $60 million of which eventually went to religious schools. This would have been an excellent chance for the court to be consistent with Frotheringham, and rule against the taxpayer, or to use its power of judicial review to strike down any federal education legislation as unconstitutional, not being within the enumerated powers. Instead they found a way to wriggle around Frotheringham (which Harlan called out in his dissent), possibly due to anti-religious bias, passing the case back to the lower court to examine it on merit, but at least they reopened the door for taxpayer suits against unconstitutional spending.

[] Valley Forge Christian College v. Americans United [for Separation of Church and State, Inc.] (1982): The Department of the Army had closed the Valley Forge General Hospital, and declared it surplus, to be sold by the Department of Health, Education, and Welfare (HEW). The property was appraised for $577,500 but the Secretary of HEW computed a 100% public benefit allowance, permitting Valley Forge Christian College to acquire the property "without making any financial payment for it", but requiring it to "use the property for 30 years solely for the educational purposes described in [their] application." The respondent is challenging the transaction ("conveyance") "on the ground that it violated the Establishment Clause of the First Amendment." Oh what a tangled web we weave, when first we start showing favoritism to special interest groups!

To be consistent with Flast the court would clearly have to rule in favor of the respondent; and this would make sense: the government should not have been in the business of either acquiring (or managing) property not used for strict legislative function or for subsidizing private ownership of same. But they reversed the lower court's ruling in favor of Americans United, on the basis that Americans United did not have standing:
At an irreducible minimum, Art. III requires the party who invokes the court's authority to "show that the personally has suffered some actual or threatened injury as a result of the putatively illegal conduct of the defendant," Gladstone, Realtors v. Village of Bellwood (1979), and that the injury "is likely to be redressed by a favorable decision," Simon v. Eastern Kentucky Welfare Rights Org. (1976). … But the "cases and controversies" language of Art. III forecloses the conversion of courts of the United States into judicial versions of college debating forums…. The exercise of judicial power, which can so profoundly affect the lives, liberty, and property of those to whom it extends, is therefore restricted to litigants who can show "injury in fact" resulting from the action which they seek to have the Court adjudicate.
The court claimed that this case was different from Flast because:
Unlike the plaintiffs in Flast, the respondents fail the first prong of the test for taxpayer standing. Their claim is deficient in two respects. First, the source of their complaint is not a congressional action, but a decision by HEW to transfer a parcel of federal property. Flast limited taxpayer standing to challenges directed "only [at] exercises of congressional power." See Schlesinger v. Reservists Committee to Stop the War [1974] (denying standing because the taxpayer plaintiffs "did not challenge an enactment under Art. I, § 8, but rather the action of the Executive Branch").

Second, and perhaps redundantly, the property transfer about which respondents complain was not an exercise of the authority conferred by the Taxing and Spending Clause of Art. I, § 8. The authorizing legislation, the Federal Property and Administrative Services Act of 1949, was an evident exercise of Congress' power under the Property Clause, Art. IV, § 3, cl. 2. Respondents do not dispute this conclusion, and it is decisive of any claim of taxpayer standing under the Flast precedent.

Some precedents are perhaps better observed in the breach than in the observance, including this "test for taxpayer standing." The fact that the originating act was executive in nature does make the court any less able to rule on it if it violates the Constitution. Any taxpayer should have standing in any case involving the smallest amount of their money (despite the inconvenience to the court), and the presumption should be that spending less will redress the wrong by lowering taxes by the amount saved (even though in practice government tends to spend anything "saved.") While there are more egregious violations, stopping this gift of taxpayer money and requiring the government to sell the property for fair market value (and better still, remit the increase as at least a token tax reduction) would have set valuable positive precedent.

Three justices dissented and wrote dissenting opinions, holding that the Establishment Clause was written for cases of precisely this kind.

Since this concludes the first chapter (The Supreme Court and the Nature of the Constitution) and since I've been a long time finishing this entry, and the last case is somewhat long, I'll resume with chapter 2, The Legislative Branch in the next installment.

Books finished: The Knight.

Why are the looters so much more ambitious than the looted?

Political ·Tuesday November 10, 2009 @ 20:16 EST (link)

NS phrased this question: "Why are the looters so much more ambitious than the the looted? The government takes your money (and mine) and just gives it away! Doesn't that [upset you]?"

My answer to the first question is that groups that receive entitlements (redistribution, takings, other people's money), after a while, start to believe that they deserve them. They even believe things like their benefits are coming from the government (rather than their fellow citizens). That, dammit, society owes it (welfare, social security, farming subsidies, health care, etc.) to them! It's their right! (No, it's not: educate yourself about positive and negative rights; there are no rights that involve coercing someone else to do something for you).

But these special interest groups are well-funded. They have your money, after all. And they (usually an lobbying organization created for the group, like AARP, or La Raza, or the AMA) have one primary goal: increase their entitlements. And it's very easy for them to manipulate "their" people by saying their entitlements will go away. Scared people are one-issue voters, special-interest voters, one-dimensional voters. But then voting for a representative that will be empowered to take and spend your money is a one-dimensional—and Hobson's—choice anyway.

There are many such groups, all of which can be scared into voting for whoever promises (depending on the choices) to maintain or increase their entitlement. The union of these one-issue voters that want handouts will vote for whoever promises them the most (see: Tytler).

The remainder—the few people that think theft is wrong, that voluntary trade is only moral economic interaction in a civilized society—isn't a majority so continues to get robbed.

As to the second question, of course it upsets me—robbery is initiation of aggression, which should not be countenanced. That's why I'm libertarian.

DVDs finished: The Dark Knight, Duplicity.

SCons: I am a convert

News, Technical, School ·Sunday November 8, 2009 @ 15:34 EST (link)

The make utility is venerable. It's also rather simplistic and somewhat crufty. The easy things are easy, but sometimes the hard things are impossible. Despite the many features added to the most common instance of the tool, make GNU make, it becomes inconvenient for all but the simplest projects. So I hunted around for something better for my UW compilers project.

At Hilton (c. 2004), I built a Perl tool—hmake, Hilton make—that leveraged the power of Perl, meaning that all hmake did was run the Perl program Makefile.pl if it was found, after minimal setup (I know CPAN distributions use Makefile.PL but uppercase PL seemed gauche and inconsistent). Makefile.pl was supposed to use the hilton::Make module and provide it a list of targets/dependencies, possibly including Perl code, which would be examined and built optimally depending on what had changed since the last build, just like make. Except hmake had Perl available to do complex target mappings (e.g. database definition files like gst_membership.cfg to perl modules like GstMembership.pm) which weren't possible with standard make. It could also do the usual install tasks etc.

SCons ("A software construction tool") (FAQ) has taken this to the next level. It is built using Python, not Perl, which is fine since I've been writing a few utilities in Python lately anyway, and the language is growing on me. It seems to be actively maintained and reasonably well documented (although apparently the (long) man page is kept more up to date); class documentation; there is also a wiki where I found several helpful nodes including one about the equivalent of make .PHONY targets, e.g., making scons run tests (replacing make test). And the source code is eminently readable; I was reading a fair amount of it figuring out how it all worked.

It is based around the concept of Builders, objects which produce target files from sources. They are very flexible, and it comes with a good number of useful defaults. I thought I would need to build flex and bison builders, but it comes with them, including analyzing the command-lines for --defines and --header-file and adding those to the target list. I did have to tweak it to understand that my scanner (.l) and parser (.y) files create C++ (.cc), not C (.c) files (I could have used use .ll and .yy, but I reject those on principle: the source is still the same type). I also added the Bison-generated location.h and position.hh files using a variant of this recipe. SCons already has an include-file scanner (no more messing around with gcc -MMD etc.), but needed to know how location.hh and position.hh were generated ("emitted" in SCons-speak) so it knew to build the parser before files that included those files.

I will not be using make in future projects unless compelled to. Call me a fan, and a devotee of scons, and kudos to the developers for a great tool.

Honey sick with 'flu

News, Technical, School ·Sunday November 8, 2009 @ 11:38 EST (link)

Honey had a bit of a temperature yesterday, but it got worse today: 100.9° and a bad cough; I picked her up some cough medicine and TamiFlu™ this morning. The cough medicine will make her sleepy, which should let her get some rest despite the wracking cough. We're not sure if it's H1N1 or regular 'flu. And I figure it's just a matter of time until I have it too.

I went down a bit of a rathole in my CSEP501 compiler project: I wanted to be able to replace nodes easily, without chasing references, so tried to use handles (pointers to pointers), but that led to a lot of hassle with my use of dynamic_cast<> and in other places too, so I used svn merge with a reverse revision specification to back out those changes. Lost some time, but learned a few things, and I'm still almost through type checking and propagation. Earlier I had a partner, but since I'm interested in building on a large number of extensions and he doesn't have the time for it right now, we agreed amicably last week to go our separate ways from project part three (ASTs) onward, and so notified the instructor.

I did some work on the torrent-mover to handle movies, and also wrote a scan option that's about equivalent to "Video Manager" in the MythTV menu: it recreates the (videometadata) database from video files present. I had a bit of trouble with Unicode characters in filenames: in particular, "à" came in as U+DCE0, which I found out is from the U+DC80-DCFF range, meaning a bad character (in the source encoding of the filename—probably taken as ASCII) which was put into the lower 8 bits when converted to a Python internal (Unicode) string. Replacing it with the intended U+00E0 fixed most of the issues. (Caused by the Law and Order episode "Folie à Deux.")

Books finished: Economics In One Lesson, Computer Science and Perl Programming.

DVDs finished: X-Men Origins: Wolverine, Sex Drive, Psycho, 12 Rounds, Prom Night, Changeling, The Bank Job, Fired Up!.

rTorrent patch, periodic torrent download

News, Technical ·Wednesday October 21, 2009 @ 03:58 EDT (link)

I patched rTorrent to fix a crash on setting a torrent to erase on finishing. There was an existing ticket, so I added my patch to it. rTorrent is an ncurses BitTorrent client that works well under GNU screen, but it's best features are a programmable API (XMLRPC over SCGI) and use of directory monitoring (drop a .torrent file in a directory, it'll start downloading) and status files (it can easily be set to create a symlink with the name of the torrent file + .finished, pointing to the download, when the download is complete).

rTorrent is the largest piece in automating weekly downloads of TV shows that we watch; the rest is a few scripts—Python, not Perl, to branch out a little. I also have a perl program that will rename and file downloaded episodes according to their names from epguides.com; I'll connect it up to auto-rename finished downloads. The other piece of the puzzle is the isoHunt JSON search API. Three programs need finishing:
  1. grabber - given a search spec, such as "House S06E05", query isoHunt and return good torrents (removing listings with poor scores, too few S/L, possibly negative comments, or that aren't plain AVI files), downloading the best one and moving it to the rTorrent watch directory to start a download.

  2. monitor - check the rTorrent watch directory for finished files; remove the .finished indicator and run the episode renamer on the target; add a symlink to a "new downloads" folder.

  3. scheduler - given a show and its day/time, look it up on epguides.com to find the latest episode and run grabber. If grabber doesn't find anything, queue up the search to try again later. Cron jobs will be set to look for each show, and to periodically re-check for queued items.

  4. ep - given a file (or show and series/episode), look up the episode name on epguides.com and rename the file appropriately.

Together this will be a neat little system and save a fair bit of manual work—which is a fundamental goal of computer science ("What can be efficiently automated?").

Update: The patch was committed in April 2010, six months after it was provided.

Books finished: Glenn Beck's Common Sense.

Second Amendment Day #4

News, Guns ·Sunday October 18, 2009 @ 20:16 EDT (link)

Once more (1 2 3) a group from Microsoft's MSgun group descended on the Sultan shooting pit. There was a pretty good turnout, and the rain which had been plaguing the area for the past few days held off and we even saw sun in the afternoon. It was a good day and as always a good time of solidarity, shooting, and suds (followup was at Redhook).


I finally (Saturday the 24th) got around to going through my photos, paring 807 down to 168, due to shooting several series trying to get the action shot. I have inserted a few I liked here and the rest can be seen using my thumbnail viewer (Tim, please don't hack it by filling up the log file—thanks :).


Kjell took video of the Mosin Nagant volley fire (you may need to be logged in to Facebook and/or be his friend to see it). Joe also took some photos, but as far as I know they're only available on an internal Microsoft share (I'll add a link if there is one, to his or anyone else's photos/videos of the event).

Books finished: Robert E. Lee On Leadership.

DVDs finished: Transporter 3, Race To Witch Mountain, In the Electric Mist, The Last House On The Left, Taken, Haunting In Connecticut.

<Previous 10 entries>