Search Results: "rra"

1 November 2009

Dirk Eddelbuettel: Adventures with Comcast: Part ohnoesnotanotherone in an ongoing series

Regular readers of this blog (yes, both of you!) may remember the computer/broadband/ directory that this post appears in as the collection of my Comcastic (yeah right) experiences with my ISP. But I think this week may top everything. I'll just try to jot down some notes before I forget all the gory details:

31 October 2009

Frank S. Thomas: Automatic generation of a C header from Fortran code?

Dear Lazyweb, In my newest project I need to use Fortran routines and variables in C. From the source code point of view this requires only to declare the needed Fortran entities in your C code whilst taking the right types of the variables and the name mangling of the Fortran compiler into account. Here is an example. Consider you have the following Fortran code:
module X
  real, dimension(0:1) :: v
 
  subroutine Foo(A, b, c, &
    & D)
    integer, intent(in) :: a, &
      & B
    real, intent(out) :: C, d
    ! <Foo's body>
  end subroutine
end module X
To use the array v and the subroutine Foo() in C, you need to add (something like) the following declarations to your C source code:
extern float x_mp_v_[2];
 
void x_mp_foo_(int* a, int* b, float* c, float* d);
If only a handful of Fortran routines are needed to be called from C, declaring them by hand may be feasible. This is however error-prone and becomes impracticable for more than a handful of routines. Especially if the routine signatures change frequently. So what I d like to have is a tool that generates a C header file containing all declarations of Fortran entities from a given Fortran source file. Or if such tool does not exist, a tool that extracts variable declarations and routine signatures from a Fortran source file into a format that is easier to parse than Fortran itself would also be helpful. Any suggestions?

28 October 2009

Russell Coker: New Play Machine

Update:
Thanks to Sven Joachim and Andrew Pollock for informing me about /etc/init.d/mountoverflowtmp which exists to mount a tmpfs named overflow if /tmp is full at boot time. It appears that the system was not compromised. But regular reinstalls are always a good thing. On the 24th of August this year I noticed the following on my SE Linux Play Machine [1]:
root@play:/root# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda 1032088 938648 41012 96% /
tmpfs 51296 0 51296 0% /lib/init/rw
udev 10240 24 10216 1% /dev
tmpfs 51296 4 51292 1% /dev/shm
/dev/hdb 516040 17128 472700 4% /root
/dev/hdc 1024 8 1016 1% /tmp
overflow 1024 8 1016 1% /tmp The kernel message log had the following:
[210511.546152] su[769]: segfault at 0 ip b7e324e3 sp bfa4b064
error 4 in libc-2.7.so[b7dbb000+158000]
[210561.527839] su[778]: segfault at 0 ip b7eb14e3 sp bfec84d4 error 4 in
libc-2.7.so[b7e3a000+158000]
[210585.270372] su[784]: segfault at 0 ip b7e044e3 sp bff1b534 error 4 in
libc-2.7.so[b7d8d000+158000]
[210595.855278] su[789]: segfault at 0 ip b7e014e3 sp bfd18324 error 4 in
libc-2.7.so[b7d8a000+158000]
[210639.496847] su[796]: segfault at 0 ip b7e874e3 sp bf99e7b4 error 4 in
libc-2.7.so[b7e10000+158000] Naturally this doesn t look good, the filesystem known as overflow indicates a real problem. It appears that the machine was compromised. So I ve made archival copies of all the data and reinstalled it. As the weather here is becoming warmer I ve used new hardware for my new Play Machine. The old system was a 1.8GHz Celeron with 1280M of RAM and two IDE disks in a RAID-1 array. The new system is a P3-800 with 256M of RAM and a single IDE disk. It s a Compaq Evo which runs from a laptop PSU and is particularly energy efficient and quiet. The down-side is that there is no space for a second disk and only one RAM socket so I m limited to 256M that s just enough to run a Xen server with a single DomU. I put the new play machine online on Friday the 23rd of October after almost two months of down-time.

27 October 2009

Leo 'costela' Antunes: Vodafone mobile USB modem configuration

I had to struggle a bit with the mobile stick I just got from Vodafone and thought it might be useful to write it down somewhere. The Huawei K3520 (recognized automatically by Linux 2.6.31 as a E620 USB Modem ) seems to work without many problems, the only hardware related issue being that sometimes, seemingly at random, the memory stick part will be loaded and sometimes just the USB modem part. The Vodafone Germany specific configuration, on the other hand, wasn t so easy to find online. The working config I currently have with NetworkManager 0.7.1 is:
Number: *99# (this is the default, but it warrants an explicit mention since I ve found other examples online with *99***1# , and that didn t work)
Username: vodafone
Password: vodafone
APN: web.vodafone.de (this seems to vary wildly from country to country) The rest is either default or empty.
And lastly, taken from this LP bug, I had to change
<deny send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.PPP"/>
to
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.PPP"/>
in /etc/dbus-1/system.d/NetworkManager.conf, to avoid the Looks like pppd didn t initialize our dbus module error. After all this the connection still needs a push to work (it rarely if ever works on the first try and I haven t dug deep enough to decide if this is a Vodafone, a driver or a NetworkManager problem), but after connecting everything is shinny.

Patrick Schoenfeld: Things that make you a good programmer

If you ever wondered if you are a good programmer (not), you might think about the following points:

1. Repeat yourself. How else would you keep yourself busy, if your customer has new requirements?

2. Re-Using code is for people who take the other side of the street if a big dog walks along. No risk, no fun. How else would you find out that the common idiom you use is really the way the job has to be done?

3. If you have a coding convention (e.g. how code has to be indented): Just ignore it. Its a good thing to have editors go crazy, when trying to automatically detect the indenting of a source file. By always confusing the editor you keep up the fun of the people, who try to change your code. It would be too boring for them, to simply edit the file, without the quiz which quoting applies to your code. Extra points for those who additionaly (to mixing tabs, spaces, 4 and 8 space, expandtab and no expandtab) write a vim modeline into their file that - by guarantee - does not match the indenting of the file.

4. If you can complicate things: Do it. Numeric indices in arrays can be exchanged by arbitrary strings, this makes your code more interesting. Especially if you have to move elements in that array. And complicated codes makes people, who don't know it, think that you are a good programmer. One step nearer to your goal, isn't it?

5. When working with different classes invent a system that auto-loads the classes you need. Don't document it, that would be a risk for your job. Its not neccessary anyway, because good programmers like the riddle and finding out what gets called, where and why, is a simple but entertaining riddle. After all documenting is a bad idea as well. Especially if you make your system open source, because with a good documentation, it might be to easy for competitors to use your code to make money.

6. If you find ways to do extra function calls: Do it. It gives you the chance to refactor your code, if the customer notices that it is too slow. Great opportunity, hu?

(But, seriously: Don't hear on me. Its just a cynical way to express my feelings.)

Asheesh Laroia: Will the last to leave kindly turn out the light? / geociti.es

Today is Monday, October 26. Someone at Yahoo will go home tonight and, on the way out, turn off geocities.com. Update: Tue, 27 Oct 2009 15:17:50 -0400 Geocities is finally offline. Pages say:
Sorry, the GeoCities web site you were trying to reach is no longer available.
To commemorate it, I bought geociti.es. I intend to do what I can to keep the Geocities pages on the web. I am part of the Archive Team, an independent group of amateur archivists racing to rescue the web from destruction at its own hand. In late 1994, Geocities began offering free web hosting as Beverly Hills Internet. A decade ago, Yahoo bought Geocities. In December 1998, one-third of all web users visited the website. As recently as March 2009, 11.5 million unique visitors arrived there. Today, according to Alexa Site Info, Geocities ranks somewhere between the New York Times and the Washington Post in pageviews. And today, Geocities.com shouts:
GEOCITIES IS CLOSING ON OCTOBER 26, 2009.
Tomorrow, Geocities' website will be closed for good if Yahoo sticks to that promise. The amount the Archive Team has downloaded is around one terabyte. That's all we seem to be able to reach; many pages were deleted months ago when the archiving effort began. The archiving is continuing as I write this. Think of it. Fifteen years of history, memories for millions of people, the birth of a generation on the web. More personal embarrassment than all the POG games put together. It fits on an $80 piece of storage equipment -- at least, that's what we managed to find before Yahoo erases it all. Initially, when I met Jason Scott of the Archive Team, he told me he wanted to download Geocities and share it by mailing hard drives around. I told him I wanted to hoist it back on the Web. He came around, and we and the rest of the Archive Team have put Geocities back online. Geociti.es is not the greatest website in the world, no. This is just a tribute. P.S. Major thanks to John Joseph Bachir for the paperwork assist.

26 October 2009

Robert Millan: fake DSNs


Dear lazyweb, this morning I got bitten by fake Delivery Status Notifications. You ve probably seen this a thousand times:
  • Spammer sends mail to non-existant user in existant domain.
  • Idiotic mail service accepts mail, even though:
    • My domain s SPF record is telling them not to.
    • Destination address doesn t even exist.
  • Another component of idiotic mail service (hurray for qmail modularity!) realizes this address is invalid, and generates a DSN for the mail sender, even though they don t really know who that is.
  • I receive a gazillon of bounces informing me that some mail I didn t send couldn t be delivered.
  • Do you know of any blacklist containing all hosts and/or domains that do this? Alternatively, I think a blacklist containing all qmail domains would probably cover most of it.

Matt Zimmerman: Open vs. open vs. open: a model for public collaboration


Introduction In the course of my work in Canonical and Ubuntu, I hear from a lot of folks who want to start an open software project, or have started one and want to make it work better. Some of them represent companies, while others are working on a volunteer basis. It s great to see so much interest in this area, and I m excited to see so many projects wanting to become more open. The trouble is, people don t always mean the same thing when they talk about opening their project. The focus of this article is to establish a basic model for open collaboration which I hope will be useful in future discussions of this type. In the spirit of openness, rather than creating a document for my own use, I ve opted to develop this on my blog instead. This is not a how-to document, just a map of the problem space. I ll use examples from software projects, because I m most familiar with that field, but I believe these principles are more broadly applicable. Open (available) In order for your project to be open to anyone, they need to be able to find out about it and experience it for themselves. Being open, in the sense of availability, is about ensuring that the people you want to reach have access to your content. The types of access that people need will vary depending on the content, but the basic principle is enabling people to obtain and use the content in an appropriate way. For software projects, this means that the code is released under a free software license. This allows all the various denizens of the free software ecosystem to make use of your software as appropriate for their role: developers can inspect and improve it for themselves, packagers can standardize and distribute it, and users can download and run it. Availability seems to be the most well understood type of openness. Even so, many project leaders still hesitate, and delay availability as long as possible ( until it s ready ). What s more, many projects simply stop there, and never explore the other dimensions of openness. Open (transparent) The next flavor of openness is about transparency. This means enabling people to find out about what is happening in your project. This means moving beyond the end result (e.g. software), and starting to involve people in the creative process behind it. In an open software project, this means allowing read access to discussion forums, source code history, bug reports, and so on. It means letting people see into the sausage factory where the software is made. This is much harder than slapping a license on your source code. Not only does it require the infrastructure to store, process and present this information, it also means revealing yourself. Creating products is about simplifying things for its consumers, letting them get on with their work without worrying about how or why the product exists. Successfully opening a project means going beyond this producer/consumer relationship and letting them see inside. This gives people the opportunity to get excited about what s coming next, and to build on it. This can be a very difficult adjustment to make. Becoming transparent means letting people see the problems with the project as well as the solutions. This opens up the project and its members to criticism, which they will need to process and even respond to publicly. This is a whole new level of accountability which may be unfamiliar to people working in private industry. Another challenge of transparency, at least in a corporate scenario, is maintaining confidentiality where necessary. While most discussions and activity should be transparent, customers, partners and management will require that some information remain confidential. Care needs to be taken to ensure that neither transparency nor confidentiality is compromised. Transparency enables the formation of a true community, made up of more than just consumers. Community members can begin to feel involved in the project, and build relationships with project participants. Open (for participation) The third type of openness is open participation. This builds on transparency by creating a feedback loop: people observe activity in your project, react to it, and then actually change its course. The change might be a small one, like helping to improve your work in progress, or a large one, like helping to redefine project goals. In a software project, this means things like opening up read/write access to the source control repository, design documents, and bug reports. This type of involvement promotes a sense of shared ownership for everyone involved in the project, not just its founders. It becomes ours rather than yours . This can be psychologically challenging, as it means giving up full control, and being subject to checks and balances of power. Corporate projects seem to have the most difficulty with this. A fully participatory project will support open participation in even the highest levels of decision-making, for example through leadership elections which are open to anyone. The community becomes central, rather than auxiliary, and the success of the project will depend on it. Conclusions People and organizations who want to truly go open need to see this as a journey, one which will require that they change their methods of communication and decision-making, not just how their content is published. The extent to which they are able to fully embrace the open paradigm will determine the potential benefits to the project.

23 October 2009

Decklin Foster: Score: 5, Privileged

(No apologies to the original.) I get the impression that the Windows 7 launch is a lot like seeing an old boyfriend suddenly show up on your doorstep wanting to get back together. He's had some work done, apparently: stomach stapling to take off some of the weight, teeth whitening, and a radical nosejob to make him look as much like your current boyfriend as medical science will allow. He's handsome, of course, almost too handsome. He still uses far too much product in his hair and carries that desperate look in his eyes. The fragrant haze around him is the cologne he overuses to mask the scent of failure. But standing there in that form-fitting t-shirt, you'd almost forget for a moment what a psycho he was- how he used to shut down in the middle of a date and forget everything you were talking about and how he was only happy when you were paying attention to him. You'd almost forget about carrying around his legacy baggage or those nights when, for seemingly no reason at all, he would simply stop speaking to you and when you asked what was wrong he'd just spit a string of hex code at you and expect you to figure it out. You complained about him for years before finally deciding to get rid of him, and here he is again. Though, somehow, he seems like a completely different person now. "I'm up here," he says when he catches you staring at his package. Tempted though you may be, you know that over time he'll get bored and slow down on you just like he always does. And then you'll be right back where you started: trapped. He keeps you by convincing you that you don't have a choice. You're just not smart enough for one option or rich enough to afford the other. "But I'm different now," he says, batting his eyes innocently. "I've changed." Indeed he has. Apparently, he's really into Kabbalah now or something like that. It's helped him discover loads of untapped potential in himself. But it also means that you'll have to buy all new furniture to fit with his understanding of feng shui. That's not the only change he has in store for you. The minute you let him move in, he'll have a new alarm system put in that succeeds only in preventing your friends from coming over on poker night. He doesn't love you, but he doesn't hate you, either. The truth is that he couldn't care less one way or the other. He's here because he doesn't want to be alone. Like all human beings, especially those well past their prime, he wants to feel wanted and, after a string of lost jobs and bad investments, he needs a place to stay. But all in all, he's OK. He's a seven. He'll do, I guess. UPDATE: There was a Hacker News thread about the Slashdot link that got killed before I could reply to someone who left a negative comment. I'll reproduce it here for the sake of anyone still scratching their head.
Thank you for replying instead of simply downvoting. There are assumptions in the structure of the original text that I don't think most of the people discussing it (here, or over there) appreciate. To wit: the narrative of technology belongs to men. Women are objects. The dumbest, easiest way to make that stick out (I did it over breakfast, ffs) is to swap the genders. It sounds "wrong". The emotional-abuse stuff is more creepy. The physical descriptions are more awkward because men aren't leered at in the same way. It's not about evening things out, it's about subverting what the text doesn't say outright by making it obvious. I am, I'm sure, as aware as you that "deconstruction" is not (anymore) a word you say to sound smart, rather a word you avoid saying to avoid sounding like you're trying to be pseudo-smart, but sometimes you just gotta call a spade a spade. You're free to disagree with that (I assume you still will), but I think "not even wrong" is a little over the top.

Kees Cook: TPM as RNG

I was reminded about some TPM coding I d done to get random bytes from the pRNG on my TPM-enabled system from Matt Domsch s recent post. I m not fully convinced that the pRNG of the TPM is an appropriate source of entropy, but it does pass my simple FIPS-140-2 test. I had to find the Intel TPM docs to figure out how to enable TPM on my system. It was under Advanced / Peripherals . I was expecting it under Security , like every other BIOS I d seen. After that:
$ sudo apt-get install trousers tpm-tools
...
$ sudo modprobe tpm_tis
$ dmesg grep -i tpm
[676618.167313] tpm_tis 00:07: 1.2 TPM (device-id 0xFE, rev-id 70)
$ sudo service trousers start
...
$ tpm_version
TPM 1.2 Version Info:
Chip Version: 1.2.2.16
Spec Level: 2
Errata Revision: 1
TPM Vendor ID: WEC
TPM Version: 01010000
Manufacturer Info: 57454300
$ ./tpm-getrand hexdump -C
00000000 61 07 23 ff 71 3e 25 e8 f0 d5 de a7 a3 07 21 dc a.#.q>%.......!.
I could run rngd with a named pipe, but it d be nice to have a new driver that could run a command instead to get the next 20000 bits. UPDATE: I ve implemented this in rngd now.

18 October 2009

Christian Perrier: 4621 potential "spams" left to review for me

A few of us are working on spam removal from Debian lists archives. The wiki page linked above explains how to report spam on Debian mailing lists. This is in short as easy as bouncing a mail to a specific address, from your favourite MUA. These "reported spams" then need to be reviewed. Once a given message has been identified as "spam" by enough DD's (there are many false positives in the candidates, particularly in non English-speaking mailing lists), it is removed from the archives. Many mails have already been removed and any help is welcomed. Since Frans Pop launched this for debian-boot, back in May, I use 1 or 2 hours every Sunday to this work. After working on debian-boot only, I gradually worked on reported spams in other lists. As of now, I only have 4 lists where I still have work to do: The Chinese and the Spanish ones are tricky because identifying spam there is much less easy (for Chinese, I'm quite conservative and only tag very obvious spam....for Spanish, I read enough of the language to be able to target spam). What about you? Will you be able to help the few of us who work on getting clean archives (noticeably, Sandro Tosi, Giacomo Catenazzi, Cord Beermann, Luk Claes, Frans Pop, Bastian Blank, Luca Falavigna, Michael Koch, Bernd Steinmetz, Thoomas Viehmann, Florian Ernst, Adam D. Barratt, to name thos ewho reviewed more than 1000 mails)? Working on lists in your own language might be a good idea (I'm particularly thinking about lists in German, Spanish, Chinese and French).

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

15 October 2009

Enrico Zini: Building a web-based API with Turbogears2

Building a web-based API with Turbogears2 I am using TurboGears2 to export a python API over the web. Every API method is wrapper by a controller method that validates the parameters and returns the results encoded in JSON. The basic idea is this:
@expose("json")
def list_colours(self, filter=None, productID=None, maxResults=100, **kw):
    # Call API
    res = self.engine.list_colours(filter, productID, maxResults)
    # Return result
    return res
To validate the parameters we can use forms, it's their job after all:
class ListColoursForm(TableForm):
    fields = [
            # One field per parameter
            twf.TextField("filter", help_text="Please enter the string to use as a filter"),
            twf.TextField("productID", help_text="Please enter the product ID"),
            twf.TextField("maxResults", validator=twfv.Int(min=0), default=200, size=5, help_text="Please enter the maximum number of results"),
    ]
list_colours_form=ListColoursForm()
#...
    @expose("json")
    @validate(list_colours_form, error_handler=list_colours_validation_error)
    def list_colours(self, filter=None, productID=None, maxResults=100, **kw):
        # Parameter validation is done by the form
        # Call API
        res = self.engine.list_colours(filter, productID, maxResults)
        # Return result
        return res
All straightforward so far. However, this means that we need two exposed methods for every API call: one for the API call and one error handler. For every API call, we have to type the name several times, which is error prone and risks to get things mixed up. We can however have a single error handler for all methonds:
def get_method():
    '''
    The method name is the first url component after the controller name that
    does not start with 'test'
    '''
    found_controller = False
    for name in pylons.c.url.split("/"):
        if not found_controller and name == "controllername":
            found_controller = True
            continue
        if name.startswith("test"):
            continue
        if found_controller:
            return name
    return None
class ValidatorDispatcher:
    '''
    Validate using the right form according to the value of the "method" field
    '''
    def validate(self, args, state):
        method = args.get("method", None)
    # Extract the method from the URL if it is missing
        if method is None:
            method = get_method()
            args["method"] = method
        return forms[method].validate(args, state)
validator_dispatcher = ValidatorDispatcher()
This validator will try to find the method name, either as a form field or by parsing the URL. It will then use the method name to find the form to use for validation, and pass control to the validate method of that form. We then need to add an extra "method" field to our forms, and arrange the forms inside a dictionary:
class ListColoursForm(TableForm):
    fields = [
            # One hidden field to have a place for the method name
            twf.HiddenField("method")
            # One field per parameter
            twf.TextField("filter", help_text="Please enter the string to use as a filter"),
    #...
forms["list_colours"] = ListColoursForm()
And now our methods become much nicer to write:
    @expose("json")
    def api_validation_error(self, **kw):
        pylons.response.status = "400 Error"
        return dict(form_errors=pylons.c.form_errors)
    @expose("json")
    @validate(validator_dispatcher, error_handler=api_validation_error)
    def list_colours(self, filter=None, productID=None, maxResults=100, **kw):
        # Parameter validation is done by the form
        # Call API
        res = self.engine.list_colours(filter, productID, maxResults)
        # Return result
        return res
api_validation_error is interesting: it returns a proper HTTP error status, and a JSON body with the details of the error, taken straight from the form validators. It took me a while to find out that the form errors are in pylons.c.form_errors (and for reference, the form values are in pylons.c.form_values). pylons.response is a WebOb Response that we can play with. So now our client side is able to call the API methods, and get a proper error if it calls them wrong. But now that we have the forms ready, it doesn't take much to display them in web pages as well:
def _describe(self, method):
    "Return a dict describing an API method"
    ldesc = getattr(self.engine, method).__doc__.strip()
    sdesc = ldesc.split("\n")[0]
    return dict(name=method, sdesc = sdesc, ldesc = ldesc)
@expose("myappserver.templates.myappapi")
def index(self):
    '''
    Show an index of exported API methods
    '''
    methods = dict()
    for m in forms.keys():
        methods[m] = self._describe(m)
    return dict(methods=methods)
@expose('myappserver.templates.testform')
def testform(self, method, **kw):
    '''
    Show a form with the parameters of an API method
    '''
    kw["method"] = method
    return dict(method=method, action="/myapp/test/"+method, value=kw, info=self._describe(method), form=forms[method])
@expose(content_type="text/plain")
@validate(validator_dispatcher, error_handler=testform)
def test(self, method, **kw):
    '''
    Run an API method and show its prettyprinted result
    '''
    res = getattr(self, str(method))(**kw)
    return pprint.pformat(res)
In a few lines, we have all we need: an index of the API methods (including their documentation taken from the docstrings!), and for each method a form to invoke it and a page to see the results. Make the forms children of AjaxForm, and you can even see the results together with the form.

14 October 2009

Patrick Schoenfeld: PHP and the great "===" operator

Lets suppose you've got an array with numeric indices:
[0] => 'bla'
[1] => 'blub'
Now you want to do something if the element 'bla' is found in that array.
Well, you know that PHP has a function array_search, which returns the key(s) of the found values. Lets say, you write something like this:
if(array_search($array, 'bla')) do_something

Would you expect that do_something would actually do something?
If yes: You are wrong.
If no: Great, you've understand some parts of PHP - insanitygoodness..

Actually, if 'bla' wouldn't have the index 0 it would work, because 1, 2, 3, 4, etc. is TRUE. But unfortunately PHP has some sort of implicit casting, which makes 0 behave like a FALSE, depending on the context. So following this, the if() works for all elements except 0.

You might be tempted to write
if(array_search... != FALSE)
But this wouldn't help you, because 0 would still evaluate to FALSE, leading to if(FALSE != FALSE) which is (hopefully obviously) never true.

A PHP beginner (or even an intermediate, if he never stumbled across this case) might ask:
Whats the solution for this dilemma?

Luckily the PHP documentation is great. It tells you about this. And additionally PHP has got this great operator (===), which causes people to ask "WTF?" when they hear about it for the first time. Additionaly to comparing the values to each other, they also check the type of the variable. This leads to the wanted result because 0 is an integer, while FALSE is Boolean. So the solution for our problem looks like this:
if (array_search($array, 'bar') !== FALSE)
Isn't this great?

12 October 2009

Christian Perrier: What marathon now?

So, now that I completed my 2009 program by running the Cologne marathon 6 months after my first one in Paris, I now plan the 2010 "season"..:-) (one point for you guys who told me that once you start you don't stop) The next step is definitely Paris. The race is close to my home, this is a great race in a great city at a great time. I really can't miss it. So, that one is registered. The point is "what about 'the other one'". I plan to run another marathon during that year, preferably during autumn. Actually, I would probably be able to run at least one more but, well, many people urge me to avoid exxagerating and that includes my beloved wife..:-) So, one more. Which one? At this very moment, I have about 4 options: So, at this moment, Berlin and Donostia have the lead. A good compromise could be running a marathon in Berlin and the 20km Behobia-San Sebastian run which is very popular in Basque country. We'll see..

10 October 2009

Jaldhar Vyas: Barack Obama is a Keynesian

pointless award I haven't written about politics since the election for several reasons. First and foremost, Obama won fair and square. While I might wish the other guy had won, I can't whine and pout or threaten to move to Canada like some people. The vox populi chose and that choice has to be respected. Secondly, one of the worst aspects of the current American political scene is the paranoid obsession with personalities in which the president is not just an implementor of policies good or bad, but personally responsible for the entire state of the cosmos. It started with Nixon, started getting alarming with Clinton and reached batshit levels of insanity with George W. Bush. But just because the left does it it, doesn't mean we have to follow suit. Although I figured Obamas policies would end up a trainwreck, I wanted to see what he actually did before calling him on it. The Nobel comittee isn't hoping and changing with me. In a decison that is bizarre even by the lax standards of a prize that long since jumped the shark, the President is to receive the Nobel Peace prize for...not being George Bush? It's difficult to see what substantive reasons they could have for their choice. But apparently one of these days he is going to make extraordinary efforts to strengthen international diplomacy and cooperation between peoples...democracy and human rights are to be strengthened. Well let's see now: Perhaps I am being a little unfair in not taking into consideration all the great things the president is going to do real soon now. It's just that I'm worried that this might be an attempt to sway him in the task of winning the war in Afghanistan (and more likely than not carrying it into Iran and Pakistan.) I take solace in the knowledge that heretofore Obama has shown a refreshing inclination to throw people under the bus when they are no longer convenient. If he can do that to the guy who says he wrote his book than some silly Norwegians won't be a problem.

9 October 2009

Martin Meredith: Most Awesome Warranty Ever!

If this product should fail in your lifetime, we will replace it at no charge. If the proeducts is damaged by aggressive music listeners sliding a rail, sliding down the emergency ramp of your aircraft, slammed in your locker, slammed in your car door, run over by a car, running into a wall, getting run out of town, mountain biking, road biking, sky diving, beating your boyfriend unmercifully, getting beat down by the man, blown up in an accidental experimentation with flammable substances or damaged in any other every day experience, it means you are living your life the way we want our product used! In these, or any other damaging events, we will replace the product for a 50% discount from retail.
Skullcandy rock! I m loving my new headphones

8 October 2009

Barry Hawkins: More Expensive and Complicated Equals Better: Carseats and Software

So I finally got around to checking out the TED site; I ve quickly become a fan. One of the first talks I watched was Steven Levitt s child carseats talk. Both the talk and the feedback comments on the TED site reminded me of things I see in software development. Here s the video if you haven t seen it.
<object height="326" width="334"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"><param name="allowFullScreen" value="true"><param name="wmode" value="transparent"><param name="bgColor" value="#ffffff"><param name="flashvars" value="vu=http://video.ted.com/talks/dynamic/StevenLevitt_2005G-medium.flv&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/StevenLevitt-2005G.embed_thumbnail.jpg&amp;vw=320&amp;vh=240&amp;ap=0&amp;ti=30&amp;introDuration=16500&amp;adDuration=4000&amp;postAdDuration=2000&amp;adKeys=talk=steven_levitt_on_child_carseats;year=2005;theme=unconventional_explanations;theme=presentation_innovation;theme=how_the_mind_works;theme=not_business_as_usual;event=TEDGlobal+2005;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;"><embed allowfullscreen="true" bgcolor="#ffffff" flashvars="vu=http://video.ted.com/talks/dynamic/StevenLevitt_2005G-medium.flv&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/StevenLevitt-2005G.embed_thumbnail.jpg&amp;vw=320&amp;vh=240&amp;ap=0&amp;ti=30&amp;introDuration=16500&amp;adDuration=4000&amp;postAdDuration=2000&amp;adKeys=talk=steven_levitt_on_child_carseats;year=2005;theme=unconventional_explanations;theme=presentation_innovation;theme=how_the_mind_works;theme=not_business_as_usual;event=TEDGlobal+2005;" height="326" pluginspace="http://www.macromedia.com/go/getflashplayer" src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" type="application/x-shockwave-flash" width="334" wmode="transparent"></embed></object>
Steven Levitt shows in his talk how 30 years of data on car crash fatalities imply that carseats do not outperform regular seatbelts for children ages 2 and up. Anyone who has a child or grandchildren will probably bristle at hearing that; as the father of a pre-schooler, it certainly gave me pause. We spent no small amount of time and decent chunk of money in selecting carseats for our child, thinking we had done our best to ensure our child s safety. For that matter, it would be illegal for us not to have done so. To see a decent-sized data sample suggesting my child would be better off in a seatbelt at her age is rather unsettling. By the end of the talk, I took away these observations: So, software professionals, does any of that sound familiar? It reminds me of numerous initiatives over the years that have led us inexorably to the software productivity morass we have slogged through for years now. I suppose the most heinous case study in my own experience would be J2EE and the insistence that it was the solution that any reasonable business application would choose for a platform. (Before you .Net folks jump on that one, DCOM and later the .Net enterprise stack was much the same.) And who hasn t read a benchmark or white paper with seemingly incontrovertible data depicted in highly-polished graphics insisting that Product Y is the one solution to address them all? I noticed that there were comments below the video on its page at the TED site, largely because the negative verbiage of the topmost comment jumped out at me. I took the time to read through them all (there were 36 at the time of this writing), and to my amusement, I saw parallels between them and how people react to questioning and examining our existing practices and means of developing software. See if any of these strike a chord: In recent years I ve been greatly encouraged by the willingness of companies to question whether or not the heavyweight frameworks and technology stacks are what they should be using. Helping companies slough off high-ceremony processes in favor of right-sized process that focuses on delivering the right software in a timely manner has been some of the more rewarding work I ve done the past several years. I think we have an encouraging number of people in the industry who are challenging the more expensive and complicated always equals better mantra. For the brave individuals willing to put these questions to the community at large, I hope you find some comfort in knowing that the resistance and rejection you will encounter is a thing to be expected; you are not alone in that respect. Here s hoping we continue to be open to self-examination, no matter what emotional responses it might provoke or what fear of the future it may stir up within us.

7 October 2009

Julien Blache: About box 2.0

You want to revitalize a dying, inactive free software project. How do you proceed?
  1. You write code, contribute, get involved in the community, get in touch with the previous developer(s) to try and join the team or take over the project. Failing that, you fork the project, because this is how free software works after all. Then, once you ve got something to show, you start talking about it;
  2. You set up a new forum, brag about it on the old one, arrange with the previous lead developer to make sure you can use the name and logo, then open a twitter account so users can follow the new forum s setup process minute by minute.
There s this saying about opensource/free software that says the logo and about box are the very first (and only) things that work in new/young projects (and sometimes that s also true for more mature projects, as we all come to know). Choice 2 above is the About Box 2.0. Unfortunately, that s the way a handful of people choose to revitalize mt-daapd/Firefly Media Server. Of course, not one among them can code or has actually got a clue about the current codebase. FAIL of epic proportions. Facepalm.

5 October 2009

Mart&iacute;n Ferrari: Nice

Last night I was about to sit down and write a post about how happy I was. After a long search, I found a beautiful appartment in Nice, with my flatmates we're cleaning and arranging stuff, we're planing parties and inviting friends to come over... When we were doing the moving, I started to see the city differenty: this time it was not just a visit. It made me remember the taste of starting from scratch, like when I did when I was 21. But some jerks ruined the party. Before sitting to write the blog post, I said I better check that the car is parked in a good place, tomorrow is Monday. And all of a sudden three guys assaulted me, making me a pass thru a real bad moment, and taking the car and house keys. Nothing happened to me, luckily, but I have no more car. I spent the day making things straight with police, insurance, etc. I had to spend a HUGE load on money to change a stupid door lock (I still cannot believe that people pay that much money for this "security" stuff), and more importantly, they ruined my mood. I'm really okay, so no need to help me or anything, I just wanted to say this somewhere. Tags: Planet Lugfi, Planet Debian

Next.

Previous.