Monday, November 13, 2017

A fix for Lightroom's scaling on high-density displays


I brought a Microsoft Surface Book laptop a couple months ago. I love the machine! However, the 3000x2000 display causes most apps to be really small. Way too small for me to use.

Fortunately the Display settings has an option to scale the display and I have it set to 200%. It works wonderfully - except with Lightroom. Lightroom does something crazy and scales itself to be really large. So large that some of the labels in dialogs don't render correctly.

I've spent all this time looking for a resolution and tonight I finally found it on superuser.com:

https://superuser.com/questions/904260/how-can-i-scale-adobe-software-uis-on-a-high-density-display

https://superuser.com/a/1167217/815240

On the properties of the shortcut, under the Compatibility tab, I selected Override high DPI scaling and set the Scaling performed by option to System

Fixed!

Thursday, July 23, 2015

SqlException error numbers for deadlock, connection and command timeouts

I'm posting this here so that I can find it in the future.

When accessing SQL Server via SqlClient (could be ADO.net or Entity Framework), any error is wrapped in an instance of SqlException and the Number property will be set to provide an indication of the specific error condition. In the event of a connection timeout, the Number property will be set to either 2 or 53. A command timeout will set the Number property to -2. And a deadlock will return 1205 in the Number property.

Thursday, July 16, 2015

Splitting and combining strings with TSQL

My current work includes a batch process that validates 1000's (and sometimes more) transactions against a dozen+ validation rules. Recently this process became the source of blocking issues, causing a lot of users to become very unhappy.

Previously the rules were written in a very straight-forward manner. Usually something similar to:

UPDATE transactions
SET 

reason = reason + 'A'
, status=6 -- exception
WHERE {some rule}

It's probably obvious where the blocking became a problem.

Our alternate approach was to collect the a list of invalid transactions and the rule that was violated into a table and mark all of the affected transactions with a single UPDATE.

CREATE TABLE #badRows (id BIGINT, rule char(1));

INSERT INTO #badRows (id, rule)
SELECT id, 'A'
FROM transactions
WHERE {some rule}

The next challenge was pivoting and rule-violation codes into a single string so that the reason field of the transaction could be updated, with the additional constraint that any existing rule-violation code had to be maintained. We came up with the following:

;WITH both AS (
-- combine existing violations with any new ones
SELECT t.id, t.reason 
FROM transactions t
INNER JOIN #badRows br ON br.id = t.id
UNION ALL
SELECT id, rule FROM #badRows
)
, ix AS

-- split any strings into single characters
SELECT id, SUBSTRING(reason,Number,1) AS code
FROM both  
INNER JOIN master.dbo.spt_values ON Number BETWEEN 1 AND LEN(reason) AND type='P'
)
, crushedReasonCodes AS (
-- combine multiple rows into a single string
SELECT DISTINCT id, (
SELECT DISTINCT code AS [text()]
FROM ix
WHERE ix.id = o.id
FOR XML PATH ('')) as reason
FROM ix AS o
)
UPDATE transactions
SET reason = crc.reason
, status = 6
FROM transactions t
INNER JOIN crushedReasonCodes crc ON crc.id = t.id


Friday, July 3, 2015

Installing Windows 10 Build 10162 on a Dell Venue 8 Pro

Today I decided to repave my Dell Venue 8 Pro with the latest Windows 10 Preview build (10162). I've been running Windows 10 on the device for a very long time, starting with an upgrade from Windows 8.1. Unfortunately, along the way, updates began to fail. Such is the risk of a preview OS.

The installation turned out to be pretty easy.

As most projects go, the prep is the most important step. First, make sure that the device is fully charged. I swear the thing doesn't change when it's running. Maybe it's just my device. Maybe I'm imagining it.

While the device is charging, download the 32bit version of the ISO from the Windows Insider site and burn it to a USB drive. I used isotousb. Format the USB drive for FAT32 and make sure that you click the option to create a bootable drive. Oh! Don't forget to grab the activation keys.

You're also going to need some drivers. You can get them from the Dell Venue 8 Pro Product Support page. I ended up using:

There's also an update for the touch screen (Panel Touch Firmware for Dell Venue 8 Pro 5830) but the installer notified me that the touch driver was already up to date after I had installed the Intel Atom A3000 Series Driver. YMMV.

I created a folder on the USB drive and copied all the installers to it.

Then you're going to need a USB hub.Windows 10 didn't come with a driver for the touch screen so you're going to need a mouse. The hub will allow you to have both the USB drive and mouse connected at the same time. You might also need an adapter (like this one) to connect the hub to the micro USB on the Venue 8.

With the device turned off, connect the USB hub to it. Press the Volume Down button and power on the device. It'll seem like the boot stalls until you release the Volume Down button. Then the device will boot into the BIOS setup. Navigate to the BOOT tab. You should see both the internal drive and the USB drive showing as bootable drives. Change the first boot target to the USB drive then save the changes and let the device restart. If all went well, the Windows 10 installer should start.

I chose the Custom Install option and removed all the existing partitions. 

After the installer completed, I installed the drivers in the same order that I listed them above.

One note: the only operating difference that I've noticed is that I have to hold down the power button for a couple of seconds to power on the device. Otherwise, everything else seems to be working as expected. 

Wednesday, March 4, 2015

Visual Studio 2013 APPCRASH KERNELBASE.DLL

I've spent the last two night trying to figure out why Visual Studio 2013 crashes roughly two minutes after loading. 

Faulting application name: devenv.exe, 
version: 12.0.31101.0, 
time stamp: 0x54548724
Faulting module name: KERNELBASE.dll, 
version: 6.3.9600.17415, 
time stamp: 0x54504ade
Exception code: 0xe06d7363
Fault offset: 0x00014598
Faulting process id: 0x940
Faulting application start time: 0x01d056d558e8e214
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll

It started right after I had applied a couple of Windows updates so I started trying to resolve the problem by rolling those back. No change.

I tried resetting the Visual Studio users settings. Nope.

Integrity scan of the disk. No problems found.

Turned to the Internet and found this answer in the Microsoft forums. It seems that my User Profile was corrupted. I created a new account on the machine, killed the previous one. Done.

Thursday, December 4, 2014

Reversing a file with Powershell

Today I was tracking down the source of a deadlock and needed to reverse the SQL Server log file so that it would be easier to follow the deadlock information. A quick search for reversing a text file lead to a command called Tail which must be a *unix command. I also found a couple of Powershell scripts but nothing really simple.

As it happens, get-content returns it's results as an array.
And you can reverse an array using the static Reverse() method
And you can write an array using out-file.

A quick example:
$c = (get-content deadlock.log)
[array]::Reverse($c)
$c | out-file "rev-deadlock.log"


Saturday, October 8, 2011

Metro style apps–loading an image from content

 

I’m writing a Win8 Metro style app and I wanted to expose an image from one of my view models. The image comes from a file that I have included in the project as content. After wandering through the samples, I was finally able to piece together this solution:

image

The XAML binds to the property using the Source attribute:

image

Some things to note. The image’s Build Action is set to Content and the path delimiters in the call to ResourceLoader.GetFile() use forward slashes (“/”). Using a backslash results the exception: NamedResource Not Found (HRESULT 0x80073B17).