Archive for the ‘Programming’ tag
Canon Rebel XSi Video Recording Hack (HOWTO)
Thanks to some ingenious Russian hackers, the Rebel XSi I won in a poker game can record video*. Of course, being Russian, that’s how they wrote the documentation.
Here’s a tiny short I call “Rain DOFs” to illustrate.
I fumbled around figuring this out at first, then read these not-much-better instructions and tried again. Here’s the simple way:
- Enable LiveView (check your manual — maybe unnecessary, but mine is on).
- Turn the camera on.
- Plug it into the machine via USB.
- Wait for the loading light on the camera to stop (in future I am going to try removing the memory card).
- Run eos_movrec.
- If it doesn’t work click “reconnect” (the button with the USB symbol on it).
It’s reasonably fun to play with, but for “serious” use the frame rates would need to get up to ~24FPS and I’d want a smoother control for focus racks (still — it’s fun to be able to do them at all).
* At no more than about 18 FPS, out to a laptop, with no sound.
Business Analysis is like Criminal Profiling
I’m a business analyst and I often struggle to explain precisely what that entails. I’m currently working on a project to develop software for some Very Important Users, who don’t have much time to meet with me, never mind the development team. Agile methodology says that the users should hang out directly with the developers and business analysts are useless, so it’s my job to prove them wrong.
So I got as much time with the users as I could, and then made up a requirements document based on my best guesses about how they’d like to do business. When the developers ask me questions, I make up answers. I can do this because I’ve learnt just enough about the users’ business that I can model the users in my head, and then do two things with the model:
- abstract and reduce their unfocused desires into a pure kernel of business need
- figure out what they want in the future based on what they say they want in the present
Business analysts are a lot like criminal profilers, who learn what they can about a criminal (in fiction usually a serial killer), build a model of the criminal in their head, and then do two things with the model:
- abstract and reduce into a pure kernel of criminal intent
- figure out what they’ll do next based on what they’ve done in the past
My two favourite fictional profilers are Frank Black in Millennium, who has a superpower of being able to see the world the same way the criminals do, and Fitz in the British version of Cracker, who is a professional psychologist with plenty of his own dysfunctions. Maybe someday they’ll make a TV show about how cool I am?
Lab Journal: Getting The Kinect Working With OS X
I bought a Kinect today. My 360 is out West somewhere and gaming, while still fun, is not something in which I am choosing to invest my time. However, the Kinect is, I think, a revolutionary device WITH WHICH I MUST PLAY.
Reproduced below are my step-by-step lab notes for getting it up and running on OS X. They’re pretty basic, and the documentation is pretty good, but still — I took notes and might as well publish.
Blogging Has Spoiled Me
I have been working on an essay about Asylum‘s film-theoretic grounding FOR MY ENTIRE LIFE. It is seriously becoming a giant panic-attack-inducing slog… and I blame blogging.
Most of what I write on here is a first draft, and I’m sure it shows. My blogging output, for better or worse, is prolific. But I hate going back and doing revisions for some reason. I have pages of notes that I find it impossible to piece together into a written flow.
Maybe that’s it though. Looking some of my notes I have no idea WTF I was thinking, and it seems that the moment to shape the prose is lost, the state of flow has passed:
AAA Is partly a film about cultural practices, and is necessarily insufficient wrt context, as is QVM. did aaa become an exotic backdrop for my own exploration? sadism / victorian repression
Good writing, supposedly, is like sculpture — you start with raw materials and hack away until you have an elephant. Except I don’t even sculpt like that… I make things from smaller pieces, not larger.
Or maybe it’s software that’s ruined me? The idea of writing a program by typing every line of code that pops into my head and then cutting it down to just those that work seems ridiculous. Except that’s kinda how you are supposed to code — premature etc is the root of all whatever?
Maybe I’m not broken though — I can do this, back to it. But where do you start when every thought is half-complete? TODO: Finish this and this and this. Argh. When is it appropriate to expand the notes into thoughts!!1!!!!eleven PaNicK
I can only write the words “sexual dialectic” so many times before I feel the onset of a kind of terminology-based-insanity; wondering if, in fact, I’ve gone around the bend and am just scrolling around my sixteen pages, randomly inserting gibberish.
Episodes held together with the corridor sequence — progressing towards the light — just as QVM is episodic, and held together with a birth-death symbolic structure of sexual dialectic
Argh.
Web Developer Sentenced to Death
I’ve had this tab open for a couple of days and just read it. A Canadian-resident Iranian has been sentenced to death by the Revolutionary Guard in Tehran for developing a piece of software which ended up being used on an adult website.
Kinect It Up!
Must buy Kinect…
Bucke’s Still LIFE
I wrote a pixel-shader-type-deal yesterday (actually, a “component”-shader-type-deal I guess — it works on pixel subunits) and used it to implement Conway’s Life on photographs given as input.
Here’s a series of 120 photos, animated in Conway steps, of the subject of Asylum:
I wrote the utility using the OS X APIs, mostly to learn them for my own creative edification (I want to automate the glitching process, and maybe some other things). I might be able to clean it up a bit, move it off the command line, and cross compile to iOS.
Right now it recompresses the JPEGs every frame, which is bad for a bunch of reasons, not least of which is that it screws up the cell-based nature of the game — it’s Life-versus-Compression at the moment.
Programmers in Love in Fiction
As a computer science undergrad, one of my (and my girlfriends’!) favourite books was Douglas Coupland’s Microserfs. The book is about a group of Microsoft programmers who leave Microsoft to found a start-up company, before the dot-com bubble. Besides the characters’ career arcs, a large part of the book is about [SPOILER!] Daniel and Karla gradually getting together. Ultimately, Microserfs is a romance set in a very realistic Silicon Valley.
Coupland effectively rewrote Microserfs as JPod, changing the setting to Electronic Arts in Vancouver. Except JPod skips over the few months where [SPOILER!] Ethan and Kaitlin start dating. In his rewrite, Coupland removed the aspect of Microserfs that I liked best: JPod is a boring piece of crap (that made for an even worse TV show).
The only two films about programming that I can recall are Hackers and Antitrust. Both films have male protagonists supported by technically-competant love interests: Hackers was Angelina Jolie’s first major role her best haircut ever and I don’t remember much about Antitrust, but Wikipedia assures me that the girls kicked ass*.
I finally got around to seeing The Social Network, which got a lot of attention when it came out for its “angry nerd misogyny”. Writer Aaron Sorkin flip-flopped on whether it was a pure Hollywood fantasy, sexed-up to sell tickets, or if he was accurately reflecting the mysogyny of the tech industry. I think The Social Network was an amazing script, making a fast-paced film out of typing and depositions, but maybe I would have liked the film more with some romance?
* Although Rachael Leigh Cook’s career-best hair was in Josie and the Pussycats.
Your Ballot Box has been 0wnd
Right now, absentee ballots in Canada are sent out by mail and then returned by mail. Getting them too and from remote locations (like Kandahar) in the time between the writ drop and the close of voting is a challenge. Elections Canada agrees that vote-by-mail should be replaced by voting online – whether vote-by-ballot should also be replaced is another issue.
The District of Columbia recently put up an online voting system for public testing. Some academics quickly found a common web app vulnerability and demonstrated a number of evil things that can be done on a compromised server. None of the things they did once they had access are notable, the issue is that an online voting server must be secure.
Part of the vulnerability comes from the government’s obsession with PDFs, because if someone gets a butterfly ballot, everyone should get a butterfly ballot (never mind the fact that blind voters have a fundamentally different presentation). But it strikes me that an insufficiently rigorous approach was used in developing this application, as this comment underscores:
My real issue with this is that they spent $300,000 of federal grant money (taxes) to deliver a web app that not only used possibly the worst method of data entry conceivable [FILE UPLOAD? PDF? SERIOUSLY?] but didn’t even make the most basic of checks against user input? It directly ran user inputed text on a command line?
Did they pay a highschool CS student $5/hour to code this while blowing the other $290,000 on cocaine and hookers? I hope so, because if they paid anyone an actual salary for this kind of shody work, they should fire the staff that hired them.
The developers used Ruby on Rails, a toolkit for rapid development or in the case of an application like this, rapid prototyping. I’d like to see the software for electronic and online voting systems be proven correct and secure. Not only because I am one of relatively few people in the world who knows how to do such a thing, but you know, for democracy.
Generating Random Sentences from a Context Free Grammar using VisualBasic for Excel
According to Google, generating random sentences from a CFG is a common computer science homework problem, which means there are no solutions online. Here is a solution in VisualBasic for Applications (VBA):
Function GenerateSentence(productor As String) As String
Dim rule As Range
' Get list of rules for productor:
Dim rules As Collection
Set rules = New Collection
With Sheet1.Range("A1:A99")
Set rule = .Find(productor, LookAt:=xlWhole) ' Match whole cell
Do
rules.Add (rule.Address)
Set rule = .FindNext(rule)
Loop While rule.Address <> rules(1) ' Until FindNext loops around
End With
' Choose a random item from rules (VBA must do by reference):
Set rule = Sheet1.Range(CStr(rules.Item(Int(rules.Count * Rnd() + 1))))
' Evaluate right-hand side of rule:
Dim production As String
Dim i As Integer ' i = 0
Do
i = i + 1
production = rule.Offset(0, i).Value
If left(production, 1) = Chr(34) Then ' Chr(34) = Double quote
' Evaluate terminal by stripping quotes:
GenerateSentence = GenerateSentence & Mid(production, 2, Len(production) - 2)
ElseIf Len(production) <> 0 Then
' Evaluate non-terminal recursively:
GenerateSentence = GenerateSentence & GenerateSentence(production)
End If
Loop While Len(production) > 0 ' Until empty column
End Function
Error handling is left as an exercise for the reader.
Input
Sheet1 contains one production rule per row. Column A is the left-hand side of the production rule and each cell to the right contains a terminal enclosed in double-quotes or a non-terminal that matches other cells in column A. For Example 5 in Wikipedia’s article on CFGs, Sheet1 would look like:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | S | "x" | ||
| 2 | S | "y" | ||
| 3 | S | "z" | ||
| 4 | S | S | " + " | S |
| 5 | S | S | " – " | S |
| 6 | S | S | " * " | S |
| 7 | S | S | " / " | S |
| 8 | S | "(" | S | ")" |
Environment
Create a macro that initializes the random number generator (Randomize) and then calls GenerateSentence with the start symbol as input. GenerateSentence returns a string that can be put in the Value of a cell.


