Search Results: "will"

4 November 2008

MJ Ray: Library Open Source Webinars (FYI/RFC)

Today is the first of the Library Open Source Webinars run by WiLS. It takes place in a few hours (2pm CST, which I think is 14:00:00-0600, or 20:00:00Z) and costs USD25 per session or USD100 for all six. Future sessions will cover Drupal and Evergreen - sadly not Koha, as far as I can see. I’m told that “standard browser, standard phone” is all that’s needed to attend live, but recordings are Windows Media Video (WMV) files, which I think isn’t great for an Open Source Webinar. I’d be interested to hear from anyone who attends, including whether it played nicely with your software.

Russell Coker: Basics of EC2

I have previously written about my work packaging the tools to manage Amazon EC2 [1]. First you need to login and create a certificate (you can upload your own certificate - but this is probably only beneficial if you have two EC2 accounts and want to use the same certificate for both). Download the X509 private key file (named pk-X.pem) and the public key (named cert-X.pem). My Debian package of the EC2 API tools will look for the key files in the ~/.ec2 and /etc/ec2 directories and will take the first one it finds by default. To override the certificate (when using my Debian package) or to just have it work when using the code without my package you set the variables EC2_PRIVATE_KEY and EC2_CERT. This Amazon page describes some of the basics of setting up the client software and RSA keys [2]. I will describe some of the most important things now: The command “ec2-add-keypair gsg-keypair > id_rsa-gsg-keypair” creates a new keypair for logging in to an EC2 instance. The public key goes to amazon and the private key can be used by any ssh client to login as root when you creat an instance. To create an instance with that key you use the “-k gsg-keypair” option, so it seems a requirement to use the same working directory for creating all instances. Note that gsg-keypair could be replaced by any other string, if you are doing something really serious with EC2 you might use one account to create instances that are run by different people with different keys. But for most people I think that a single key is all that is required. Strangely they don’t provide a way of getting access to the public key, you have to create an instance and then copy the /root/.ssh/authorized_keys file for that. This Amazon page describes how to set up sample images [3]. The first thing it describes is the command ec2-describe-images -o self -o amazon which gives a list of all images owned by yourself and all public images owned by Amazon. It’s fairly clear that Amazon doesn’t expect you to use their images. The i386 OS images that they have available are Fedora Core 4 (four configurations with two versions of each) and Fedora 8 (a single configuration with two versions) as well as three other demo images that don’t indicate the version. The AMD64 OS images that they have available are Fedora Core 6 and Fedora Core 8. Obviously if they wanted customers to use their own images (which seems like a really good idea to me) they would provide images of CentOS (or one of the other recompiles of RHEL) and Debian. I have written about why I think that this is a bad idea for security [4], please make sure that you don’t use the ancient Amazon images for anything other than testing! To test choose an i386 image from Amazon’s list, i386 is best for testing because it allows the cheapest instances (currently $0.10 per hour). Before launching an instance allow ssh access to it with the command “ec2-authorize default -p 22“. Note that this command permits access for the entire world. There are options to limit access to certain IP address ranges, but at this stage it’s best to focus on getting something working. Of course you don’t want to actually use your first attempt at creating an instance, I think that setting up an instance to run in a secure and reliable manner would require many attempts and tests. As all the storage of the instance is wiped when it terminates (as we aren’t using S3 yet) and you won’t have any secret data online security doesn’t need to be the highest priority. A sample command to run an instance is “ec2-run-instances ami-2b5fba42 -k gsg-keypair” where ami-2b5fba42 is a public Fedora 8 image available at this moment. This will give output similar to the following: RESERVATION r-281fc441 999999999999 default
INSTANCE i-0c999999 ami-2b5fba42 pending gsg-keypair 0 m1.small 2008-11-04T06:03:09+0000 us-east-1c aki-a71cf9ce ari-a51cf9cc The parameter after the word INSTANCE is the serial number of the instance. The command “ec2-describe-instances i-0c999999” will provide information on the instance, once it is running (which may be a few minutes after you request it) you will see output such as the following: RESERVATION r-281fc441 999999999999 default
INSTANCE i-0c999999 ami-2b5fba42 ec2-10-11-12-13.compute-1.amazonaws.com domU-12-34-56-78-9a-bc.compute-1.internal running gsg-keypair 0 m1.small 2008-11-04T06:03:09+0000 us-east-1c aki-a71cf9ce ari-a51cf9cc The command “ssh -i id_rsa-gsg-keypair root@ec2-10-11-12-13.compute-1.amazonaws.com” will then grant you root access. The part of the name such as 10-11-12-13 is the public IP address. Naturally you won’t see 10.11.12.13, it will instead be public addresses in the Amazon range - I replaced the addresses to avoid driving bots to their site. The name domU-12-34-56-78-9a-bc.compute-1.internal is listed in Amazon’s internal DNS and returns the private IP address (in the 10.0.0.0/8 range) which is used for the instance. The instance has no public IP address, all connections (both inbound and outbound) run through some sort of NAT. This shouldn’t be a problem for HTTP, SMTP, and most protocols that are suitable for running on such a service. But for FTP or UDP based services it might be a problem. The part of the name such as12-34-56-78-9a-bc is the MAC address of the eth0 device. To halt a service you can run shutdown or halt as root in the instance, or run the ec2-terminate-instances command and give it the instance ID that you want to terminate. It seems to me that the best way of terminating an instance would be to run a script that produces a summary of whatver the instance did (you might not want to preserve all the log data, but some summary information would be useful), and give all operations that are in progress time to stop before running halt. A script could run on the management system to launch such an orderly shutdown script on the instance and then uses ec2-terminate-instances if the instance does not terminate quickly enough. In the near future I will document many aspects of using EC2. This will include dynamic configuration of the host, dynamic DNS, and S3 storage among other things.

Jeff Bailey: Watching an election go by...

Tomorrow I get the joy of watching an election go by that I can't participate in. I think Sen. Obama doesn't need one more voice from me at this point, but let's look at the California propositions:

Prop 1A - High speed rail. California really needs something like this. In fact, the whole US does, and maybe they'll get it once California shows that trains really can work on this side of the Atlantic.

Prop 2 - Increasing the sizes of cages for confined farm animals. I admit that I actually don't much care about this one either. I'd probably vote yet on it, but a cage is still a cage. =(

Prop 3 - Funding Children's hospitals. Uhhh. Why does this take a ballot measure? I'd do this one. Especially if it were seen as a path to the socialisation of health care.

Prop 4 - Parental notification before termination of pregnancy. Sounds like a great way to have more teen moms dead in back alleys. People either get illegal abortions or legal ones. Legal ones are much safer. This is a no-brainer for a no. If you think the incidence rate of abortions in teens is too high, fund some sex ed.

Prop 5 - Drug treatment facilities, good. Easier parole for drug-related offenses probably also good. Increased parole for serious and violent felonies? It's not clear to me that there's an actual problem here to solve. Is there really a problem with repeat offenders here that is going to be solved by this? I'd probably skip this one because there just isn't enough info.

Prop 6 - A bunch of gang related funding and such. It seems to me that if the legislature thought this was a real problem, they'd have solved it. The US already spends a stupid amount on policing, with the result of a lot of people in jail, and seemingly not alot of reduction in crime. Sounds like throwing good money after bad, then. I'd say no.

Prop 7 - Require utilities to focus on renewable energy. My electric company is already ~50% renewable according to their pamphlets. They also already are introducing smart meters, remote power cuts for air conditioning units, and have an offset program that isn't just cutting down trees. From what I understand, getting more than what they do is problematic because of reliability of supply. I don't think legislation will solve that. This legislation is probably too soon, sadly. A reluctant no from me here.

Prop 8 - A bill to remove existing rights from citizens. If you don't know my opinion on this one, you're clearly just tuning in. "no". It did occur to me today that what people should've been doing was trying to muddy the issue and put up billboards that said "In Defense of Marriage, No on prop 8". Because I really think that a yes here lessens the value of my marriage - it means that I'll be sharing in something I can't in turn wish for everyone else. And that would be sad.

Prop 9 - Victims rights bill. I wish there were more background on this site. It's not clear that there's a problem here that people are solving. A criminal sentence is supposed to be society's version of just punishment. Just because you personally still feel like crap doesn't mean that the punishment wasn't served. I don't see what relationship a person getting out of jail has to the victim at that point either than staying away from one another. No here.

Prop 10 - Funding for alternative fuels. I'm thinking back to "Who killed the electric car?" We're not doing what we can with the technology we already have. It would've been nice to perhaps see the old requirements kicked by in of a certain amount of cars having to be zero-emission or something like that now that we *know* we can do it. There are lots of electric car options now. I'd say no here.

Prop 11 - Redistricting. Nice to see that this includes people who belong to neither party in the requirements makeup. Taking the districts out of the hands of the representatives is probably a good idea. I hope the committee will opt to do something sane like simple cluster diagrams or something. I was talking with some folks at work about polling station finding and stuff, and it sounds really miserable.

Prop 12 - Veteran's bonds. Umm, sure? Are vets particularly hard hit by the current economic crisis? It seems odd to single them out. But the US has a culture of celebrating veterans that I've never understood. At home I suspect most people just don't know any. As opposed to a pile of their schoolmates *being* veterans.

Wow. That was exhausting. Do you guys have to do this every time you go to the polls?

MJ Ray: Tasty New Microblog Flavour

I’ve flirted with it in the past and resisted it for a while, but you can now follow me on Identi.ca and Twitter if you are so inclined. Seems like I might have picked a good time to try this because TwiTip just soft-launched. There’s some overlap between my accounts, but they’re not identical because different third-party sites connect to each one. Both will get told when a new article appears on this website, but Twitter is likely to see more links to other sites and Identi.ca will get more status updates. Other than that, usage will be determined by popularity at events or with communities - or by suggestions here. How would you use them? At first glance, the two services are similar but different. Both sites seem to be “cooperative deserts” (not many cooperative members on them), both sites seem to be running on non-free software (I consider AGPL non-free until its big questions are resolved) and neither site seems to have an easy way to backup one’s data or participate without registration. Identi.ca seems to have some SEO-spammer problems, while Twitter’s interface has some silly needless javascript uses. Identi.ca supports OpenMicroBlogging (OMB) but I don’t understand that yet - it seems a terrible specification. It opens with references (but not web links) to three other things I’ve never heard of, then continues into a dictionary where terms like “listener” are redefined (ouch!) and doesn’t contain an examples section. New article announcements are done by a Wordpress plugin I’ll publish soon. Because of the above problems with OMB and that I can’t find whether Twitter supports it, the plugin uses the simpler status HTTP POST interface. Does anything other than Twitter and Identi.ca support that? I tried a few sites and got bored with them requiring me to apply for an API key before they’d tell me much.

MJ Ray: Tasty New Microblog Flavour

I’ve flirted with it in the past and resisted it for a while, but you can now follow me on Identi.ca and Twitter if you are so inclined. Seems like I might have picked a good time to try this because TwiTip just soft-launched. There’s some overlap between my accounts, but they’re not identical because different third-party sites connect to each one. Both will get told when a new article appears on this website, but Twitter is likely to see more links to other sites and Identi.ca will get more status updates. Other than that, usage will be determined by popularity at events or with communities - or by suggestions here. How would you use them? At first glance, the two services are similar but different. Both sites seem to be “cooperative deserts” (not many cooperative members on them), both sites seem to be running on non-free software (I consider AGPL non-free until its big questions are resolved) and neither site seems to have an easy way to backup one’s data or participate without registration. Identi.ca seems to have some SEO-spammer problems, while Twitter’s interface has some silly needless javascript uses. Identi.ca supports OpenMicroBlogging (OMB) but I don’t understand that yet - it seems a terrible specification. It opens with references (but not web links) to three other things I’ve never heard of, then continues into a dictionary where terms like “listener” are redefined (ouch!) and doesn’t contain an examples section. New article announcements are done by a Wordpress plugin I’ll publish soon. Because of the above problems with OMB and that I can’t find whether Twitter supports it, the plugin uses the simpler status HTTP POST interface. Does anything other than Twitter and Identi.ca support that? I tried a few sites and got bored with them requiring me to apply for an API key before they’d tell me much.

3 November 2008

Russell Coker: Christian Principles in an Election Year

The National Council of Churches in the US [1] has produced some advice for Christian voters titled Christian Principles in an Election Year [2]. It starts by saying “Your church, your communion, and the National Council of Churches USA do not endorse any political party or any candidate” (which is in bold in their text) and then lists 10 issues that Christians should consider when voting. Here are the 10 section headings, the full article has a sentence or two explaining each one. I think that most good people (regardless of religion) will agree with all of this - maybe substitute “God” with the name of some other entity that has not been proven to exist or with “humanity”.

  1. War is contrary to the will of God.

  2. God calls us to live in communities shaped by peace and cooperation.

  3. God created us for each other, and thus our security depends on the well being of our global neighbors.

  4. God calls us to be advocates for those who are most vulnerable in our society.

  5. Each human being is created in the image of God and is of infinite worth.

  6. The earth belongs to God and is intrinsically good.

  7. Christians have a biblical mandate to welcome strangers.

  8. Those who follow Christ are called to heal the sick.

  9. Because of the transforming power of God s grace, all humans are called to be in right relationship with each other.

  10. Providing enriched learning environments for all of God s children is a moral imperative.

The Blogger Joy Reid [3] often uses the term “Matthew Christian” to refer to Christians who follow the book of Matthew and act in ways that would be considered to be good by most people regardless of belief. This is in stark contrast to some of the nasty people who call themselves Christian and who promote hatred, inequality, and war - such people give all Christians a bad reputation (see the comment section of any blog post concerning religion for examples). John Goerzen’s post titled Politics and the Church (which references the NCCUSA article [4]) is also worth reading. Interestingly his blog post had a Google advert for “Christian Masturbation” when I viewed it. John also has a good post explaning why he is voting for Obama - based on his Christian beliefs and “Traditional Values” [5].

Andrea De Iacovo: Great things for WordPress


That’s really a good period for WordPress in Debian: yesterday 2.6.2 hit experimental and today I closed two RC bugs for 2.5.2 (in lenny). Next things to come:
  1. experimental will have 2.6.3
  2. WordPress will depend on many more libraries so I can stop shipping embedded (and bugged!) scripts.
I whis I had more time to do all these things! You’ll have to wait just for some days ;-)       

Michal Čihař: Bad translations status

I know phpMyAdmin translators will love us for this, but I just commited translatable messages for new setup script. This leads to situation when even the best translations are at 75% (see statistics). I hope our brave translators will manage to handle these 350 new messages for upcoming 3.1 release, at least for major languages, which were always close to 100%. PS: Looking for translator to Czech!

Simon Richter: The future

I don't know what Web 3.0 will look like, but Web 4.0 will be built with structural markup and <blink> tags.

Russell Coker: Types of Cloud Computing

The term Cloud Computing seems to be poorly defined at the moment, as an example the Wikipedia page about it is rather incoherent [1]. The one area in which all definitions of the term agree is that a service is provided by a varying number of servers of which the details are unknown to the people who use the services - including the people who program them. There seem to be four main definitions of cloud computing. The first one is Distributed Computing [2] (multiple machines in different administrative domains being used to perform a single task or several tasks), this definition does not seem to be well accepted and will probably disappear. The next one is Software As A Service [3] which is usually based on the concept of outsourcing the ownership and management of some software and accessing it over the Internet. An example is the companies that offer outsourced management of mail servers that are compatible with MS Exchange (a notoriously difficult system to manage). For an annual fee per email address you can have someone else run an Exchange compatible mail server which can talk to Blackberries etc. The main benefit of SAAS is that it saves the risk and expense of managing the software, having the software deployed at a central location is merely a way of providing further cost reductions (some companies that offer SAAS services will also install the software on your servers at greater expense). The last two definitions are the ones that I consider the most interesting, that is virtual machines (also known as Cloud Infrastructure [4]) and virtual hosting of applications (also known as Cloud Platforms [5]). The Amazon EC2 (Elastic Cloud Computing) service [6] seems to be the leading virtual machine cloud service at the moment. Google App Engine [7] seems to be the leading cloud application hosting service at the moment. It is also claimed that “Cloud Storage” is part of cloud computing. It seems to me that storing data on servers all over the world is something that was done long before the term “Cloud Computing” was invented, so I don’t think it’s deserving of the term.

2 November 2008

John Goerzen: What magazine to subscribe to?

A few years ago, I -- yes -- subscribed to a paper magazine (US News). I didn't continue my subscription because I stopped reading it. I stopped reading it because, frankly, there wasn't that much worth reading a week after I heard it on NPR.

I find I spend entirely too much time reading at a computer and far too little time reading elsewhere. I want to subscribe to a magazine that will actually be interesting. Thought-provoking. Challenging, even.

So here's what I'm considering, just looking at their websites:

The New Yorker

Seems to have articles with a lot of depth, some interesting fiction in each issue. I guess I'd call it literary. I like what they have to say and the intelligence behind it.

It seems I've got to love it for its use of diaeresis marks in print.

The others I'm looking at include The Atlantic Monthly, The New Republic, and The Nation. Of these, The Nation perhaps looks the most interesting. But I'm leaning towards The New Yorker right now.

Suggestions?

John Goerzen: Politics and the Church

My church is one in which politics are checked at the door. Some church members wear their politics on their yard, or on their blog -- and just about every opinion is represented in the church. But you rarely hear politics mentioned in church. When it is mentioned, it's issue-oriented rather than candidate-oriented or policy-oriented -- we'll hear updates on efforts to create a peace tax fund, for instance.

But today, hearing about politics is just about unavoidable.

The relationship between Christianity and government has been uneasy and troubled all the way back to the religion's founding. Many Christians, and I count myself in this, believe that our first loyalty is to Jesus, and on those grounds, refuse to say the pledge of allegiance. What, we wonder, would our word be worth if we were forced to disobey our government because of a law that was unjust or immoral? How could we even say the words "one nation, under God, with liberty and justice for all" when those words were written at a time when the KKK was active, lynchings were common, and are said today at a time when people treat Muslims and immigrants with modern disdain?

In short, we believe we are called to be citizens of a different kingdom first.

So, today, our pastor deliberately picked a difficult scripture passage for us: Romans 13:1-7, which reads, in part:

Everyone must submit himself to the governing authorities. . . The authorities that exist have been established by God. . . Consequently, he who rebels against the authority is rebelling against what God has instituted, and those who do so will bring judgment on themselves. For rulers hold no terror for those who do right, but for those who do wrong. . . Therefore, it is necessary to submit to the authorities, not only because of possible punishment but also because of conscience.


What an extraordinary set of statements. This was written during the time of the Roman Empire, which could hardly be said to have been a just and benign government. It's hard for me to imagine the Roman Legion being established by God.

In more modern times, it would seem to denounce the American revolution as a rebellion against authority and therefore a rebellion against God. It would also seem to denounce the protests that we see all over the world -- striking workers in France, human rights seekers in Burma, war protesters in the United States. Would it even have condemned the protests in the 1960s over civil rights in this country, or the protests against war today?

One commentator notes that "Paul is not stating that this will always be true but is describing the proper, ideal function of rulers. When civil rulers overstep their proper function, the Christian is to obey God rather than human authorities" -- a theme Paul mentioned more than once in Acts.

What relevance does this have for us today? It seems that we are to help our rulers act in a just way, even if we disagree with them -- no matter who wins the election. It is also a reminder that a superficial reading of the Bible, taken out of context and without a deep understanding to understand the author's point, can potentially lead to very strange conclusions.

The American National Council of Churches has issued a non-partisan voting guide, which we found in our bulletin today. It is an interesting read, and probably not what you think; it begins with, "War is contrary to the will of God." Thought-provoking stuff.

I find it interesting that there are a lot of people out there that say that religion is responsible for a lot of ill in this country, then proceed to hold pretty much the same opinions I do for pretty much the same reasons. I just point out that the Bible is deeper than intolerance and submission.

Clint Adams: Third-party affirmative action

I have no good reason to participate in a system I believe to be so flawed it should be replaced entirely. However, I am still going to vote, and since people have already threatened to pay me to vote for Obama, I have concocted this little solicitation scheme to justify my trip to the polls. I don't believe in the free market any more than I believe in the crap that is Keynesianism, so the following offsets will be subtracted from the final totals.
$0.00 Barr / Root
$0.00 Calero / Kennedy
$0.00 La Riva / Puryear
$0.00 McKinney / Clemente
$0.00 Nader / Gonzalez
$0.01 Obama / Biden
$1,000,001 McCain / Palin
Bribes will be kept anonymous, and should there be an inquest, I will deny all of this. Everything must be prepaid to count. Should there be any ties after the adjustments, decisions will be made through a game of mumblety-peg with an effeminate Texan. Whining and FUD about how not voting for one of the two mainstream parties causes simultaneously global warming and the heat death of the universe will be met with the skepticism appropriate for the PR drivel paid for by those two parties. If you want something inspirational instead, read John Goerzen.

Joerg Jaspert: archive.debian.org, old bugs and list archives

sarge archived As already written a few days ago I was going to archive Sarge on archive.debian.org. That is done, you can get sarge from there now. The dists/sarge directory also already disappeared from the regular mirrors a few days ago. Im not simply deleting all source and binary packages from Sarge. Instead I am doing a removal of 1000 packages every second day, which ends up in batches of about 10000 removed files every other day. While that is a little more work on the archive side I think it pays off - many mirrors, including Debians own ones, limit the amount of files they delete in one mirror run and it is much less work than asking every mirror admin to make sure it will work on their system. Oh, just in case you mirror archive.debian.org somewhere: Make sure to use -H in your rsync call, will save about 30G of disk space.
Sarge AMD64, volatile and backports Now, while I was already working on archive.debian.org I thought it could do a little more than it did in the past. So I also went and put the Sarge AMD64 release on it, in a seperate directory. And as it would have felt lonely I put sarge-backports and sagre-volatile right beside it.
security and non-us non-us.debian.org is a service thats dead since the sarge release. Finally it also got archived on archive.debian.org (it helps that this service is, since a long time, no longer on a host in the US). security.debian.org now also appears on archive.debian.org, and the security archive will soon lose the files of old releases like slink, potato, woody and also sarge.
0.93R6, Rex and Buzz I got a few responses to my post about old releases and now we also provide 0.93R6. And to make it even better we now also have the binary packages for Rex and Buzz again. I still would like to see even older releases, including alpha and beta versions, so if you have such old things somewhere - tell me. Just make sure they somehow include the source too. I do have 0.91 for example, but it is missing any kind of source except for one package and one patchset. :(
Old list archives, old bugs On one of the CD images I thankfully got from J.H.M. Dassen I found another nice thing - old mailinglist archives from 1995 and 1996 as well as old bugs, #350 - #1626. The list- and bugpeople both got a tarball and just need to import them to make them available again. (Well, Don will kill me for that just, the bugs are html and textfile dumps, so he needs to parse them to get them in the right format for debbugs. But I’m sure he will manage. :) ). Comments: 2

Decklin Foster: Tap that class

And now, something entirely impractical. I picked up Beginning Ruby by Peter Cooper the other day to look for some teaching material. Flipping through, I came across a basic feature that had heretofore escaped my notice: the Struct class. If you want to use a class for nothing more than bundling together a few values, you can create a Struct instead of writing out initialize and attr_accessor yourself. The idiom is like this:
class Server < Struct.new(:host, :port, :password)
  def to_s
    port == 6600 ? host : "# host :# port "
  end
end
That particular one's from Njiiri (which may clue you in that it took me several months to get around to writing this post). For educational purposes, it's nice: you can point out how we give a name to a class (I've also tried to explain assignment as "naming" rather than "storing"), that there's an unnamed class (classes are also objects!), and overriding a method (which uses the dynamically defined stuff), without any boilerplate to get in the way. So it's tempting to use this in a lesson. Unfortunately, Ruby is a little bit weird here, and you run into those distracting "practical" issues about the particular language you're working in. Your classes can't subclass Class, and thus you can't say Foo.new like you can Struct.new. Struct is actually implemented in C (or Java, or whatever's native). So you have to do some handwaving. This is because the "metaclasses" we have in Ruby are implemented, so to speak, as singleton classes of objects (including class objects). I do not mean this as a criticism of Matz at all, but they seem like more of a serendipitous thing than an intentional design -- "hey, if we implement classes in this particular way, we get this sort of metaclassing automatically [1]." (The clearest explanation of why this is that I've found is in the first chapter of Advanced Rails by Brad Ediger.) I wanted to be able to just subclass Class, rather than have all that fun power that we normally get to abuse in Ruby, only because I think this is the clearest way to explain the abstraction. Even I still have trouble describing singletons in plain English. Struct is intuitively a class of classes, and factors out similar/boring stuff -- a good practice. It could be an example of how to refactor some simple classes, if only we could follow it. I decided to give up on the idea for my tutorial, but it kept me up at night. Ruby metaclasses clearly can do anything that the sort of Struct-like metaclasses I have in my mind -- "parametric" classes, if you will -- can do, and I can dynamically define just about anything; why not make it happen? We can instantiate Class itself, but the tool we have to shape that class is singleton methods. This can certainly be abstracted away. So, I whipped something up. Before getting to it, though, let's visit a new construct in Ruby 1.9 and 1.8.7: Object#tap. Apart from the obvious debugging use described in its documentation, it makes it quite easy to factor out this pattern:
def gimme_a_thing
  thing = Thing.new
  thing.do_stuff_to_it
  thing
end
Into something closer to the style of functional or declarative programming:
def gimme_a_thing
  Thing.new.tap  thing 
    thing.do_stuff_to_it
  end
end
(Well, "do stuff" is obviously still procedural, but A for effort.) Which one is "better" could probably be the subject of much debate, but: I really prefer the second one; even though it has exactly the same effect, it looks like "what" rather than "how" (something else I try to beat into impressionable young heads. :-)), which is I think easier to write tests for. I'm going to use it here, because it's shorter. Now, Object#tap passes the object as an argument to the block; in our case, we are going to define a metaclass, so we want to work with self, instead. So we define a new version, class_tap -- by analogy with class_def, I suppose --- which class_evals the block rather than simply evaluating it:
class Class
  def class_tap(&blk)
    tap  _self  _self.class_eval &blk  
  end
end
And to do the following trickery, we make use of MetAid, written by why the lucky stiff -- it's very small, so we could always just incorporate the bits we want into the code here, but this short file provides a common vocabulary for talking about metaclass stuff which is quite valuable. Now, we can write a method to create our new classes on the fly. Here's what I came up with:
require 'metaid'
class << Class
  def meta(_super=Object, &blk)
    new.class_tap do                     # 1
      meta_def :new do  *args            # 2
        Class.new(_super).class_tap do   # 3
          class_exec *args, &blk         # 4
        end
      end
    end
  end
end
(Note the "class << Class", opening the singleton, rather than "class Class", opening Class itself. Also, the distinction between new and Class.new -- they are the same method, but from inside the meta_def we're no longer in the Class class.) The lines of meta itself mean:
  1. The value of this thing is a generated class, which we will describe thusly:
  2. Its singleton class has a new method, which gives you a value that is:
  3. Another generated class, which is defined by:
  4. the original block, which now gets run with new's arguments.
Nary an assignment in sight! The (embarrassing) caveat is that methods in the block that defines the new class instance cannot use def to create methods as normal. A def is evaluated in a totally fresh scope (I don't think I get the opinion behind this decision, to be honest), so we need to use class_def instead. This is, I must admit, rather hideous. Perhaps someday the language will change. But, first things first: now we can implement Struct in pure Ruby.
class MyStruct < Class.meta \
  do  *args 
    attr_accessor *args
    class_def :initialize do  *instance_args 
      args.zip(instance_args).each do  attr, val 
        instance_variable_set :"@# attr ", val
      end
    end
  end
end
The real Struct class does a few other nice things for you, but this is the heart of it; I can go back to that Njiiri example and just swap in MyStruct for Struct (Providing an instant performance gain of -200%... :-)). Here's a "shapes" example from my abandoned OO lesson:
class Polygon < Struct.new(:sides)
  def perimeter
    @sides.inject(&:+)
  end
end
class RegularPolygonClass < Class.meta(Polygon) \
  do  n_sides 
    class_def :initialize do  side_length 
      @sides = [side_length] * n_sides
    end
    class_def :area do
      @sides.size * @sides.first**2 / Math.tan(Math::PI / @sides.size) / 4
    end
  end
end
class Square < RegularPolygonClass.new(4); end
class Pentagon < RegularPolygonClass.new(5); end
(Note that area has no free variables and thus could actually be defined with def. It would just look funny.) You only have to change one number here to make new polygon classes, rather than accumulating parameter lint or explicitly subclassing and redefining something implicit just for the derived class [2]. In a way it the exact analogue of the imperative vs. tap style described above. There is quite a bit of aesthetics involved; one way is not "right". Apart from the syntactical wart, I like being able to do things this way. Ruby is, as they say, optimized for programmer happiness and the principle of least surprise. Still, I'm sure it is quite slow, and I don't particularly need it for any real-world application right now. For an intro to OO it's way too much complexity to have lurking unexplained beneath the surface and still requires getting bogged down in the language you happen to be using. But hey! It's neat.
[1]I basically try to do this whenever possible, anyway. Design decisions are like sex: they're better when they're free.
[2]Of course, if Ruby class variables were not leaked across the entire inheritance hierarchy, something as trivial as this one-variable example would be... trivial. At least, few people would actually miss metaprogramming features. Blub blub blub.

Julien Valroff: Laptop as desktop computer replacement

I am currently studying the possibility to change my current desktop computer for a laptop. This is the first time I am looking at these powerful laptops, as I now only use cheap laptops for small office use (email, web etc.) when traveling. My aim is now to use a laptop for my daily tasks: picture editing, small development, multimedia etc.

Ideal features would be: I do not care about the weight, as it would mainly stay on my desktop. I currently have a desktop computer with 2Go RAM, an Intel 4400 Dual Core CPU (@ 2Ghz) with 200Gb hard disk - though it is enough at the moment, I would prefer the laptop to be more powerful in order to be able to run smoothly with future applications which will be released in 2 or 3 years! Ideally, it would be around 1,000 (obviously, the cheaper the better, but I want something reliable for a few years if possible). Last but not least, it needs to be 100% compatible with GNU/Linux (Debian in particular) - I do not care about compiling kernel modules, but would rather prefer they are free (as in free speech). Do you have any experiences with such laptops?
What would be your recommendations? Is my idea something totally weird (I mean, should I keep my current desktop computer)?!

Matthew Garrett: Ultamatix

First, let me make one thing clear. This isn't constructive criticism. This is just criticism. It's directed at software that's so wrong-headed that there's no way to make it significantly better, and everyone involved would be much better spending their time doing something else instead of trying to fix any of what I'm about to describe. It's not worth it. Sit in a park or something instead. Meet new and interesting people. Take up a hobby that doesn't involve writing shell scripts for Linux. You'll be happier. I'll be happier. Everyone wins.

Anyway. I wrote about Automatix some time ago. It died and the world became a better place. More recently it's been resurrected as something called Ultamatix. In summary, don't bother. It's crap. And dangerous. But mostly crap. Again, I'm going to utterly ignore the UI code and just concentrate on what it runs.
There's almost certainly more. I got bored. The worrying thing about this is that the Ultamatix author read my criticisms of Automatix and appears to have attempted to fix all of them. The problem with this is that there's clearly a complete lack of understanding of the fundamental problem in several cases. For example, one of my criticisms of Automatix:

sudo sed -i "s/^vboxusers\(.*\):$/vboxusers\1:$AXUSER/" /etc/group

- assumes that the system isn't using some sort of user directory service.


and the Ultamatix response:

Fixed...Got rid of Virtualbox

Except exactly the same problem is present at other points in Ultamatix, as noted above. Taking a bug list and slavishly fixing or deleting all the bugs isn't helpful if you then proceed to add the same bug back in 24 other places. In that respect, it's even worse than Automatix - the author's managed to produce a huge steaming pile of shite despite having been told how to avoid doing so beforehand. He may be no newbie to programming, but if not it's a perfect example of how experience doesn't imply competence.

Don't install this package. Don't let anyone else install this package. If you see anyone advocating the installation of this package, call them a fool. There's absolutely no excuse whatsoever for the existence of this kind of crap.

Minor update:
The above was looking at 1.8.0-4. It turns out that there's a 1.8.0-5 that's not linked off the website. There's no substantive difference, but some of the numbers may be slightly different.

Russell Coker: Integrity and Mailing Lists

One significant dividing factor between mailing lists is the difference between summary lists (where the person who asks a question receives replies off-list and then sends a summary to the list) and the majority of mailing lists which are discussion lists (where every reply goes to the list by default). I have seen an argument put forward that trusting the answers on a mailing list that operates under the summary list model is inherently risky and that peer review is required. It could be argued that the process of sending a summary to the list is the peer review. I’m sure that if someone posts a summary which includes some outrageously bad idea then there will be some commentary in response. Of course the down-side to this is that it takes a few days for responses to the question to arrive and as it’s common that computer problems need to be solved in hours not days the problem will be solved (one way or another) before the summary message is written. But the idea of peer review in mailing lists seems to fall down in many other ways. The first problem with the idea of peer review is that the usual aim of mailing lists is that most people will first ask google and only ask the list if a reasonable google search fails (probably most mailing lists would fall apart under the load of repeated questions otherwise). Therefore I expect that the majority of such problems to be solved by reading a web page (with no peer review that is easily accessible). Some of those web pages contain bad advice and part of the skill involved in solving any problem relates to recognising which advice to follow. Also it’s not uncommon for a question on a discussion list to result in a discussion with two or more radically different points of view being strongly supported. I think that as a general rule there is little benefit in asking for advice if you lack any ability to determine whether the advice is any good, and which of the possible pieces of good advice actually apply to your situation. Sometimes you can recognise good advice by the people who offer it, in a small community such as a mailing list it’s easy to recognise the people who have a history of offering reasonable advice. It seems that the main disadvantage of asking google when compared to asking a mailing list is that the google results will in most cases contain links to web sites written by people who you don’t know. Sometimes the advice is easy to assess, for example if someone recommends a little-known and badly documented command-line option for a utility it’s easy to read the man page and not overly difficult to read the source to discover whether it is a useful solution. Even testing a suggested solution is usually a viable option. Also it’s often the case that doing a google search on a recommended solution will be very informative (sometimes you see web pages saying “here’s something I tried which failed”). Recommendations based on personal experience are less reliable due to statistical issues (consider the the regular disagreements about the reliability of hard disks where some people claim that RAID is not necessary due to not having seen failures while others claim that RAID-5 is inadequate because it has failed them). There are also issues of different requirements, trivial issues such as the amount of money that can be spent will often determine which (if any) of the pieces of good advice can be adopted. The fact that a large number of people (possibly the majority of Internet users) regularly forward as fact rumors that are debunked by Snopes.com (the main site for debunking urban legends) seems to indicate that it is always going to be impossible to increase the quality of advice beyond a certain level. A significant portion of the people on the net are either unwilling to spend a small amount of effort in determining the accuracy of information that they send around or are so gullible that they believe such things beyond the possibility of doubt. Consider that the next time you ask for advice on a technical issue, you may receive a response from someone who forwarded a rumor that was debunked by Snopes. Sometimes technical advice is just inherently dangerous because it is impossible to verify the integrity of some code that is being shared, or because it may be based on different versions of software. In a previous blog post I analyse some issues related to security of the Amazon EC2 service [1]. While the EC2 service is great in many ways (and implements a good well-documented set of security features on the servers) the unsigned code for managing it and the old versions of the images that they offer to customers raise some serious issues that provide avenues for attack. Getting the EC2 management tools to work correctly on Debian is not trivial, I have released patches but will not release packages for legal reasons. It seems most likely to me that someone will release packages based on my patches (either because they don’t care about the legal issues or they have legal advice suggesting that such things are OK - maybe due to residing in a different jurisdiction). Then people who download such packages will have to determine whether they trust the person who built them. They may also have the issue of Amazon offering a newer version of the software than that which is packaged for Debian (for all I know Amazon released a new version yesterday). The term integrity when applied to computers refers to either accidental or malicious damage to data [2]. In the context of mailing list discussions this means both poorly considered advice and acts of malice (which when you consider spam and undisclosed conflicts of interest are actually quite common). If you ask for advice in any forum (and I use the term in it’s broadest sense to cover web “forums”, IRC, twitter, etc) then getting a useful result will depend on having the majority of members of the forum possessing sufficient integrity and skill, being able to recognise the people whose advice should be followed, or being able to recognise good advice on it’s own. I can think of few examples of forums of which I have been involved where the level of skill was sufficient to provide quality answers (and refutations for bad answers) for all areas of discussion that were on topic. People whose advice should generally be followed will often offer advice on areas where their skills are less well developed, someone whose advice can be blindly followed in regard to topic A may not be a reliable source for advice on topic B - which can cause confusion if the topics in question are closely related. Finally a fundamental difference between “peer review” (as applied to conferences and academic journals) is that review for conferences and journals is conducted before the presentation. Not only does the work have to be good enough to pass the review, but the people doing it will never be sure what the threshold is (and will generally want to do more than a minimal effort) so the quality will be quite high. While peer review in mailing lists is mostly based around the presence or absence of flames. A message which doesn’t attract flames will either have some minimal quality or be related to a topic that is not well known (so no-one regards it as being obviously wrong). Update: The “peer review” process of publishing a post on my blog revealed that I had incorrectly used who’s instead of whose.

1 November 2008

Thomas Girard: Playing with C++0x -- tuple

C++0x is approaching, and it comes with a lot of new stuff, so I've decided to play with it. Some C++0x features are already available in g++ 4.3. Others will be available in the 4.4 release -- see this page for a summary of C++0x language support in g++. What is a tuple? It's a std::pair on stero ds: it can contain any number of elements. For the impatient, the whole sample program is available from here. It can be compiled with: g++-4.3 --std=c++0x tuple.cpp -o tuple. Now let's see how to create a tuple:
#include <string>
#include <tuple>
typedef std::tuple<int, double, std::string> my_tuple_t;
my_tuple_t a_tuple(1, 5.0);
Every element of the tuple gets initialized to its default value if it's not specified. Indeed displaying the third element:
std::cout << std::get<2>(a_tuple) << std::endl;
outputs nothing, because the string element was default-constructed to an empty string. The std::make_tuple function, like std::make_pair for std::pair, can be used to create a tuple using type deduction:
std::cout << std::get<1>(std::make_tuple(false, std::string("see"))) << std::endl;
A tuple element can be changed using the same get function:
std::get<2>(a_tuple) = "a string";
Of course, a tuple is type safe. Trying to put a string at the first element:
std::get<0>(a_tuple) = "another string";
does not compile. But there's more: you also get a compilation error when trying to access an element that does not exist. For example trying to display fourth element does not compile:
std::cout << std::get<3>(a_tuple) << std::endl;
What else can you do with tuples? You can test them for equality, or assign them:
my_tuple_t another_tuple = std::make_tuple(2, 10.0, std::string("nothing"));
std::cout << (a_tuple == another_tuple) << std::endl;
another_tuple = a_tuple;
std::cout << (a_tuple == another_tuple) << std::endl;
You can also retrieve multiple elements at once, possibly ignoring some of them:
std::string a_string;
std::tie(std::ignore, std::ignore, a_string) = another_tuple;
Last, you can concatenate two tuples into a new tuple:
std::tuple<int, double, std::string, bool, std::string> cat =
    std::tuple_cat(a_tuple, std::make_tuple(false, std::string("see")));

Biella Coleman: Voter Fraud

My colleague Mark Crispin Miller has written an excellent piece in the Wall Street Journal Will this Election Be Stolen?. The issue he raises–voter fraud of various stripes–is the single most important issue the American electorate faces. He concludes with the following powerful thought:
It is not the failure or success of any candidate or party that most matters but the exercise of voting rights, and, through them, our self-government. If either team prevails despite the disenfranchisement of some Americans, that victory will mean all that much less; and if your favorite wins, and then the U.S. doesn’t do anything to fix its voting system (and otherwise restore this faltering democracy), that victory of his won’t matter much at all, since We the People will have lost control for good.

Next.

Previous.