Friday, November 19, 2010

Emulate PS3 controllers

I had a play around in the past few days on how to emulate the ps3 controller from a PC with a bluetooth dongle. There are a few things one might want to emulate:

1. Six-axis
2. BD remote control
3. HID Keyboard & Mouse (for faster typing)

All the keys from the six-axis can be used from either the BD remote or the keyboard. The HID protocol doesn't seem to be able to transmit the stick movements, so it is useless for playing. There is a work around (as in, a properly reversed engineered six-axis protocol implementation) at diy-machine, which supports up to 7 controllers and it's being developed actively.

I was mainly interested to emulate the remote/keyboards in order to be able to play/pause etc a DVD from my iPod/phone through a web page. I will not post the details of the web server (yet) as it is too messy, but if google picks this up it might useful to other people to know where the resources are.

Useful python code can be found in bluemaemo (for Nokia phones) and remoko for the openmoko phone. At the heart of the implementation there is a HID server that pretends to be a HID device. There are quite a few lying around, for example hidserv.c (in bluemaemo), hidclient.c, xkbdbthid. This server opens a Bluetooth (L2CAP) socket and writes to it according to the HID protocol .

To establish a connection with Bluez4 one needs to load the SDP record of the device (specifications of the SDP protocol can be found on the Bluetooth v3 specifications (volume 3 part C)). One such service record can be found in bluemaemo (for a keyboard + mouse HID device). The record will contain the HID descriptor (according to the HID specifications, on the USB website).

The HID descriptor for the PS3 BD remote can be found here and here. On these websites there is also a SDP service record of the remote, that can easily be converted to xml.

That's all for now, I might post the code at some point if it turns out to be readable.

Tuesday, October 26, 2010

Clipping and tweeters

A fairly definitive article from Rane on what blows tweeters (read: volume) and what doesn't (read: clipping).

Wednesday, October 20, 2010

From father to son

Young Italians often complain that one of the reasons why graduate jobs are hard to come by is that hiring is often based on family relationships rather than merit. It's like an unwritten precedence rule. I was taken by surprise by the fact the rule actually is written.

In its negotiations with the trade unions Unicredit (one of largest European banks) agreed on Monday to hire first the sons of the employees that take voluntary redundancies. I could not believe it. This article on Il Mattino suggests that the practice is widespread in industrial agreements in the italian financial services, citing also Intesa San Paolo and BCC di Roma.

These other articles from major Italian newspapers report on the same news. But it seems so unreal that I wanted to find the primary source for the agreement. The news broke at 8:05 on 18/10/2010, but there is no mention of the father-son agreement. It is also not mentioned in the Fisac/CGIL (Union) statements, they only say "fostering youth employment" or something like that.

With a bit of Googling I found a scan of the original union agreement, the declaration is on page 28. The Italian wording is:
Su espressa richiesta delle OO.SS., Unicredit (...), ferma restando l'ineludibile esigenza di pieno rispetto delle caratteristiche meritocratiche che stanno alla base delle politiche di recruiting del Gruppo, conferma che non sara' posta in essere alcuna limitazione connessa al vincolo parentale nei confronti dei figli di dipendenti cessati per pensionamento volontario in possesso dei requisiti richiesti per la selezione (laurea triennale e conoscenza delle lingua inglese), determinando, a parita' di valutazione in sede di selezione, una priorita' nell'assunzione.

This is a single long sentence of the finest Italian legal prose meaning:
On request of the Unions, Unicredit, while following its overarching aim of meritocracy in hiring decisions, will favour the sons of employees who have taken voluntary redundancy over other candidates with the same qualifications, as long as they have a degree and can speak English

It is normal practice to encourage employees to put forward people they think valuable (sometimes offering money on top as a reward). There is nothing wrong in using staff as head hunters, but it is not quite the same thing as trading voluntary redundancies of senior employees in exchange of hiring their family.

I expect the next step is to rank second cousins just below sons in law but above nephews, with grandsons somewhere between third cousins and godchildren.

Sunday, October 10, 2010

256 colours in screen

Sometimes screen does not inherit the right terminfo from the terminal. This fixes the 256 colour problem:
terminfo rxvt* 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'

Saturday, October 09, 2010

Current Cost CC128, part 2

The CC128 rj45 pinout is like this, i.e.
1 = +v Unregulated (Same as the PSU input)
2 = PIC chip pin 52 (PGC)
3 = +V Regulated
4 = GND
5 = PIC chip pin 47 (PGD)
6 = PIC chip pin 9 (Program Voltage (nMCLR))
7 = Unit RX
8 = Unit TX

The stock RJ45-USB cable uses pins 1,4,7,8. I suspect you don't need 7 to just read the output of the meter, but you definitely need both 1 and 4.

Note to self: current setup

1 = 1 CC128
2 = 4 CC128
3 = n/a
4 = Phone
5 = Phone
6 = n/a
7 = 7 CC128
8 = 8 CC128

Friday, October 08, 2010

Orange database

After nearly two years of being with O2 I still get texts from Orange every month or so, informing me that my point balance is 0.

Monday, October 04, 2010

LS9 tips: recall safe

I've decided to share a few tips about not so obvious things on the Yamaha LS9, with the hope that they will be useful.

Recall safe is probably the only good thing about the scene recall on the LS9, because otherwise recalling a scene would recall the whole desk, which you very rarely want (I can think of only one occasion: the beginning of a show to reset the desk).

However there are a few things that cannot be "recall safed", and they will bite you. The only way to find out what is actually safe or not is to look at page 256 of the manual, "Mixing parameters operation applicability". You will discover that:

1. Pan cannot be safed unless ALL is selected.
2. To Stereo, To Mono, to MIX pre-post, and many other things such as Mute Assign also cannot be safed unless ALL is selected.
3. You cannot safe Mix to stereo for a MIX unless ALL is selected.

This means that if half way through plotting you decide to send a channel (that you wish to recall) to the mono channel you will have to turn it on for each scene you have already plotted.

Most importantly, and really not obviously:

1. You cannot safe channel link
2. You cannot safe MIX/MATRIX bus settings in the System Setup screen

These two are the most annoying things. It means that you cannot simply create an extra stereo bus on the second night of the show to record, because that setting "stereo bus" will have to be saved in every single scene.

I guess the conclusion is that it is wise to the plotting as late as possible and be careful when designing the signal path to allow for modification that do not require you to replot the whole show.

Friday, October 01, 2010

Current Cost CC128

Also known as Envi, given out for free by E.ON (got it for £12 on ebay, as I'm not on E.ON). The device transmits every 6 seconds a neat xml file with the power usage (and temperature) through a serial interface (an Rj45 socket so it can be run through cat5 quite easily), it comes with a serial-rj45 to USB converter.

Useful websites:
Perl script to submit data to Google Power Meter
Perl script to read serial port (and submit data to Google Power Meter, but the code above is easier to adapt)
Ruby app by IBM
Access the UART

Wednesday, September 29, 2010

CDDA, pre-gap, post-gap

Notes on CD mastering to avoid tracks cutting off last few seconds.

This is how a CD is made:

Digital Audio, or CD-DA, was the initial compact disc format. The Red Book standard of 1980 was followed in 1987 by IEC 908. Sound is recorded in frames, each containing 24 bytes of digitized audio. A continuous, spiral track consists of lead-in followed by pre-gap, then a single physical track of audio frames, then post-gap, and finally lead-out. Multiple songs are accessed by dividing the physical track into as many as 99 logical tracks, and by subdividing logical tracks using indexing. All compact disc drives must be capable of playing this CD-DA format. [*]

The specifications are contained in the Red Book (costs $100 and you have to sign a NDA), but there are alternative specifications (close enough) free from ECMA.

The interesting fact is that by default the post-gap on each track is 2 seconds. The non-so-obvious fact is that this post-gap is not an additional 2 seconds, but is the last 2 seconds of the track. The gap is simply an index to the last two second, that a player playing in gapless mode will automatically skip (sometimes switching the display to a countdown).

Friday, September 24, 2010

Batch normalization

Make all the tracks in one folder the same volume (peak -3dB)
for i in *.wav; do sox "$i" "norm/$i" norm -3; done

Friday, August 06, 2010

LS9 firmware 1.17

Fixed a problem in which the LS9 would occasionally function excessively slowly or freeze when the Ethernet connection was unexpectedly disconnected due to the application crashing or font changes made in Windows Vista when the LS9 Editor was online.

(emphasis mine)

Wednesday, June 30, 2010

Thursday, June 17, 2010

Weird Cases 4

Nice case on product liability and the effect of the Consumer Protection Act 1987. Richardson v Lrc Products Ltd [2000] P.I.Q.R. P164.
The claimant claimed damages for personal injuries which she suffered when, on May 20, 1995, a condom manufactured by the defendant being used by the claimant's husband failed as he was having sexual intercourse with the claimant. The claimant became pregnant as a result.
In his judgement Justice Kennedy sets out the facts:
The relevant act of sexual intercourse took place on a Saturday afternoon. Mr Richardson opened the foil and put on the condom. Mrs Richardson watched him. The act of sexual intercourse was unremarkable to her. It lasted, she thought, perhaps about four minutes but nobody attaches too much importance to that estimate.
They kept the broken condom (except for some bits that were "never found")
the claimant says that he put it on a piece of kitchen paper and then into a painted wooden cupboard in their bathroom. [...] The condom remained there for about two days until Mr Richardson wrote his letter of complaint which is dated May 23. At about that time the claimant put it in a brown glass screw-top jar. There it remained until it was about to go to the solicitors when she went out and purchased a more appropriate container.
After that they went to court, and after hearing a lot of expert evidence about the fragility of rubber and ozone damage they decided that there was no breach from the defendants. This is because there is enough scientific evidence that condoms "did burst on occasion for no readily discernible reason" that consumers are not entitled to have an "actual expectation" of safety against unwanted pregnancies.

Well, it came in handy in today's exam.

Welcome to the eighties

Tort exam announcement: please turn off your mobile phones, PDAs, and pagers. Pagers? I should remember to put away my filofax as well...

Monday, June 14, 2010

announcement overflow

For (unsigned int i=0; i < -1; i++) { play(announcement[i],"loud"); }

This is what happened on the london Overground the other day, according to the going undeground blog.

Video follows:

Friday, May 28, 2010

Weird cases 3

Taken from this blog, a rather funny SEC complaint filing about to wannabes Disney inside traders:

The defendants are Hoxie, an administrative assistant to a high-level executive at The Walt Disney Company (“Disney”), and her boyfriend, Sebbag. Beginning in March 2010, the defendants sent numerous hedge funds anonymous letters offering to provide the funds with inside information about Disney’s quarterly earnings in exchange for a fee.

At least twenty hedge funds received these letters:
Hi, I have access to Disney’s (DIS) quarterly earnings report before its release on 05/03/10 [sic]. I am willing to share this information for a fee that we can determine later. I am sorry but I can’t disclose my identity for confidentiality reasons but we can correspond by email if you would like to discuss it. My email is I count on your discretion as you can count on mine. Thank you and I look forward to talking to you.

These are some of the emails the girl or her boyfriend sent to an undercover FBI agent
First of all, i am not a fed, I have no way to prove it at this point but i am not asking you to disclose your identity not i will disclose mine. It is up to you to determine if this is worth the risk as i did. I work for Disney, that is all i can tell you.

I can deliver 3 to 4 days before release. I will email you the report as soon as i have it and you will wire transfer the money to my account after you get ahold of it. I am asking you to make me an offer based on the capital gains from the trade and the risk i am taking delivering this information to you? Also, i am looking to build a strong business relationship with you for future quarters and information.

And a very smart one:
I dont think we will get caught if we stay discret and careful. You can count on my discretion as i am counting on yours...They wanted 15k/20k or "how about doing a 50-50 profit sharing from your trades? Does that sound fair to you?"

The best bit is when they start stressing out on the day beacause Hoxie cannot get her hands on the report
Hoxie e-mailed Sebbag: “I told you that you were going to be waiting...” Sebbag responded “Just hurry up,” to which Hoxie replied “I have no control over this. Patience is a virtue.” Still waiting for the information later that day, Sebbag urged Hoxie to “Get things moving with all the powers you have.” Hoxie replied “3 hours have come and gone what is another hour at this point. Chill.”

“What would you suggest I do. If I could wave my magic wand and give you what you want – I would. However, since that is not going to happen I suggest you call on you inner Buddhist – and CHILL the f’ out.”

But why did they want to do this in the first place? Well, a handbag.
Hoxie stated “here is the bag that you are going to get for me – thank [sic],” and attached a link to a picture of an expensive Stella McCartney designer handbag available for $700 at Neiman Marcus [...] Sebbag stated “I may be able to [buy] u 2 of them, lol.” Hoxie responded via email, “In that case, i also love love these shoes” and attached a link to a picture of expensive Stella McCartney shoes also sold at Neiman Marcus.

They then met the undercover FBI agents and asked how they could go about opening an offshore account to transfer the money. Oh dear.

Thursday, May 27, 2010

The end of an era

Dear Colleague,

According to our records we believe that as of 26/06/2010 you will no longer be a member of Imperial College and therefore your Imperial College account and mailbox will therefore expire on 26/06/2010 at 00.01 am

(the email is still redirected and working though, no worries!)

Google birthday calendar

Just found out that there is a Public Google Calendar for creating a calendar of the birthdays of gmail contacts. Nice.

Thursday, May 13, 2010

Rebuilding rebuilding rebuilding

I hear a lot of politicians say they want to "rebuild society", "rebuild Britain", "rebuild politics", rebuild this, rebuild that. David Cameron the other day was going on about rebuilding family, rebuilding community, above all rebuilding responsibility.

I am not sure all this "rebuilding" is necessary, or desirable. Although these are certainly challenging times, it's not like everything is broken beyond repair. All right, we shouldn't take it literally. But with so many good things around, the rhetoric could be a bit more inspiring.

Wednesday, May 12, 2010

On proportional representation

There is a good video of John Cleese explaining PR, more actual than ever now.

Is it really just as simple and fair? I think not.

Wednesday, April 28, 2010

#Bigotgate, funniest tweets

ethernat Say what you like about Nick Griffin, but he would never have called her bigotted #bigotgate

sjrw @AIannucci He's burying her in the back yard as we speak!

simonwbaker Gillian Duffy: "all these eastern Europeans coming in, where are they flocking from?" - I think the answer is in your question. #bigotgate

nhudgell RT @jamesgraham: Has Duffy not left the house yet? Did Gordo do her in? #bigotgate

richrandall Stupid "-gate" suffix. If Watergate scandal had happened today, we'd have to call it Watergate-gate. #bigotgate

sciggles I'm sure labour people are trying to think up a way to make all of #bigotgate out to be #nickcleggsfault you know

canvasGB RT @PaulWaugh In attacking Gillian Duffy, Brown has insulted his entire core vote. Has he ruined Labour's election? #BigotGate #ge2010

richcowley Someone's getting their head kicked in tonight by GB. My money is on Sue. #bigotgate

bigotedwoman Cheeky bastard's having a shit in my toilet now. #ge2010 #election2010 #bigotedwoman #bigotgate

jimbotfu I would've liked to have seen him emerge from her house still clutching her broken and bloodied dentures screaming "WHO'S NEXT?" #bigotgate

markstallard Could be worse! could have called her "an opinionated cunt sponge & and there's some voters we don't need" rather than a bigot. #bigotgate

Farkough "Gordon Brown called me a bigot, and all I got was this lousy apology"#bigotgate

BTW, Spain has been downgraded, maybe that's kind of important...

Thursday, April 08, 2010

Lighting advice (from a sound guy)

I would advise against backlighting people with white hair in purple

(it was even more evident on TV but I didn't want to photoshop it!)

Wednesday, March 31, 2010

BA humour

After arriving slightly late to the airport, I was greeted at the gate by a BA stewart with these words:

You can't be late to your own funeral

Thursday, March 25, 2010

Two systems

It's funny that when John Lewis doesn't have something in store they kindly offer to order it in from another shop (takes about 5 days they say). However if you go online you can have next day in store delivery of pretty much anything.

Monday, March 01, 2010

Weird Cases 2

The (not-so-)old-retired-barrister-professor looked at the watch. He figured with 15 minutes left he could raise the spirits of the class by reading some case law. He opened the dusty law reports from 1972 and flicked to R v Collins [1972] EWCA Crim 1, from the Court of Appeal. This is such a landmark case it has its own wikipedia page. Everyone gets told to read the case, few actually do. The professor started reading the judgement of Lord Justice Davies:

This is about as extraordinary a case as my brethren and I have ever heard either on the Bench or while at the Bar. Stephen William George Collins was convicted of burglary with intent to commit rape [...] he was sentenced to twenty one months' imprisonment. He is a 19-year old youth, and [...] the learned Judge was clearly troubled about the case and the conviction.

Let me relate the facts. Were they put into a novel or portrayed on the stage, they would be regarded as being so improbable as to be unworthy of serious consideration and verging at times on farce. At about 2 o'clock in the early morning of Saturday 24th July of last year, a young lady of 18 went to bed at her mother's home in Colchester. She had spent the evening with her boyfriend. She had taken a certain amount of drink, and it may be that this fact affords some explanation of her inability to answer satisfactorily certain crucial questions put to her. [The professor here noted that she would be 56 by now, and that he hoped she wasn't anyone's mum.]

She has the habit of sleeping without wearing night apparel in a bed which is very near the lattice-type window of her room. At one stage on her evidence she seemed to be saying that the bed was close up against the window which, in accordance with her practice, was wide open. [...]

At about 3.30 or 4 o'clock she awoke and she then saw in the moonlight a vague form crouched in the open window. [...]

The young lady then realised several things: first of all that the form in the window was that of a male; secondly that he was a naked male; and thirdly that he was a naked male with an erect penis. She also saw in the moonlight that his hair was blond. She thereupon leapt to the conclusion that her boyfriend with whom for some time she had been on terms of regular and frequent sexual intimacy, was paying her an ardent nocturnal visit. She promptly sat up in bed, and the man descended from the sill and joined her in bed and they had full sexual intercourse. But there was something about him which made her think that things were not as they usually were between her and her boyfriend. The length of his hair, his voice as they had exchanged what was described as 'love talk', and other features led her to the conclusion that somehow there was something different. So she turned on the bed-side light, saw that her companion was not her boyfriend. So she slapped the face of the intruder, who was none other than the Appellant. He said to her, "Give me a good time tonight", and got hold of her arm, but she bit him and told him to go. She then went into the bathroom and he promptly vanished.

The [girl] said that she would not have agreed to intercourse if she had known that the person entering her room was not her boyfriend. But there was no suggestion of any force having been used upon her, and the intercourse which took place was undoubtedly effected with no resistance on her part.

Collins was seen by the police at about 10.30 later that same morning. According to the police, the conversation which took place then elicited these points: He was very lustful the previous night. He had taken a lot of drink, and we may here note that drink (which to him is a very real problem) had brought this young man into trouble several times before, but never for an offence of this kind. He went on to say that he knew the complainant because he had worked around the house. On this occasion, desiring sexual intercourse - and according to the police evidence he had added that he was determined to have a girl, by force if necessary, although that part of the police evidence he challenged - he went on to say that he walked around the house, saw a light in an upstairs bedroom, and he knew that this was the girl's bedroom. He found a step ladder, leaned it against the wall and climbed up and looked into the bedroom.

What he could see inside through the wide open window was a girl who was naked and asleep. So he descended the ladder and stripped off all his clothes, with the exception of his socks, because apparently he took the view if the girl's mother entered the bedroom it would be easier to effect a rapid escape if he had his socks on than if he was in his bare feet. That is a matter about which we are not called upon to express any view, and would in any event find ourselves unable to express one.

At this point there was so much debate on the effectiveness of socks in descending a ladder that the professor thought it was a good time to call it a day. I was not able to abstain from thinking this should be up on my blog.

Wednesday, February 24, 2010

Weird Cases

In 2008 in Scotland, 30 police officers raided The Arches nightclub in Glasgow. They discovered a “mass orgy”. Inside the club, all 30 of the officers stormed over to an area behind a partition where they found many men engaged as a group in gay sex. The officers attempted to make arrests but when the orgy participants saw the men in police uniforms waving truncheons and handcuffs, they assumed it was all part of the orgy and enthusiastically tried to incorporate the officers into the recreational mêlée. It took a while for the officers effectively to communicate their true purpose.

Via the Times.

Thursday, February 04, 2010

Tuesday, February 02, 2010


Reminder to self: these are the font settings.

StandardFont=Bistream Vera Sans,7,-1,5,50,0,0,0,0,0
activeFont=Bitstream Vera Sans,7,-1,5,75,0,0,0,0,0
fixed=Bitstream Vera Sans Mono,7,-1,5,50,0,0,0,0,0
font=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0
menuFont=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0
taskbarFont=Bitstream Vera Sans,7,-1,5,50,1,0,0,0,0
toolBarFont=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0

Monday, February 01, 2010

Verified by VISA

This papers explains extensively what I always thought when using the stupid extra authentication for debit cards online. I think it is ridiculous such a system was ever allowed to be put in place.