OpenCL: first investigations with an NVIDIA card
I'm taking a look at OpenCL at the moment, with the vague intention of hooking it up to Resolver One. In case you've not heard about it, OpenCL is a language that allows you to do non-graphical computing on your graphics card (GPU). Because GPUs have more raw computational power than even modern CPUs, in the form of a large number of relatively slow stream processors, this can speed up certain kinds of calculations -- in particular, those that are amenable to massive parallelisation.
Until recently, the two main graphics card manufacturers had their own languages for this kind of general-purpose GPU computing; NVIDIA had CUDA, and ATI/AMD had their Stream technology. OpenCL was created as a way of having one language that would work on all graphics cards, so although the tools for developing using it are not currently as good as those for CUDA (which has been around for a long time and has great support), as a longer-term investment OpenCL looks to me like the best one to be looking at.
It took a little bit of work to get something up and running on my machine here at work, so it's probably worth documenting to help others who are trying the same.
Playing with NLTK
I spent some time this afternoon playing with NLTK, the
Python Natural Language Toolkit; the book
is highly recommended. I couldn't resist sharing the results of the first time I
tried its generate
function, which takes a particular text and tries to automatically
generate more text in the same style.
First, from the Book of Genesis:
In the selfsame day entered Noah , and asses , flocks , and Maachah . And Joseph said unto him , Abrah and he asses , and told all these things are against me . And Jacob told Rachel that he hearkened not unto you . And Sarah said , I had seen the face of the air ; for he hath broken my covenant between God and every thing that creepeth upon the man : And Eber lived after he begat Salah four hundred and thirty years , and took of every sort shalt thou be come thither .
Next, Jane Austen:
[ Sense and Sensibility by Jane Austen 1811 ] CHAPTER 1 The family of his relations , I know Marianne ' s indisposition , beyond giving time for the world to seeing YOU .-- Very far from being weary of her feeling how more than commonly joyful . He was four years . Every thing was disregarded . I had called in Berkeley Street , January . " Mrs . Jennings , sagaciously smiling , " For my part , not being Willoughby , where much of his fate with Miss Morton , with two pointers playing round him ,
And finally, from a corpus of IRC conversations:
now im lost i agree i saw the whole thing JOIN PART google 's start page .. lol yeah , he said this morning he is hoping they win tonight im gay ....... im happy as hell ...... jus aint #### lol U42 , how are you NICK : U23 what a combo hehehe JOIN . ACTION pictures the blues brothers behind that chicken wire screen . (((((((((( U34 ))))))))))))) Hi U7 ......... how are ya ll gotta watch my manners or she wo n't you play another somebody done somebody wrong song ? JOIN . ACTION wonders if U16
Scarily accurate :-)
Joining TheyWorkForYou to Twitter
I'm putting together some spreadsheets that we're going to use to publicise Resolver One over the coming UK electoral campaign, and one set of data I needed was a list of Members of Parliaments' Twitter accounts indexed by an ID that I could use with TheyWorkForYou.com. I was delighted to discover Tweetminster, a site analysing MPs' tweets, and in particular their Twitter list of all UK MPs' accounts, but there was no link to TWFY.
So, given that no-one else seems to have done it, here's my own list:
- A Resolver One file listing Twitter accounts for TheyWorkForYou
person_id
s - For those of you unlucky enough to not have a copy of Resolver One, here's a CSV file with exactly the same data.
Hope someone finds it useful. It's up-to-date as of this posting, and I'll endeavour to keep it up-to-date, at least for as long as we need it at work :-)
3D graphics in Resolver One using OpenGL and Tao, part II: an orrery
In my last post about animated 3D graphics in Resolver One (the souped-up spreadsheet the company I work for makes), I showed a bouncing, spinning cube controlled by the numbers in a worksheet. Here's something more sophisticated: a 3D model of the planets in our solar system, also know as an orrery (click the image for video):
3D graphics in Resolver One using OpenGL and Tao, part I
I've been playing around with 3D graphics recently, and decided to find out what could be done using .NET from inside Resolver One. (If you haven't heard of Resolver One, it's a spreadsheet made by the company I work for -- think of it as Excel on steroids :-)
I was quite pleased at what I managed with a few hours' work (click the image for video):
Fix for pygame/PyOpenGL/NeHe tutorial windows not disappearing when run from IDLE
It's a long weekend here in the UK and I thought I'd spend some time working through Paul Furber's Python translations of the well-known NeHe OpenGL tutorial, which use the pygame and PyOpenGL libraries. (This is all with Python 2.6 on Windows XP.)
I noticed that when I ran the sample files from IDLE, the windows did not close -- it didn't matter whether I used the close box or hit escape; the program would seem to exit, but IDLE was in a messy state, and the OpenGL window would sit there not repainting.
Googling didn't turn up anything that sounded relevant, but this archived mailing list message
mentioned a pygame.quit()
function that sounded relevant. I tried putting this
at the end of each of the samples, and it seems to fix the problem.
Ada Lovelace day
I'm a day late, but having just heard about Ada Lovelace day I couldn't but help make a slightly schmalzy post.
The aim of the day is to celebrate women who excel in technology, and while I've worked with some great women developers over the course of my career, there's one who stands out. Yes, it's my mother :-)
Back in the 60s, Yvonne Thomas was one of the first women to do Electronic Engineering (or Electron Physics as it was then called) at Southampton University, and she went on to work at various defence-related companies (that being the best place to be in tech back then). By 1974 she was working on ALGOL compilers at (I think) ICL, and then she decided to pack it in to raise her unruly -- but generally grateful -- offspring. Von, thanks for doing that, and for bringing me up to be technically able. There are few coders out there who can honestly say that they had programming fed to them in the womb, and I'm glad to be one of them.
She's still coding, and is now happily building an ever-expanding web application that links together all the information she's found in her genealogical researches.
Right, enough sentimentality. Back to our regularly-scheduled gadget- and business-of-software-related blogging...
R in Resolver One (and perhaps IronPython generally)
We've just announced the winner of this month's round of our competition at Resolver Systems, and it's a great one; Marjan Ghahremani, a student at UC Davis, managed to work out how you can call R (a powerful statistical analysis language) from our spreadsheet product Resolver One. You can download a ZIP file with a detailed PDF describing how it works and a bunch of examples.
If you're not interested in Resolver One, but want to use R from your own IronPython scripts, you may be able to do that too, using her instructions as guidelines -- I've not tried it myself, but there are no obvious blockers. If you do try it out, I'd love to hear how it goes.
xmlrpc
One of our customers had been asking about how to call XMLRPC servers from
Resolver One. It doesn't work in version 1.3, and he was having problems getting
it to work in 1.4. The problem turned out to be simple and fixable, and unlikely
to affect other people, so I'm proud to present a really simple XMLRPC/Resolver One example
that you can use as a starting point: a Python script that creates a server
exposing an is_even
function (which tells you if a number is even or not), and
a Resolver One spreadsheet that uses it. There are only two lines of code in
the spreadsheet, which is pretty cool :-)
Getting phpBB to accept Django sessions
phpBB is a fantastic bulletin board system. We use it at Resolver Systems for our forums, and it does a great job.
However, we're a Python shop, so we prefer to do our serious web development -- for example, the login system that allows our paying customers to download fully-featured unlocked versions of our software -- in Django.
We needed to have a single sign-on system for both parts of our website. Specifically, we wanted people to be able to log in using the Django authentication module, and then to be able to post on the forums without logging in again. This post is an overview of the code we used; I've had to extract it from various sources, so it might not be complete -- let me know in the comments if anything's missing.