Search Results: "wart"

12 January 2010

Jaldhar Vyas: Condorcet Voting With Clone-proof Schwartz Sequential Dropping Is Hard, Let's Go Shopping

I am passing on a message from my daughter Shailaja. She would like you to go here and vote for computer engineer. (Or news anchor if you want to annoy her father.)

31 December 2009

John Goerzen: My Reading List for 2010

I can hear the question now: What kind of guy puts The Iliad and War and Peace on a list of things to read for fun? Well, me. I think that reading things by authors I ve never read before, people that take positions I haven t heard of before or don t agree with, or works that are challenging, will teach me something. And learning is fun. My entire list for 2010 is at Goodreads. I ve highlighted a few below. I don t expect to read all 34 books on the Goodreads list necessarily, but there is the chance. The Iliad by Homer, 750BC, trans. by Alexander Pope, 704 pages. A recent NPR story kindled my interest in this work. I m looking forward to it. The Oxford History of the Classical World by Boardman, Griffin, and Murray, 1986, 882 pages. It covers ancient Greece and Rome up through the fall of the Roman empire. The Fires of Heaven (Wheel of Time #5) by Robert Jordan, 1994, 912 pages. I ve read books 1 through 4 already, and would like to continue on the series. War and Peace by Lev Leo Nikolayevich Tolstoy, 1869, 1392 pages. Been on my list for way too long. Time to get to it. Haven t read anything by Tolstoy before. The Politics of Jesus by John Howard Yoder, 1972, 2nd ed., 270 pages. Aims to dispel the notion of Jesus as apolitical. An Intimate History of Humanity by Theodore Zeldin, 1996, 496 pages. Picked this up at Powell s in Portland on a whim, and it s about time I get to it. The Myth of a Christian Nation: How the Quest for Political Power Is Destroying the Church by Gregory A. Boyd, 2007, 224 pages. An argument that the American evangelical church allowed itself to be co-opted by the political right (and some on the left) and argues this is harmful to the church. Also challenges the notion that America ever was a Christian nation. Daily Life in Ancient Rome: The People and the City at the Height of the Empire, by Jerome Carcopino, 2003, 368 pages. I ve always been fascinated with how things were on the ground rather than at the perspective of generals and kings, and this promises to be interesting. Slavery, Sabbath, War, and Women: Case Issues in Biblical Interpretation (Conrad Grebel Lectures) by Willard M. Swartley, 1983, 368 pages. Looking at how people have argued from different Biblical perspectives about various issues over the years. To the Lighthouse by Virginia Woolf, 1927, 252 pages. I can t believe I ve never read Woolf before. Yet another one I m really looking forward to. Tales of the Jazz Age by F. Scott Fitzgerald, 1922, 319 pages. Per Goodreads: This book of five confessional essays from the 1930s follows Fitzgerald and his wife Zelda from the height of their celebrity as the darlings of the 1920s to years of rapid decline leading to the self-proclaimed Crack Up in 1936. Ulysses by James Joyce, 1922 (1961 unabridged version), 783 pages. The Future of Faith by Harvey Cox, 2009, 256 pages. Per Goodreads, Cox explains why Christian beliefs and dogma are giving way to new grassroots movements rooted in social justice and spiritual experience. Heard about this one in an interview with Diane Rehm. Being There by Jerzy Kosi ski, 1970, 128 pages. Jesus: Uncovering the Life, Teachings, and Relevance of a Religious Revolutionary by Marcus Borg, 2006, 352 pages. Whether or not you agree with Borg, this has got to be a thought-provoking title. The Three Musketeers by Alexandre Dumas, 1844, 640 pages. The Book of Tea by Kakuzo Okakura, 1906, 154 pages. Per Goodreads: In 1906 in turn-of-the century Boston, a small, esoteric book about tea was written with the intention of being read aloud in the famous salon of Isabella Gardner. It was authored by Okakura Kakuzo, a Japanese philosopher, art expert, and curator. Little known at the time, Kakuzo would emerge as one of the great thinkers of the early 20th century, a genius who was insightful, witty and greatly responsible for bridging Western and Eastern cultures. Nearly a century later, Kakuzo s The Book of Tea is still beloved the world over. Interwoven with a rich history of tea and its place in Japanese society is poignant commentary on Eastern culture and our ongoing fascination with it, as well as illuminating essays on art, spirituality, poetry, and more. More of my list is at Goodreads.

28 November 2009

Bernd Zeimetz: the ganneff way of becoming a debian package maintainer

Once there was a project called Debian and a Ganneff.... (unfortunately in German only....)
22:20 < cb> Das ist doch voll die Arbeit Maintainer zu werden :-). Ich geb
gew nschte Pakete immer nur weiter an einen der da sowieso schon den Kernel
betreut :-)
22:21 < Ganneff> es is nur viel arbeit wenn du keinen schimmer hast
22:22 < cb> ja ich hab nur das seepferdchen *g*
22:22 < Obilan> Knusper: ja sicher ist es das
22:22 < Knusper> kopf -> tisch
22:22 < cb> Knusper, wenn du die verwaisten pakete findest siehst du auf
der gleichen seite auch die links wie man maintainer wird
22:22 < Knusper> die hab ich gefunden
22:22 < cb> zumindest hab ich das das letzte mal dort gesehen
22:24 < Ganneff> wnpp?
22:24 < Knusper> aber man brauch dann schon leute, die einen "hoffieren"
22:26 < Ganneff> du brauchst erstmal die ahnung nen paket zu bauen.
22:26 < Ganneff> dazu siehe new maint guide
22:26 < Ganneff> dann brauchste nen sponsor. dazu gehe zur mentors liste
22:26 < Ganneff> dann machste mit dem eh weng rum (also normal so
paketuploads via dem)
22:26 < Ganneff> und hast da halt schon dein maintenance krams.
22:27 < Ganneff> irgendwann is der sponsor angekotzt von dir und dem
laufenden arbeit generieren
22:27 < Ganneff> der tritt dich dann dass du mal DM anf ngst.
22:27 < Ganneff> das machste dann, und jemand anders tritt dir deine pakete
als dmua zurecht, nachdem du in nem keyring irgendwo steckst.
22:27 < Ganneff> und dann kannste denn krampf selbst hochladen. aber nix
andres.
22:27 < Ganneff> irgendwann willste was andres. und willst das auch noch
ohne son doofen sponsor
22:28 < Ganneff> dann versuchste dich an DD
22:28 < Knusper> ahhhhhh
22:28 < Ganneff> dazu musste dir nen advocate suchen
22:28 < Ganneff> der is  blicherweise einer dem du vorher im prozess
laufend auf den wecker fielst
22:28 < Ganneff> und er deswegen den nm leutz sagt "oh gott, befreit mich
bloss von dem"
22:28 < Ganneff> die machen das dann, aber sie wollen dir mal etwas
schmerzen zur ckgeben
22:28 < Ganneff> desdewegen wirste viele fragen beantworten m ssen
22:29 < Ganneff> und wie beim t v das auto musste hier deine pakete nochmal
vorstellen und checken lassen
22:29 < Ganneff> und dann nochmal fragen beantworten
22:29 < Knusper> thx...
22:29 < Ganneff> irgendwann gehst du dann mit den antworten den nm leuten
so auf den geist dass die dem frontdesk sagen "meine kacke, den wolle mehr
nit mehr sehen, schickts den dochma zu den DAMs, die hamms verdient"
22:30 < Ganneff> und die machen das dann meist. ausser sie m gen dich nich.
dann darfste nochma fragen beantworten
22:30 < Ganneff> bei den dams darfste nur warten. die testen deine geduld
22:30 < Ganneff> irgendwann langweilen die sich aber
22:30 < Ganneff> und dann kriegste pl tzlich mail
22:30 < Ganneff> OH MEIN GOTT. EIN NEUER DD.
22:30 < Ganneff> ende
22:30 < Ganneff> kapitel 2:
22:30 < cb> sch ne beschreibung
22:30 < Ganneff> du machst ne zeit als dd rum
22:30 < Knusper> LOL
22:30 < Ganneff> votest durch die gegend
22:30 < Ganneff> l dst pakete umher
22:30 < Ganneff> machst bugs in stable
22:30 < Ganneff> gibts dem security team arbeit
22:31 < Ganneff> sprich - du gehst allen auf den sack. denn das is was ein
dd macht. muss ja schliesslich auch spass machen.
22:31 < Ganneff> aber irgendwann, also irgendwann, da wird das langweilig
22:31 < Ganneff> und dann verschwindeste mal ne zeit.
22:31 < Ganneff> weil du weisst - da gibts noch son team. das brauch auch
arbeit
22:31 < Ganneff> die suchen so leute die weggehen und sich verstecken
22:31 < Ganneff> nennt sich mia. die suchen.
22:31 < Ganneff> vielleicht finden die dich ja auch.
22:32 < Ganneff> dann kommste zur ck und machst mal wieder etwas arbeit f r
security/stable/sonstwen
22:32 < Ganneff> oder nicht, aber das is langweilig, da fliegste einfach.
22:32 < Ganneff> wennde dann gar keinen bock mehr hast und ne l ngre pause
willst
22:32 < Ganneff> dann gehste und machst eien auf emeritus
22:32 < Ganneff> das sind die rentner, die alten s cke, die sich
zur cklehnen und  ber die versuche der neuen lachen die sich grad von den
sponsoren qu len lassen
22:33 < Ganneff> ende kap. 2, ich hab keinen bock mehr. (jaja, emeritus)
Cheers to #debian.de on freenode :-)

20 November 2009

Matthew Garrett: Why SHMConfig is off by default

Bastien mentioned the Chromium OS xorg.conf file, which includes an irritating wart - namely, Option "SHMConfig" "on". This tells the Synaptics touchpad driver to export its configuration data to a shared memory region which is accessible to any user on the system. The reason for this is that in the past, there was no good way for configuration information to be passed to input drivers through the X server at runtime. This got fixed with the advent of X input properties, and synaptics can now be configured sensibly over the X protocol.

But why was it off by default? Because, as I said, the configuration data is exported to a shared memory region which is accessible to any user on the system. And while it contains a bunch of information that's not terribly interesting (an attacker being able to disable my touchpad or turn on two finger emulation may be a DoS of sorts, but...), it also contains some values that are used to scale the input coordinates. Which means that anyone with access to the SHM region can effectively take control of your mouse. The current position is exported too, so they can also track all of your mouse input.

Now, this isn't stunningly bad. The attacker can only do this while you're touching the pad. You'll see everything that happens as a result. There's no way to fake keyboard input. They need to be running code as another user on the system - if they're running as the logged in user then they can already do all of this. And for a device as single-user as Google seem to be looking at, it's obviously not a concern at all.

But there's still plenty of places on the web suggesting that you enable SHMConfig, and various distributions that ship with it turned on (Ubuntu on the Dell mini used to, but got turned off after I contacted them about it). It's absolutely fine to do this as long as you're aware of the security implications of it, but otherwise please use X input properties instead.

15 November 2009

John Goerzen: Jacob and I Visit Wichita

Today didn t exactly go as planned. Terah woke up feeling sick, and by mid-morning was really wanting a nap. Not that that is likely to happen with a 3-year-old and a 4-month-old in the house. I needed to visit the WSU bookstore sometime anyhow, so I suggested I d take Jacob to Wichita for awhile. Jacob had been talking of seeing the trains again for awhile, so he chose these overalls for the day: 2009-11-14 11.23.26.jpg He wanted me to sing Home On The Range several times as we drove. We stopped at WSU first, and he enjoyed running down the wide sidewalks and trying to hide behind bushes. Then it was on to lunch at HuHot Mongolian Grill. Jacob chose his own ingredients (with some help from me). He chose fish, which noodles he wanted, and of course had some baby corn and carrots. He got a full bowl of ingredients, and of course his favorite part was watching them grill it. He polished off most of his plate, too. 2009-11-14 13.28.22.jpg He had been talking about ice cream all day. In fact, mention Wichita to Jacob, and he ll almost immediately say, Shall we get some ice cream? I wonder who he gets that from Terah usually takes him to Cold Stone Creamery, but we didn t have enough time to go there. So we went to The Old Mill Tasy Shop, something of along-time local legend in downtown Wichita. Jacob enjoyed noticing that the old brick wall had holes in it while they scooped out his chocolate ice cream and my strawberry sundae. He was too busy devouring his ice cream to notice it came in a metal bowl until I pointed it out to him. 2009-11-14 14.16.43.jpg Then it was off to the Great Plains Transportation Museum. It was a quiet afternoon in November; not the packed crowd like the last time we were there. He went for the old Santa Fe diesel passenger locomotive first (which he insists is a freight train ). Of course you get to go inside almost everything, and he enjoyed going inside that one, sitting on the engineer s chair, and playing with handles and knobs. We went in several of the cabooses, and he noticed the train potty in one. It s the old open to the ground type, and if you look down inside it, you see the rocks that are underneath the caboose. Jacob thought it was very interesting that the train potty has rocks in it. The museum is right next to some active freight tracks, and Jacob was very much hoping that there d be a freight train going past. He wasn t disappointed; we saw two, plus an airplane and a helicopter. A successful visit, I d say. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="http://www.flickr.com/apps/video/stewart.swf?v=71377" height="267" type="application/x-shockwave-flash" width="400"><param name="flashvars" value="intl_lang=en-us&amp;photo_secret=8517185815&amp;photo_id=4104904370"><param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=71377"><param name="bgcolor" value="#000000"><param name="allowFullScreen" value="true"><embed allowfullscreen="true" bgcolor="#000000" flashvars="intl_lang=en-us&amp;photo_secret=8517185815&amp;photo_id=4104904370" height="267" src="http://www.flickr.com/apps/video/stewart.swf?v=71377" type="application/x-shockwave-flash" width="400"></embed></object> So I didn t really get done anything I had planned to today, but in spite of being behind on stuff, it s a better day than I had planned. I really enjoy going off and doing things with Jacob. While we were eating lunch, I asked him if he had fun at the bookstore. Yeah! I have fun EVERYWHERE! What a fun perspective, huh?

17 October 2009

Russell Coker: Links October 2009

Garik Israelian gave an interesting TED talk about spectrography of stars and SETI [1]. He assumes that tectonic activity is a pre-requisite for the evolution of life (when discussing the search for elements that are needed for life) and that life which is based on solar energy will have a similar spectrographic signature to the chlorophyl based plants that we are familiar with. I doubt both those assumptions, but I still found the talk very interesting and I learned a lot. Julian Dibbell wrote an interesting Wired article about an ongoing battle between the Cult of Scientology and 4chan [2]. I don t often barrack for 4chan, but they seem to be doing some good things here but of course they do it in their own unique manner. The article also links to a hilarious video of Tom Cruise being insane, among other things he claims that Scientologists are only ones who can help at an accident site. Has Tom Cruise ever provided assistance at a car crash? The Independent has an article by Robert Fisk about the impending shift away from the US dollar for the oil trade [3]. This is expected to cause a significant loss in the value of the US dollar. Robin Marantz Henig wrote an interesting article for the NY Times about the causes of anxiety [4]. It focusses on Jerome Kagan s longitudal studies of babies and young people. One thing that I found particularly interesting were the research issues of recognising the difference between brain states, internal emotional state, and the symptoms of emotions that people display (including their own description of their emotions which may be misleading or false). The tests on teenage social interactions that involved fake myspace pages and an MRI were also interesting. Juan Cole wrote an insightful Salon article titled The top ten things you didn t know about Iran [5]. The Iranian government doesn t seem to be a threat to anyone outside their country. Clay Shirky wrote an insightful post about TV being a heat-sink for excess spare time and considers the number of projects of the scale of Wikipedia could be created with a small portion of that time [6]. It seems that the trend in society is to spend less time watching TV and more time doing creative things. In a related note Dan Meyer has an interesting blog post about trolls who say You Have No Life [7]. The Making Light blog post about Barack Obama s Nobel Peace Prize has some insightful comments [8]. I doubted that he had achieved enough to deserve it, but the commentators provide evidence that he has achieved a lot. I wonder if he will receive a second Peace Prize sometime in the next 10 years. The Making Light blog post about bullies and online disputes predictably got diverted to discussion school bullying [9]. The comments are interesting. Making Light has a mind-boggling post about homosexuality and porn [10]. US Senator Tom Coburn s (R-OK) chief of staff Michael Schwartz made the case against pornography. All pornography is homosexual pornography , said Schwartz, quoting an ex-gay friend of his. Among other things there are many good puns in the comments. Cubicle Jungle is an amusing satire of the computer industry [11]. It s shocking how long it goes before it gets to the part that s obviously fiction. The WikiReader is an interesting new device [12]. It costs $99US and has a copy of Wikipedia on an SD card, they have a subscription service that involves posting you a new SD card every 6 months, or you can download an image from their server. They state that they have a filtered version of Wikipedia for children, I wonder how they manage that, I also wonder whether they have an unfiltered version for adults. The device runs on two AAA batteries and is designed to be cheap and easy. Naturally it doesn t support editing, but most of the time that you need Wikipedia you don t need edit access or access to content that is less than 6 months old. Exetel are scum, customers who complain are cut off [13]. Making Light has an interesting post about a New Age scumbag who killed at least two of the victims who paid $10,000 for a sweat-lodge workshop (others are in hospital and may die in the near future) [14]. The NY Times has an interesting article about Jamie Oliver and his latest project [15]. He is trying to reform the eating habits of the unhealthiest area in the US. The 15 pound burger sounds interesting though, I wouldn t mind sharing one of those with 14 friends

23 April 2009

Matthew Palmer: Insane/Brilliant Idea of the Day

I've been talking serial consoles with a couple of the other guys at work: how nice they are to have for machines in the datacenter, how annoying it is that vPro serial-over-LAN doesn't seem to be robust (yet?), and how serial access concentrators are lung-and-kidney expensive (especially when you've got 50-some racks to outfit). This discussion, combined with my ongoing embedded-hardware-fascination lust for a SheevaPlug appears to have spurred my brain into coming up with a Brilliant Idea: tie a SheevaPlug to a pile of USB to serial adapters and use that as your per-rack serial concentrator. Imagine: faffenheimer, a dedicated server you manage for a customer, and located in rack 27 of your DC, has just crashed, and you'd like to know WTF has happened rather than just blindly reboot, but you're in the office 15 minutes away from the DC floor, and the customer's going to want that machine back up and running pretty quickly.
workstation:~/porn$ ssh rack27.serial
rack27:~$ sconsole faffenheimer
[screen session attached]
[minicom running, shows the horror of a kernel crash dump]
[oh look at that, kernel bug]
^A ESC
[pgup pgup]
[enter]
[pgdn pgdn]
[enter]
^A >/tmp/faffenheimer-crash-dump
^A d
rack27:~$ exit
workstation:~/porn$ scp rack27.serial:/tmp/faffenheimer-crash-dump ~
workstation:~/porn$ powercycle rack27 faffenheimer
Shiny! We got a crash dump in a minute or so (rather than having to take phonecam photos of KVM screens in the DC), never had to leave our comfy seat, and the machine's on it's way back up. We're now free to pursue diagnostic activities on that crash dump at our leisure. 10 minutes later, the downtime for faffenheimer that was automatically set when we ran powercycle runs out and Nagios sends us threatening messages. Hmm, something's gone wrong here. Back into the console...
workstation:~/porn$ ssh rack27.serial
rack27:~$ sconsole faffenheimer
[screen session attached]
[Boot is hung waiting for root password after initrd has bombed]
[Type root password]
[Oh look, the root MD appears to have come asunder]
[clickety-click... fixee fixee]
[reboot]
The more I think about this, the more I reckon I'm onto a bona fide winner. The sheevaplug is a powerful ARM-based system with USB/ethernet/SD ports that is packaged literally in it's own power supply wall wart -- it's a plastic box with power plug prongs poking out the side. That's all there is to it. The USB to serial adapter things are likely to be a bit more of a pain, but I've played with enough of them by now to not be too scared. So, you plug the Sheeva into a power socket, plug an Ethernet cable and USB hub into the Sheeva, configure things a bit so that the system knows which serial adapter maps to which machine, and you're away. Oh, and the best bit: the Sheeva apparently draws as little as 2W when idle. A whole datacentre's worth of serial goodness for about a server's worth of power. The cost per rack should be somewhere below AU$250, especially in bulk. Let's see if I can convince work to spring for a Sheeva, a USB hub, and a half dozen or so USB to serial adapters to test this whole thing out. Given that the whole thing looks like it'd cost less than AU$250 (plus my R&D time), I can't imagine it'll be too hard a sell to at least give it a go. Watch this space...

19 April 2009

Andreas Metzler: snowboarding season 08/09

Due to the later date of easter this year we had a rather long season this year. I started snowboarding on 2008-12-06 and stopped today 2009-04-19. Following up on previous entries here is the balance sheet:
2005/062006/072007/082008/09
number of (partial) days25172937
Dam ls1010510
Diedamskopf1542423
Warth/Schr cken0304
total meters of altitude12463474096219936226774
highscore10247m8321m12108m11272m
# of runs309189503551
In the second half of the season we actually had a lot of snow, up two 130 cm down at 800m above sealevel. Complete snow cover lasted from December until mid of April. Riding was good, I did not have any major injury, my skills did not increase though. The addition of a snowboard, a SG Speed 173 to my quiver worked out well. Loads of fun and less danger in slushy conditions (nose-in) compared to the shorter slalom board. Now the waiting starts. ;-)

30 March 2009

Russell Coker: Links March 2009

Cory Doctorow has written a column for The Guardian titled You shouldn t have to sell your soul just to download some music [1]. One really interesting point he made was The same companies that spent decades telling lawmakers that they were explicitly not the guardians of the morality of the young that they couldn t be held accountable for sex, drugs and rock n'roll, for gangsta rap, for drug-fuelled dance-parties did a complete reversal and began to beat their chests about the corrupting influence of downloading on the poor kiddies . The pt4me2 organisation advocates that the Victorian government spend more money on public transport infrastructure [2]. Recently the congestion on Melbourne roads has been getting worse, the costs of private car parks in the central city area have been increasing, and during peak hours all public transport is over-crowded. Some significant improvements are needed, and more trains, trams, and buses are the only possible way of coping with the number of people working in the city. Also there s the issue of suburbs that lack any public transport, I wouldn t want to live near one of those areas when petrol hits $8/L (as the CSIRO predicts for 2018). Michael Tiemann writes about Microsoft s latest patent attack against Linux [3]. He doesn t pull any punches which is a very noteworthy thing. It s pretty rare to see someone in a senior position in a company blog in a way that makes any significant comment about another company. Dan Ariely gave an interesting Ted.com talk about Our Buggy Moral Code [4]. One of the points was that people who declare themselves to be atheists are less likely to cheat when asked to swear on a bible first, another was that if someone who is identified as a member of the same group cheats then others will follow, but if an outsider cheats then they won t. It seems that if you want to minimise cheating then you want to have only outsiders be seen to do it, and you want everyone to swear to follow some sort of moral code. Flame has written a good rant titled Anarchy is Dead about the lack of popular outrage against the Australian government s censorship plans [5]. Rolling Stone magazine has a good article about the US banking crisis [6]. A moderate amount of bad language, but no more than is deserved. Amazing video of rounding up sheep that are fitted with LEDs at night [7]. Here s an interesting TED talk by Saul Griffith about using kites to generate electricity [8]. Unfortunately he didn t give much engineering information, it was more of an executive summary of what he has done. He claims that if a wartime level of effort was put in place then wind could supply all the electricity needs of the US within 10 years. Adam Savage (of Mythbusters fame) gave a talk for TED about his obsession with the Dodo [9]. One thing that surprised me is how his manner in that talk differed from his appearance in Mythbusters. It seems that most of his crazy antics in Mythbusters are an act to entertain the audience. The information about the dodo was really interesting too. He then went on to talk about his recreation of the Maltese Falcon. His work can serve as inspiration for other geeks who want to try sculpting.

21 March 2009

Russell Coker: Feeds and Banning from Planets

Stewart Smith has written about the removal of a blog from Planet Linux Australia [1] due to publishing a list of URLs that the Australian government wants to censor. The first point I want to make is that even if you had a list with thousands of entries that are not likely to offend anyone or incur any legal liability then it s still not suitable for syndication on most Planet feeds. The correct thing to do is to have a paragraph describing the list and why people would want to read it and then use the MORE feature of your blog so that the rest isn t in the RSS feed. If you use Wordpress which seems to have the MORE function broken then that would mean hosting the list somewhere else. In regard to the specific post, in a comment on Stewart s post Matt suggests that the Planet software somehow filter out certain blog posts. I am not aware of any way of doing that apart from through code changes, Matt could submit some patches to allow that sort of thing. One thing that would be really good would be to have an exclusion tag or category in a blog feed. So you for example you could have feed URLs such as /feed/lca which would be configured to list all posts without the tag not-lca. Another way for a blogger to do this would be to use Yahoo pipes [2]. The people who run a Planet should be prepared to take any feed URL. It would not be difficult for a blogger to create a pipe that excludes all items that have NSFW in the title (or any other possible way of listing them). A final option is to have multiple blogs. I have a blog for documents that I regularly update [3]. Many of those documents had been plain HTML files edited with vi for years before I started blogging. But Wordpress is a reasonable CMS and as I use it for blogging it made sense to use it for other documents too. Wordpress has no good option for managing two types of documents, ones that are date-based (regular blog posts with the date in the URL) and non-date based (which change periodically and have different date stamps). There are Wordpress pages, but the support for having moderate numbers of pages is not great. Also on my document blog I will often have articles appear new regularly as I change the date when updating them. Anyone is welcome to subscribe to the feed for my document blog if they are interested in seeing new versions of the documents, but I expect that most people don t want to. The Debian Wordpress package (as of last time I used it) and my fork of the Debian Wordpress package have great support for multiple blogs. There is Wordpress-MU for bulk blog hosting, but that is only designed for people who want to run something like LiveJournal or Blogger. If you just want a few blogs for friends and relatives then the regular Debian Wordpress package will do the job well. Some bloggers maintain two blogs, one for public things and another for close friends and relatives (people who ARE interested in what they ate for breakfast). Having one blog for the NSFW material would be a reasonable thing to do for certain bloggers. Finally while I doubt that someone who runs a Planet installation faces any legal liability, there is also the issue of a PR liability. From a PR perspective I think it s best for the reputation of Linux users in Australia for certain things to not appear on Planet Linux Australia. That said it would be good if there was a process for removing and reinstating blogs that was publicly documented. There will obviously be many differences of opinion as to what is too risky to allow on the Planet so we should expect that from time to time feeds will be temporarily removed. When that happens what does a blogger have to do to be done to be syndicated again? Update: A comment has revealed a way of filtering out RSS feeds via the feed URLs used by wordpress. A URL such as /feed/cat=-X will give a feed of all articles that don t contain category number X. Multiple categories can be specified when separated by commas. So this allows Wordpress users to exclude their NSFW category from Planet Linux Australia.

9 March 2009

Wouter Verhelst: Uitmuntend

Yesterday, the choir of which I've been a member for these past few years went to the provincial tournament for the first time in its existence. For those of you unaware with what this is: the "provincial tournament" isn't a tournament in the traditional sense (which would have a winner etc); instead, you get to sing in front of an expert jury which will classify you in one of six categories; the category you're in then determines government subsidy your group gets. This is done for all nonprofessional music groups, and makes for a pretty fair way of deciding who gets what, IMO. Apart from that, it's of course also fun. Anyway, as said this was the first time our choir went to such a "tournament", but of course we weren't alone; apart from us, there were six other choirs, two of which were also part of the Ekerse C-koren: Cantando (the semi-professional choir of our group) and Cantilene (for those between the ages of 18 and 25 (or 16 and 25 for boys). And we did well. Cantilene (who did very well in the most recent edition of the 'Koor van het Jaar' contest) was categorized in the 'superieure afdeling' ('superior category'), with 75% in that category. Cantando did even better than that; they achieved a score of 93%, also in the superieure afdeling. This is the highest category in the whole system, so it deserves some special praise. Caljent , our choir, didn't quite reach that level yet; considering the fact that we've only existed about three years, however, that isn't very surprising. Yet, we did quite well; we were categorized in the 'Uitmuntendheid' category, with a score of 75% in that category. Uitmuntendheid (which would translate to something like 'greatness') is the third possible category, which puts us in the top half of the choirs of the province of Antwerp. Quite an achievement for what is, after all, a fairly new choir. Of course we're all very happy with that especially so our conductor, who was rather surprised when she heard the outcome... For those interested, one of the choir members had a camera with him, and he put the four pieces we sang up on youtube: Credo, Dostoyno Yest, Wals van kwart voor middernacht, and Hodie Christus Natus Est. There're also films of the other choirse, but you'll have to look for those yourself ;-P

5 March 2009

Decklin Foster: You're talking about things I haven't done yet

I've been converting all my Mercurial repositories to Git. One of the motivations for this was hg's poor handling of branches and tags: branches are just another metadata field on a commit, and tags are entries in a text file called .hgtags that is tracked in the repository(!). Git has its flaws as well, but I prefer its view that branches and tags are just refs, which are pointers that exist at the repository level and are pushed or pulled around in much the same way as the objects they refer to. The excellent hg-to-git.py script included in contrib created Git tags corresponding to my old Mercurial tags, but of course didn't modify the actual commits. So I still had a .hgtags file in my Git repository, and a boilerplate commit of the form "Add tag foo for changeset bar" each time I added to it (recall that .hgtags is just another file. Thankfully, I never had to deal with two branches where I added different tags...). I wanted to remove these. Git has a 'filter-branch' command that can totally rewrite or expunge commits; this is of course a horrible idea for already published code, but there's no harm in using while initially preparing a repository. While I appreciate git's object model and speed, I must agree with its detractors that the user interface is terrible. It took some tinkering to get git-filter-branch to do what I wanted, so I'm writing this to save my notes for next time (and in case someone else is searching for how to do this). Here's the command I arrived at:
git filter-branch \
    --tag-name-filter cat \
    --index-filter 'git update-index --remove .hgtags'
    --commit-filter \
        'if [ $# = 3 ] && git diff-tree --quiet $1 $3; then
             skip_commit "$@"
         else
             git commit-tree "$@"
         fi' \
    HEAD
The tag name filter is always necessary if you want tags to be updated to point to the corresponding commits on the new, rewritten branch. I consider this a UI failure -- when a branch is rewritten, the ref is modified, and the old one moved to refs/original. Tags, on the other hand, stay where they are, without any indication on the new branch that this is where you might want to move that old tag and sign it again or whatever. IMHO they ought to be handled the same as branches. The index filter is simply an efficient way of removing the unwanted file from all commits. This and the tag filter are both covered in the manual page. Writing a commit filter is a little more obscure. After .hgtags is removed from the index, we may end up at one of those useless "Added tag foo" commits and have no changes to record in the commit. By default, of course, filter-branch still records these -- the commit message might be useful, or something. But I want to suppress them. The commit filter is called with a tree -- you're at the point between write-tree and commit-tree (I recommend Git from the bottom up if you're confused here.) It gets that tree ($1), and then "-p PARENT" for each parent, just like commit-tree. So, if this is a normal commit with one parent, there will be 3 arguments. (If there's only one argument, there is no parent, i.e., the first commit, and if there are more, then it's a merge.) This is the only case we want to mess with. If there are no changes between our tree and the parent's tree, then it's one of those no-op commits, and we can skip it (skip_commit, a shell function defined by filter-tree, uses some deep magic to hand us the original parent again next time). I think diffing the index and the parent would work as well, but this seemed clearer. It still feels like a hack, so I'd love to hear from anyone who can suggest improvements. Since this is a special case, maybe it's better off being implemented in hg-to-git.py itself. There's always more than one way to do it. Update: Teemu Likonen points out that the next version of Git (1.6.2, not yet in unstable) will have a --prune-empty option which makes this particular problem totally trivial. I am starting to get the feeling that the Git developers are all reading our minds... :-)

26 February 2009

Riku Voipio: The not-slug: SheevaPlug

popcon lists approximately 1000 arm/armel Debian installations. There is also listed 864 installations of nslu2-utils, letting us estimate that approximately 85% of debian/arm(el) installations are Linksys nslu2's. It is nicked sympathetically as "The Slug", which pretty accurately describes the performance of nslu2. Still, people have found absolutely amazing amount of ways to use their slugs. What would you do with something approximately 10x more powerful with same prize/size range?

Enter the Marvell SheevaPlug




What Slug SheevaPlug
CPU 266Mhz 1.2Ghz
Cache 32KB 32+256KB
Flash 8MB 512MB
MEM 32MB 512MB
Net 100Mb 1Gb


And that's not everything - SheevaPlug comes with SDIO slot and miniusb to be used as a serial console (and JTAG). No soldering needed for hacking.

Some more details on the LinuxDevices article.

For those of you who think that has one port too few of something, or don't like the wall-wart design, Other devices based on kirkwood SoC (which SheevaPlug is based on) are on the way from various ODM/OEM houses.

31 January 2009

Russell Coker: Predictions for 2009 and Beyond

Stewart has made some predictions for the future of computing [1]. He predicts that within 2 years the majority of consumer machines will be laptops and have SSD (not rotational media). I predict that by the end of next year more than half of all new consumer machines that are being sold will be laptops (defined as being portable machines with the display and keyboard forming part of a single unit), and that more than half of such machines will have SSD as the primary storage (IE used for booting and for most common file access). I predict that by the end of 2010 the majority of all computers shipped (in all form factors including games consoles and servers) will have SSD as their primary storage. I predict that in late 2010 rotational media will start to go away for most tasks, but for at least the next year the model will be SSD for small/light/fast operations and rotational media for large capacity. I m not disagreeing with Stewart, just being more precise. Also while Val made some good points about the reliability of SSD [2] I don t think that this will be an obstacle in the low-end of the market. There is no little evidence of computers failing in the consumer market due to being unreliable - it seems that Microsoft has conditioned people to expect unreliability. I predict that Sun will not release ZFS under the GPL in time for anyone to care. The release of OpenSolaris was way behind schedule and I don t expect anything different this time around. Stewart predicts that in five years Linux will have significantly more desktop market share than Apple. I agree and also predict that Apple will convert to the Linux kernel. I predict that Apple will become the first Linux distributor to make any significant hardware sales for the mainstream computer market (Linux bundled with hardware has already done well for mobile phones, routers, Tivo, and similar devices where the user doesn t know what OS is running). I predict the death of Windows mobile. I predict that in five years the mobile phone/PDA market will be dominated by Android with a variety of other Linux based phones. I predict that some time after five years the iPhone will go away. Chris Samuel has made some predictions too [3]. He predicts that within two years The distinction between laptops, netbooks and mobile phones will get even more blurred with consumers demanding mobiles with more power and lighter and lighter laptops/netbooks . I believe that the difference between laptops, netbooks, and mobile phones is primarily one of IO (size of keyboard, sockets for peripherals, and size of screen). For desktop use the only application I use which requires more RAM or CPU power than my EeePC 701 can provide is Firefox. A combination of more efficient javascript interpretation and better coding practices by web designers would solve that problem. A significant portion of the mass of a laptop is dedicated to suppporting IO ports and maintaining the structural integrity of the device. A common feature in science fiction is lapotops that can be rolled up, stretched to size, etc (the Thinkpad Butterfly keyboard was an attempt at a first step towards this which failed due to issues of mechanical strength). As some Netbook class systems already have 3G networking built in it seems a logical extension to have telephony functions built in to a laptop. I predict that laptops with full telephony support will go on sale in 2010. One promising feature in regard to laptop IO is the new Display Port [4] video port. It will only be an incremental improvement to the space taken for IO capacity, but I am not expecting anything revolutionary in the near future. I predict that HDMI will be a failure in the market and DVI will never gain critical market share, it will be VGA and Display Port on most systems by 2012. Predicting that technological developments won t happen is always risky, but I predict that the mechanical issues which separate the heavier laptops and desktop-replacements from netbooks (in terms of making a large display and keyboard that won t break frequently) won t be solved within five years. In the same note, I don t expect anyone to try building a mobile phone which can have a full-size screen and keyboard connected to it (although it would be possible to do so). So I expect that the phone/PDA, Netbook, and laptop distinction will remain for at least the next 5 years. One thing that would make sense is to have a small device (PDA or mobile phone) store data that is security relevant and connect it to full-size machines for serious work. So for example you could use a desktop machine for Internet banking (maybe in an Internet cafe) and have your mobile phone ask you to confirm the transaction and then authenticate you to the bank server. I predict a larger role for PDAs and mobile phones as computers as soon as people start to take security seriously. I won t try and guess when that might be, but I predict that it won t be for at least five years. I predict that increasing oil prices will significantly make a significant impact on the price of computers before the end of 2010. Not that I expect the prices to suddenly jump upwards, it s more likely that prices will steadily increase while at the same time new technology to reduce production expenses in other areas is introduced. I also predict that increasing oil prices will increase the desire to maintain systems for longer periods of time without maintenance. For example my Thinkpad T41p has had a few significant part replacements (a couple of motherboards, half the case, and a few keyboard replacements). This is OK while plastic costs almost nothing and the manufacturing expenses are also very low. But in future I expect that people will want laptops that can run for years without needing part replacments and which have a service life of 10 years or more. This requirement for strength will counteract the demand for laptops that are as light as netbooks.

4 January 2009

Andrew Pollock: [tech] Mixing electricity and water: monitoring the cat water bowl with Nagios

(this is something I've had "in production" for many months now, I just haven't had the time or energy to do a proper write up about what I did) We have a cat water bowl, it looks like this: The cat water bowl Under "normal" circumstances, it usually lasts about seven days. So when our weekly routine is happening, we'll refill it on a Saturday whilst doing house chores, and it'll last until the following Saturday when it gets refilled. Unfortunately, sometimes our routine gets disrupted, and we forget. Sometimes, we travel and have a house-sitter, who may not pay as close attention to such things as ourselves. Once, one of our cats was licking the condensation off a chilled bottle of soft drink that was on the kitchen counter one evening, before we realised the water bowl needed refilling. Naturally, we felt like terrible pet owners. So I think it was some time around the 2008 Maker Faire, that I hatched the idea of having some sort of water sensor on the cat bowl, which would communicate to one of the various computers in house. At the Maker Faire, I bought a copy of Making things talk, and an Arduino starter kit, which consisted of a Diecimila board and a make-it-yourself proto shield. I also bought a little electronics starter kit, which consisted of a breadboard and various components, and a USB-TTL cable. I decided to use Bluetooth to communicate with the board, as I already had my MythTV setup using a Bluetooth keyboard and mouse, and it was within range of the water bowl. I decided against using Zigbee, because I didn't know anything about it, and I didn't want to add (or learn about) yet another wireless infrastructure just for this project. I should point out that I know very little about electronics. I'd never owned (or really used) a soldering iron until I embarked on this project. I took a basic soldering class at the Tech Shop, but I'd already assembled the proto shield by the time I took the class, so I'd pretty much figured it out. I had a very naive vision that I could just basically shove two wires in some water and it'd close a circuit and that would be my water sensor. Of course this didn't work, so I started hunting around on the Internet for a circuit that would do this. I happened upon a circuit (I don't seem to have retained the URL, so I can't link to it), which just consisted of a couple of transistors and some resistors. So I headed off to Fry's to try and buy the transistors I needed. I quickly discovered that I didn't have sufficient information to identify the transistors that I wanted, but I did happen to stumble upon a cheap assemble-it-yourself water alarm. It consisted of a PCB, and a transistor and some resistors and a buzzer. I bought a couple of these instead. Between studying the PCB and the circuit diagram that came with the alarm, I was able to reproduce it on my breadboard instead of on the PCB. Sure enough, placing the two probes in water closed the circuit. I replaced the buzzer with an LED so I could see what was going on. I attached the circuit to the Arduino proto shield, and had it feed into one of the digital I/O ports. I wrote some quick and dirty Wiring code so that when water not present (i.e. the circuit was open and no current was detected on that I/O port) the LED was switched on. Really at this point, I didn't need a microcontroller, I could have presumably achieved the same thing with a NOT gate. At this point, I wanted to make the sensor remotely queryable. I bought a BlueSMiRF Silver Bluetooth modem, which I attached to the TX and RX lines of the board (I first configured it by attaching the USB-TTL cable to it and using Minicom on my laptop). I extended the Wiring code to provide a rudimentary prompt, and accept a command to check if water was present. I think around this time it also dawned on me that I could use the digital I/O pins as a switch. When they're "high" they provide power. So rather than constantly running a current through the water, I only needed to briefly power up the water detection circuit, see if the circuit closed or not, and then report if water was present if it did. I much preferred this, as at the time, I was endeavouring to power the whole sensor off a 9 volt battery. I figured I'd get much better battery life if I wasn't running a current through the water the entire time. I should point out that I did some "tongue tests" in a glass of water while the circuit was powered up, and couldn't detect a difference between when the circuit was on or off. The last thing I wanted to be doing was zapping the cats! At this point, the Wiring and Arduino work was pretty much complete. I setup ser2net on the MythTV server, so that I could just connect to port 4000, and be connected to the water sensor.
apollock@icarus:~$ telnet teevee 4000
Trying 172.16.0.9...
Connected to teevee.andrew.net.au.
Escape character is '^]'.
ser2net port 4000 device /dev/rfcomm0 [9600 N81] (Debian GNU/Linux)
waterbowl> s
Water is present
waterbowl>
telnet> q
Connection closed.
apollock@icarus:~$
The Wiring code running on the Arduino board is checked in here. Next, I wanted to monitor this with Nagios. One thing I found with the Bluetooth connection was that it wasn't all that reliable. Not every connection to port 4000 resulted in a connection with the water sensor. I elected to write some standalone code that submitted results to Nagios by way of a passive check, rather than having Nagios try to actively monitor it. Again, trying to conserve energy, I decided to only check the sensor once every 8 hours. So I wrote a Python daemon, which tried to be as robust as possible. If at first it doesn't make a connection on its 8 hourly schedule, it keeps trying until it does. Nagios itself has some freshness detection for this monitor, so if no passive result is submitted within 8 hours and one minute, Nagios alerts that something is possibly wrong with the sensor itself. (The original intent was to deal with the situation where the battery went flat) This is the Nagios service definition I've got. Some of it may be unnecessary or redundant:
define service  
        host_name                       teevee
        service_description             Cat water bowl
        check_command                   check_stale!2!"Check water bowl monitor is on and reachable"
        normal_check_interval           480
        notification_interval           240
        active_checks_enabled           0
        check_freshness                 1
        freshness_threshold             28860
        max_check_attempts              1
        check_period                    24x7
        use                             generic-service
        stalking_options                o,w,c
        contact_groups                  everyone
 
The code for the Python daemon is checked in here. So everything was going swimmingly, apart from I couldn't get even 24 hours of monitoring on my conservative 3 times a day schedule, and the Bluetooth modem configured for all of its power saving options, and the water sensor itself only being powered on when it was performing a check. There wasn't much more I could do to try and reduce power consumption, at least with my limited electronics knowledge. Perhaps using Zigbee instead of Bluetooth would have helped, but I still think I'd have been going through 9 volt batteries more quickly than I'd have liked. I also had a brief foray into solar powering the board. I thought maybe the lighting in the house would be sufficient to power the board. Of course this didn't work out. I'd also have needed to make the code running on the board more self-sufficient, and have it just provide a water status indication whenever it had enough power to do so, instead of being a fairly dumb device like it currently is. This all felt a whole level more complicated, and out of my league, and I wasn't interested in attempting this sort of remote-sensing exercise at this time. The Arduino board can also be powered by USB, so as I already had some long USB type A to type B cables (that had funky lights in them to boot), I decided to just get a wall wart that had a USB type A receptacle, and powered the Arduino board that way. So much for being completely "wireless". (I could have also gotten a general purpose DC power supply that was capable of spitting out 9 volts, but I doubted I'd get one with a sufficiently long cable, which is why I went for the USB-powered option, as I already had a cable long enough) Speaking of wires, the most challenging part was the probes for the water sensor. As they were going to be permanently in the cats' drinking water, I didn't want to contaminate the water with them. I figured plain untinned copper wire would be okay, since water pipes are copper. Finding untinned, unstranded copper wire was a real challenge. I started out using some FM antenna cable, but that was stranded, and the shielding was a nightmare to strip. It was also reasonably difficult to make go where I wanted it. What I really wanted was something more solid, that would flex and stay where I put it. I cannibalised a spare IEC power cable, but it was also stranded copper wire. I finally managed to obtain some solid-core CAT-5 cable from a hardware store, and this has worked exactly as I wanted. I haven't done any further work on the setup since getting the CAT-5 cable for the probe. Further improvements that I'd like to do at some point: The finished product I had a lot of fun with this project. I had a real sense of achievement, being able to go from concept to completion, and learn a few things about electronics along the way. I'm normally not a fan of messing around with hardware. Some photos of the project are here.

12 December 2008

Joey Hess: wherein I read too much

  1. Dishwasher, by Pete Jordan
  2. Windfalls, by Jean Hegland
  3. River of Gods, by Ian McDonald
  4. Powers, by Le Guin
  5. Real World Haskell, by O'Sullivan, Goerzen, Stewart
  6. Matter, by Iain M. Banks
  7. Ars Magica, by Tweet & Rein Hagen
Nice set of books. Pity I'm in the middle of all of them. Lately I have a hard time finishing many novels, I think because waiting for the plot to play out gets boring. Although River of Gods has mostly just confused me with too many viewpoint characters. And by this, where each box is a chapter, and that big box I'm just at the start of scares me: Dishwasher is fun light reading. If I'd thought to bring it to its owner, Jay, who misplaced it, I could have picked it up from where I left off months ago and read it on the plane. Double oops. Oh well, there's always my next doctor or dentist appointment. Powers is a probably great book by Le Guin. I hope there are many more to come, but the tendancy is to savor what's available. Also, I have it in dead tree edition, which I tend to save up for when I need them. Windfalls is such a dead tree book, hibernating in the yurt for me to get back to them some day. I may have to start it over, since it's pretty involved, and rather out of my usual comfort zone. Real World Haskell is coming along well, I hope. Matter hasn't pulled me in yet, oddly. Ars Magica I've been flipping through the PDF of idly.
Anyway, after all that, turning up a random story generator in 1 kilobyte of code couldn't help but feel like a relief.

2 November 2008

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.

23 October 2008

Adam Rosi-Kessel: Republic National Committee Helps Obama Fundraising

The only plausible result from this RNC mailing, I think, is increased fundraising for Obama over the next few days:
Terrorists Dont Care Who They Hurt

"Terrorists Don't Care Who They Hurt"

For the nearsighted, the front of the mailing says “Terrorists Don’t Care Who They Hurt” and inside: “Why Should We Care What They Have to Say? … Barack Obama. Not Who You Think He Is.” I would be surprised if the Obama campaign doesn’t get a measurable bump in donations for every mailing like this. What I really wonder is how intelligent Republican party members tolerate this sort of thing. Aside from Colin Powell, are other high-IQ Republicans voting against their party because of these tactics? Or do they just believe any means justify the ends? My pet theory as to why these attacks are useless (at best) to the GOP is that they don’t resonate with anything the voters are seeing. The GOP implies Obama is a muslim terrorist who is inexperienced and risky and also an extreme liberal/socialist left-winger (I haven’t heard “communist” yet from the mainstream), while what the electorate sees in the debates, ads, and campaign appearances is an uncannily steady, balanced, articulate individual who comes across as a moderate on most issues (note Obama’s theme of returning to Reagan-era taxation levels!) At least with the “flip-flopper” attacks (and maybe even the Swift-Boat attacks) on John Kerry, there was something people could see that somewhat corresponded with the attacks, even if the underlying facts didn’t actually pan out. Here, the chasm between the nature of the attacks and the visible target is so great, they could only help energize those who are already hard-core partisans. The lesson here is that if you want to launch misleading, baseless attacks against your opponent, at least find some kernel of truth to base them on. On a similar note, I agree with Aaron Swartz that ACORN deserves our financial support. Finally, I predict a bunch of astroturf comments to this blog entry. I won’t bother to respond if the comments fail to say anything intelligible. Technorati Tags: , , , , ,

Adam Rosi-Kessel: Republic National Committee Helps Obama Fundraising

The only plausible result from this RNC mailing, I think, is increased fundraising for Obama over the next few days:
Terrorists Dont Care Who They Hurt

"Terrorists Don't Care Who They Hurt"

For the nearsighted, the front of the mailing says “Terrorists Don’t Care Who They Hurt” and inside: “Why Should We Care What They Have to Say? … Barack Obama. Not Who You Think He Is.” I would be surprised if the Obama campaign doesn’t get a measurable bump in donations for every mailing like this. What I really wonder is how intelligent Republican party members tolerate this sort of thing. Aside from Colin Powell, are other high-IQ Republicans voting against their party because of these tactics? Or do they just believe any means justify the ends? My pet theory as to why these attacks are useless (at best) to the GOP is that they don’t resonate with anything the voters are seeing. The GOP implies Obama is a muslim terrorist who is inexperienced and risky and also an extreme liberal/socialist left-winger (I haven’t heard “communist” yet from the mainstream), while what the electorate sees in the debates, ads, and campaign appearances is an uncannily steady, balanced, articulate individual who comes across as a moderate on most issues (note Obama’s theme of returning to Reagan-era taxation levels!) At least with the “flip-flopper” attacks (and maybe even the Swift-Boat attacks) on John Kerry, there was something people could see that somewhat corresponded with the attacks, even if the underlying facts didn’t actually pan out. Here, the chasm between the nature of the attacks and the visible target is so great, they could only help energize those who are already hard-core partisans. The lesson here is that if you want to launch misleading, baseless attacks against your opponent, at least find some kernel of truth to base them on. On a similar note, I agree with Aaron Swartz that ACORN deserves our financial support. Finally, I predict a bunch of astroturf comments to this blog entry. I won’t bother to respond if the comments fail to say anything intelligible. Technorati Tags: , , , , ,

22 October 2008

MJ Ray: The Phone Coop, Best Social Enterprise 2008

a phone
ThePhoneCoop Congratulations to all our friends at The Phone Coop for winning the Best Social Enterprise Award at the Enterprising Solutions Awards 2008 yesterday. (TTLLP is an agent and I’m a member personally too.) Longer report at Cooperatives-UK. Comiserations to Barnsley Building Society, who are merging into Yorkshire Building Society after having 10m with collapsed Icelandic banks. Still, it survived further into the banking crisis than even the biggest of the demutualised building societies.

Next.

Previous.