Fastest XML Editor

The really fasted XML editor I've ever used is XMLMarker which loads a 5MB file in a fraction of a second. When editing, it shows the XML simultaneously in tree, text and 'Data Grid' views which is quite impressive as are a couple of its other features:

  • You can edit data in the data view, not just in the text view
  • If you 'break' the document by editing the markup in text view, the data and tree views still work (arguably a dangerous feature: caveat user)

But I'm often doing RegEx search and replace, which XML Marker doesn't do, and often editing text as well as xml. Notepad++ is quite speedy and can do regexes, but Sublime Text 2 does regex search and replace much better: it does live highlighting of what its found as you type, so you can 'debug' your regexing on the fly.

Everyone wants xml pretty printing (well, re-indenting), which for Sublime Text 2 is done by first installing the WBond.net package manager and then installing the 'Indent XML' package. Package Management in Sublime Text is a bit command-liney, so do read Mr. Bond's instructions.

sp_WhoLock – a T-SQL stored proc combining sp_who and sp_lock to show who’s locking what and how much

Run this query, or remove the comments to actually create a stored proc.
Note that SQL pre-2008 requires a field to be commented out of the query, as noted inline.

/*
--Create Procedure WhoLock
--AS

if object_id('tempdb..#locksummary') is not null Drop table #locksummary
if object_id('tempdb..#lock') is not null Drop table #lock
create table #lock (    spid int,    dbid int,    objId int,    indId int,    Type char(4),    resource nchar(32),    Mode char(8),    status char(6))
Insert into #lock exec sp_lock
if object_id('tempdb..#who') is not null Drop table #who
create table #who (     spid int, ecid int, status char(30),
            loginame char(128), hostname char(128),
            blk char(5), dbname char(128), cmd char(16)
            --
            , request_id INT --Remove this line for SQL 2005 or earlier
            --
         )
Insert into #who exec sp_who
Print '-----------------------------------------'
Print 'Lock Summary for ' + @@servername  + ' (excluding tempdb):'
Print '-----------------------------------------' + Char(10)
Select     left(loginame, 28) as loginame, 
    left(db_name(dbid),128) as DB,
    left(object_name(objID),30) as object,
    max(mode) as [ToLevel],
    Count(*) as [How Many],
    Max(Case When mode= 'X' Then cmd Else null End) as [Xclusive lock for command],
    l.spid, hostname
into #LockSummary
from #lock l join #who w on l.spid= w.spid
where dbID != db_id('tempdb') and l.status='GRANT'
group by dbID, objID, l.spid, hostname, loginame

Select * from #LockSummary order by [ToLevel] Desc, [How Many] Desc, loginame, DB, object

Print '--------'
Print 'Who is blocking:'
Print '--------' + char(10)
SELECT p.spid
,convert(char(12), d.name) db_name
, program_name
, p.loginame
, convert(char(12), hostname) hostname
, cmd
, p.status
, p.blocked
, login_time
, last_batch
, p.spid
FROM      master..sysprocesses p
JOIN      master..sysdatabases d ON p.dbid =  d.dbid
WHERE     EXISTS (  SELECT 1
          FROM      master..sysprocesses p2
          WHERE     p2.blocked = p.spid )

Print '--------'
Print 'Details:'
Print '--------' + char(10)
Select     left(loginame, 30) as loginame,  l.spid,
    left(db_name(dbid),15) as DB,
    left(object_name(objID),40) as object,
    mode ,
    blk,
    l.status
from #lock l join #who w on l.spid= w.spid
where dbID != db_id('tempdb') and blk <>0
Order by mode desc, blk, loginame, dbID, objID, l.status

Although this is a bare metal approach to investigating sql contention, the query does show you actual login names, so it enables you to join up technical issues with affected/affecting customers.

BootCamp Download Stuck – How to Get Drivers for Macs to run Windows 7 or 8

— updated after BootCamp 5 release June 2013 —

Where can you get a direct download of Windows drivers for Macs if BootCamp is stuck, and says 'could not continue' or you have some other problem downloading the drivers?

The brute force solution: it’s a darned large download, so physically take your machine to somewhere with a very fast internet connection that can download 600MB – 1GB in a couple of minutes. There, you’re done. Especially if you have a laptop, this would be the simplest solution - even take it to an Apple Store.

For the rest of us:

  1. If not, then first find out your Mac's ModelIdentifier
    • Q: How do I find my Mac's Model Identifier?
      A: Open System Information, and look in the Hardware Overview section.
      In other words: Click Apple menu -> About this Mac -> More Info… -> System Report -> Hardware. Now, read down the list in the Hardware Overview panel, looking for Model Identifier
    • If you're stuck, see the note below.
    • Note that a ModelIdentifierHasNoSpacesInItAtAll.
  2. Second, get a download manager. You can try doing without, but the reason you're on this page is that you're having trouble getting a file to download reliably. A download manager such as iGetter or Folx solves this problem.
  3. Then, search for your ModelIdentifier in the table below. Click the link to get the download package. Be patient as they are 600MB to over 1GB. It will be much simpler if you do the download in OS X, because OS X can open the downloaded file and also open the dmg file inside it.

  4. Still in Mac OS X, once your pkg is downloaded, double click it and install to a folder on your hard drive so you know where to find it. During the Installation, click the "Change Location" option so that you can choose where it gets installed.Image of OS X Installer step where you can choose the folder to install to

  5. The folder contains a nest of folders, the last of which contains a dmg disk image file. Double click that to open. At last! Here are your Windows installer files.Install BootCampESD 4 Find and Double click the dmg fileBootCamp WindowsSupport.dmg Contents

    BootCamp WindowsSupport.dmg Contents of Drivers Folder

  6. Copy them to a usb drive, or a burnable CD. NB, it’s still 660MB or more, so it’s a full CDs worth of burning time.
  7. Done. You can now proceed with Boot Camp assistant Windows installation and boot the Mac in Windows.

If you must do the download in Windows instead OS X, it's harder. You will need the help on http://www.cafe-encounter.net/p860/opening-a-bootcamp-driver-download-on-windows-7-or-8-with-7-zip to open the pkg file and the dmg file inside it.

BootCamp Direct Download Links

Most of these driver downloads work for both Windows 7 and Windows 8. Windows 8 on 32-bit is not officially supported, but almost everything seems to works on fine on not-officially supported models: the only specific shortcoming I'm aware of is that the screen brightness buttons don't work on all models.

Model Identifier Size & driver release date Direct Download Link
Macmini6,1
Macmini6,2
MacBookPro10,2
iMac13,1
iMac13,2
438MB, 3 Dec 2012 http://swcdn.apple.com/content/downloads/54/18/041-8805/9tglhtxadqtnrro79rsdy4f0mkgu7wg6or/BootCampESD.pkg
MacBookPro9,1
MacBookPro9,2
1,058MB, 15 June 2012 http://swcdn.apple.com/content/downloads/11/05/041-0925/g27es04pw9re5ggrfp3vuf8ew6r53asfz8/BootCampESD.pkg
MacBookPro10,1
MacBookAir5,1
MacBookAir5,2
942MB, 15 June 2012 hhttp://swcdn.apple.com/content/downloads/55/51/041-3891/se4uhpqng48t842cdsosqh28lft54fmswl/BootCampESD.pkg
MacBookAir4,1
MacBookAir4,2
Macmini5,1
Macmini5,2
Macmini5,3
676MB, 23 May 2012 hhttp://swcdn.apple.com/content/downloads/32/33/041-2303/W5jKtsQhhMgMXs3TKhPDqLXrpXyY2HdXMN/BootCampESD.pkg
MacBook2,1
MacBook3,1
MacBook4,1
MacBook5,1
MacBook5,2
MacBook5,3
MacBook6,1
MacBook7,1
MacBookAir1,1
MacBookAir2,1
MacBookAir3,1
MacBookAir3,2
MacBookPro2,1
MacBookPro2,2
MacBookPro3,1
MacBookPro4,1
MacBookPro5,1
MacBookPro5,2
MacBookPro5,3
MacBookPro5,4
MacBookPro5,5
MacBookPro6,1
MacBookPro6,2
MacBookPro7,1
MacBookPro8,1
MacBookPro8,2
MacBookPro8,3
MacPro1,1
MacPro2,1
MacPro3,1
MacPro4,1
MacPro5,1
Macmini2,1
Macmini3,1
Macmini4,1
iMac5,1
iMac6,1
iMac7,1
iMac8,1
iMac9,1
iMac10,1
iMac11,1
iMac11,2
iMac11,3
iMac12,1
iMac12,2
632MB, 23 May 2012 http://swcdn.apple.com/content/downloads/33/54/041-2011/pRtCDYcWShMLxFggy3TzFzmfnnWQNFQBfJ/BootCampESD.pkg

Finding your ModelIdentifier

If you're struggling to find your ModelIdentifier then you want the brilliant page at everymac.com which can tell you what model Mac you have based on serial number. On the result page after you submit, look carefully and you'll the ModelIdentifier.

Still stuck?

If you're still stuck, then:

  1. Look through the comments for people with similar problems -- there have been a couple of hundred so they cover pretty much everything I can suggest.
  2. Try my summary of problems/solutions for direct download of bootcamp drivers

References

See BootCampESD.pkg download instructions for references and for the DIY instructions to work out these links yourself.

Using a Windows Keyboard with Mac OS X

If you've got OS X 10.7 this should be easy:

  1. Plug the keyboard in
  2. Open System Preferences – Language and Text – Input Sources
  3. Behold, in the list of input sources, alpabetically below British, one called "British - PC"
  4. Choose it.

Done. What could be easier? If you keep the ordinary British one ticked as well (e.g. you have a laptop and second keyboard) then you'll want to tick the 'Show input menu in menu bar' option so you can easily switch between them. I like have keyboard viewer in the input list too, so I can see what layout the computer thinks I've got.

If you're on an older OS X and don't have British PC layout in your list, this post includes a link to download a British Windows Keyboard Layout for Mac.

The windows key should work as your command key, and control and alt should work as expected. If, in addition, you go to System Preferences - Keyboard - Keyboard, you should also see a button called Modifier Keys, which allows you to swap around the ctrl/command/alt keys.
I do wish Apple would make up their mind about calling the alt key 'option'. On my MacBook, the key is labelled 'alt' but in the Modifer Keys dialog box it's called 'option'