Archive for the ‘Tech’ Category

Mac display glitch in bright-white areas: color profile workaround

Monday, April 23rd, 2012

My MacBook Pro display started malfunctioning yesterday, exhibiting flickering vertical cyan stripes in all bright-white areas, and flickering red in pitch-black areas. This doesn’t go away on reboot, and happens on the laptop screen itself and not on external monitors. So probably a hardware failure.

I’ll get it repaired, of course, but in the meantime I have a workaround: I tweaked the color profile so that the brightest RGB values map to only 96.5% of the display’s full physical brightness, and the darkest to 3% instead of 0%. Works like a charm for me. If your machine is out of warranty, you might prefer this to an expensive repair job (assuming your display problem also affects only brightest-white and darkest-black areas).

Cons: this makes the display a little bit less bright and contrasty, and might cause color hue shifts perceptible to someone more chromatically delicate than me.

Here’s the tweaked color profile (no warranty implied, may eat your computer alive, I am not liable, etc.). To try it out:

  1. download this file and put it in /Library/ColorSync/Profiles/Displays
  2. open System Preferences → Displays → Color
  3. select the “GulliHack” display profile

If the above steps do not seem easy to you, get someone technically minded to help.

How I made this (for the technically minded):

  1. Download remapcolorprofile.py. This reads a hex dump of a brightness curve as expressed in ICC files, snips off the top end of the curve, and linearly interpolates the remainder to the original number of values, maintaining its overall shape.
  2. In /Library/ColorSync/Profiles/Displays, find the default color profile for your laptop screen (on my machine the filename is Color LCD-00000610-0000-A005-0000-000004280140.icc on my machine) and copy it to another file.
  3. Open that file in a hex editor, such as 0xED.
  4. Find the token vcgt (0x76636774) in this file. It appears in two places; go to the second (for me it was at offset 0x0A88).
  5. 18 bytes on from that, find a 512-byte long sequence of two-byte words, starting with 0x0000 and ending with 0xFFFF. Select that (make sure you got exactly 512 bytes; bottom right of the window should show “Selection: 200”) and copy.
  6. Run this in a terminal: pbpaste | python remapcolorprofile.py 0.03 0.965 | pbcopy (your particular problem may call for a different proportion; I tried a few and 3% and 96.5% were just right for my problem).
  7. Go back to your hex editor and paste (making sure the “Write Mode” is “Overwrite”, not “Insert”). Make sure the length didn’t change.
  8. Do the same for the next two 512-byte sequences (there’s one sequence for each primary color).
  9. Save, and try out the color profile.

When in ROM …

Monday, September 10th, 2007

Sales blurb for the HTC P3600 mobile phone:

„Process applications faster and store more data with 256MB internal ROM …“

project.ioni.st playli.st

Monday, May 28th, 2007

Consolidated supply of music picked by project.ioni.st, that discriminating bastion of good taste:

project.ioni.st.m3u

(Yes, this will stay up-to-date.)

Diffing at 37,000 feet

Wednesday, April 18th, 2007

A brief feature comparison: in mid-flight I am impertinent enough to want to diff my checked-out code to see the changes I have made.

Under (the free-of-charge and open-source) Subversion, that would have been “Sure, here you go.”

Under (the $3,000 proprietary) Team Foundation Server, it is “be thankful I’m letting you work at all. And when you get online, go download a separate utility and ask it politely to sort out which files you have changed.”

And here I was trying to break the rant habit. Dagnabbit!

Reinventing The Wheel

Tuesday, April 10th, 2007

There are two rules of paramount importance in engineering innovation.

  1. never reinvent the wheel.
  2. always break the rules.

So I guess this was only a matter of time. Presenting: TheWheel™.

The Ayende retort

Friday, March 30th, 2007

When you hear from software people (e.g. from yourself) things like “I don’t have time” or “it’s too much work”, there is a single-word slapdown response.

Ayende.

2.07 posts a day on average over the last three years, mostly high-value software stuff. At the same time, he spews out useful, robust software. That’s all on top of his day job. And apparently he reads a lot.

Personally I suspect Ayende is a five-person software company masquerading as a single person. Even then he is not doing too badly.

The obvious question: how does he do this?

The useful question: why aren’t you doing it?

(Ouch.)

In·sha’·Allah·tion

Monday, March 19th, 2007
The Everlasting Miracle
In·shaʾ·Allah·tion (ĭn’shä-lä’shən)

n.

A software installation/upgrade performed as a leap of faith in the irrational hope that it might make things less terrible.

[From Arabic in šaʾ Allāh (إن شاء الله), “God willing”]

TeamCity: sgen.exe exited with code 1 because of C++ DLL

Monday, February 26th, 2007

On our experimental TeamCity build machine, a build was failing in Release configuration (but not in Debug configuration) with the message:

"sgen.exe" exited with code 1.

The same project was building just fine on developer machines.

Googling the failure message turned up some pages suggesting a sledgehammer fix: disable “Generate Serialization Assembly” in the project file. But disabling something that may be valuable seems a little drastic just to appease a finicky build machine.

A better approach starts (as it always does) with getting more information about the failure. In TeamCity’s “All messages” view:

- This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

If you would like more help, please type "sgen /?".
"sgen.exe" exited with code 1.

This yields the eminently googleable HRESULT 0x800736B1, which led to a couple of pages pinpointing the problem:

  • the project references a DLL that depends on the C++ runtime library
  • sgen.exe needs to load referenced DLLs
  • loading a C++ DLL causes it to load the C++ runtime
  • The C++ runtime exists on my machine because it has Visual Studio installed; the build machine doesn’t.

Solution: install vcredist_x86. The build is now fine.

I’m quite excited about TeamCity; go check out their early access program!

The incomprehensible failure of disco

Thursday, February 22nd, 2007

Disco failed

Suddenly my MSBuild fails because somebody deleted Reference.cs and there’s only a Reference.map in the Web References\LT folder.

So I try changing the reference’s URL Behavior from Dynamic to Static (just to make any change, to see if Visual Studio regenerates Reference.cs). That yields the error dialog pictured here.

Pop quiz, hotshot: what is the difference between OK and Cancel in this dialog?

None, apparently. I click OK and the property does change to Static. When I repeat the experiment, this time clicking Cancel, the property also changes to Static. Don’t know what else might be happening behind this error dialog …

… and that’s exactly the point. Where, pray tell, should I go to troubleshoot this error?

Well, silly, I’m a tech guy. I should figure it out for myself, rather than expect my tools to make it easy to find. Which brings me to my next question …

… how much did we pay for this IDE again?

Null coalescing and value type boxing

Wednesday, February 14th, 2007

Try calling this with a null argument.

public double AndCastYeHimIntoAnInt(object o)
{
    return (int) (o ?? 0);
}

It works as you would expect; returns 0.0 (implicitly cast from the integer 0).

But we like our casts explicit, so now try this:

public double AndCastYeHimIntoADouble(object o)
{
    return (double) (o ?? 0);
}

Woe is me; this fails with an InvalidCastException saying “Specified cast is not valid.”

But heavens, surely the integer zero can be cast to a double? For verily, (double)0 works just fine, and a debugger verifies that that (o ?? 0) indeed evaluates to the integer 0.

But put a watch on (double) (o ?? 0) and quoth the debugger: “Cannot unbox 'o ?? 0' as a 'double'”.

And lo, lift up now thine eyes and place a watch on (o ?? 0).GetType() and it shall prove to be the struct type System.Int32, a boxed integer, and that cannot be cast to a double.

It is a boxed integer unto the LORD, because the compile-time type of the expression must be object, the only type to which both object and int have an implicit conversion.

But why does a boxed integer not convert to Judaism double in the obvious way, by unboxing to int and then implicitly converting to double? Probably because supporting that would require extra work at runtime for every unboxing conversion.

With few exceptions, value-type boxing can be ignored. This is one of those exceptions.