Fix blue tint on MacBook Pro dedicated GPU

This post is primarily a reminder for myself on how to purge/reset the ColorSync user cache.

I’ve got a mid-2010 15″ MacBook Pro, which was the first having both an integrated GPU (Intel HD) and a dedicated GPU (NVidia Geforce GT 330M). It “dynamically” switches between the two on-demand, which means some applications (e.g. Adobe Photoshop, Google Chrome, Visual Studio Code) trigger the switch, probably because of some low-level GPU call that makes OS X decide the dedicated GPU must be used.

Now, since a while, when the MBP would switch from the internal GPU (iGPU) to the dedicated GPU (dGPU), the screen would change colour. It would change from its correct colour to a somewhat blue-ish tint. Very bad on the eyes, especially in the evening.

After googling around a lot, a number of posts on the Apple Discussions pages recommend gfxCardStatus, using which you can “lock” the MBP on the iGPU. I consider this a bad option (it’s not bad software by the way, I’ve used it in the past to monitor the GPU switching), since the dGPU is far more powerful than the iGPU and often you need that power (be it the dedicated memory or the computation power). And, when you attach an external screen (like I do most of the times), it doesn’t work at all.

I also found the recommendation to reset or purge the ColorSync user cache. I tried this and it immediately worked, removing the blue-ish tint from the MBP screen (well, after removing the ColorSync cache and restarting the MBP).

The easiest way to do this (in my opinion), is described by Topher Kessler on CNET.com in his post titled “How to make ColorSync profiles stick in OS X”. It took me a while to find it because the title doesn’t immediately give away the fact that it concerns the ColorSync cache.

So, long story short, execute the following in the Terminal:

sudo rm $(getconf DARWIN_USER_CACHE_DIR)com.apple.colorsync.profiles.`id -u`

…which gets rid of the existing ColorSync user cache. Restart afterwards and the screen will maintain the same colour on both the iGPU and the dGPU.

I don’t know why or how the ColorSync user cache gets corrupted, but I do know how to solve it!

DYMO Label Framework Typescript Definition

About a week ago I’ve created a Typescript definition file (.d.ts) for the DYMO Label Framework. Being the good netizen I am, I created a pull request on DefinitelyTyped (the de facto Typescript definition repository) and it was accepted! Well, the second time round it was…

So, using the amazing tsd tool (kind of like the bower for typescript definition files), you can now do…

$ tsd install dymo-label-framework

…and have the Typescript definition file automatically added to your project. This will give you Intellisense in e.g. Visual Studio Code or VS2015 and compile-time type checking during Typescript to javascript compilation.

I’ve done my best to add all documentation to the definition file, so you can enjoy proper Intellisense with full documentation during programming. Enjoy!

Assembly.Load and FileNotFoundException

I’m experimenting with AppDomains to be able to load multiple versions of the same assembly in one application. I’ll write a bigger post about my findings later, but there’s one thing I encountered very early in the experiments: using Assembly.Load on a newly created AppDomain immediately leads to a FileNotFoundException. It took me a while to figure out why that happened and I’d like to share my experience with you.
Continue reading Assembly.Load and FileNotFoundException

Verify the integrity of a flash/SD card on a Mac

Last minute camera shopping

The week before going on a holiday, I realised my old Canon Ixus 40 camera would no longer live up to my expectations. So I quickly checked dpreview.com for the latest and greatest compact camera’s and decided I wanted the Canon PowerShot SX240 HS. 15 Minutes later I found myself in the Media Markt with the camera in my hand (unfortunately only the silver colour was available, I had hoped to buy the black one).

I need a bigger memory card

I then realised that my existing 512MB and 1GB SD cards would no longer be large enough for the 12Mpixel photos of this new camera. A few meters down the corridor was a huge wall covered in memory cards. I decided to buy a Samsung 8GB SDHC card, which would be able to hold up to 1500 photos or an hour of HD video. When I returned home, I formatted the card in-camera, and played around with the photo and video functions. Three days later my holiday would start and I would have a good (enough) camera to capture some fine moments!

Corrupted photos

Fast-forward about two weeks, half-way into my holiday. I’ve happily been taking photos and videos with my new camera. While I’m reviewing the last five photos, the camera suddenly displays a “broken picture” image on the screen. I take another photo, review it and it’s immediately “broken” again. I’m approximately on two-thirds of the card’s capacity and it is corrupting my photos. I do what I’ve learned from experience with corrupt memory cards: turn off the camera immediately, remove the SD card, and to be sure, “lock” the card (making it read-only) using the physical switch on the SD card. At this point, I just hope for the best that only those last two photos were corrupted.

Back at home a week-and-a-half later, it turns out I’m extremely lucky! Indeed only those last two pictures were corrupted! Continue reading Verify the integrity of a flash/SD card on a Mac

Profiling on SQL Server Express

I’m working on a new web app using ASP.NET MVC 3 and Entity Framework 4.1. One thing lacking in EF 4.1 is the ability to monitor the actual queries sent to the SQL database, like you could do with Linq2SQL’s DataContext.Log.

The machine I’m working on has SQL Server Express. The Express version doesn’t come with the SQL Profiler. So without Profiler and without a log function on Entity Framework’s DbContext, what’s a developer to do?

Well, as it turns out, profiling is part of the SQL Server (any version, including Express), the SQL Profiler application is just one way to access the profiling functionality. Some people even argue it’s better to do the profiling on the server itself, as opposed to through SQL Profiler.

Starting the trace

How do you start? The easiest way to start is (you’re not going to like this) by using SQL Profiler. That’s what I did (on another machine). It’s explained on the website linked above, here are the steps: Continue reading Profiling on SQL Server Express

Fighting “General SQL Error” in Dynamics CRM custom workflows

Working for my client Valx, I had some serious problems in custom workflows for Microsoft Dynamics CRM 4. Every now and then, a workflow would throw a SoapException. I always put the original exception in the InvalidPluginExecutionException (second parameter “inner exception”). Now the actual exception information you want to see is in SoapException.Detail, which is an XmlNode. You won’t see that info if you just put the SoapException in the InvalidPluginExecutionException’s inner exception. Therefore, I use the following try/catch construction in each custom workflow’s Execute method to see some relevant information in the WorkflowLog view of the Dynamics CRM database.

Continue reading Fighting “General SQL Error” in Dynamics CRM custom workflows

PDF watermark/background Rendering Extension for SSRS – Part 2

Updated 2011-02-22: the underlying Stream is closed when PdfWriter.Close() is called, so the code for the PdfHandler.AddBackgroundPdf() method is updated (line 79 and further).

Well, I didn’t think this follow-up to Part 1 would come this quick, but here it is! Again I would like to emphasize that Jan Hoefnagels is the one who should take credit for this solution, but he isn’t the blog-writing type of guy. He’s not even a “Getting Things Done” guy. He’s a “Making Things Work” guy. And he’s pretty good at that.

Anyway, Part 1 showed you a general solution for an implementation of a Rendering Extension for SQL Server Reporting Services that was able to utilize the built-in (Microsoft provided) PDF Renderer, while enabling you to get the rendered PDF and do “something” with it, before sending it back to the SSRS server, which would subsequently send it to the end-user as a downloadable PDF file. That was a long sentence by English standards, but by Dutch standards, that’s kind of like a normal length. In German however, you would just be getting started. This whole article could be one sentence in German and still leave room for more.

Continue reading PDF watermark/background Rendering Extension for SSRS – Part 2

PDF watermark/background Rendering Extension for SSRS – Part 1

While working on a Dynamics CRM implementation for Valx —whose website was made by Jan, Zlatan and me with Umbraco— with my dear friend and “colleague” Jan Hoefnagels, we stumbled upon a technological hurdle.

We promised our client quotes, orders and invoices —as generated by SQL Server Reporting Services, which is neatly integrated into Dynamics CRM— with and without their own letter background, so they could use the same reports for printing on pre-printed paper (no background), as well as send the PDF through email to their clients (with background). Continue reading PDF watermark/background Rendering Extension for SSRS – Part 1