13 July 2012

MacBook Pro "Retina" Quick Review - Or How I'm Learning To Stop Worrying And Love The Mac

Today I finally picked up my new MacBook Pro "Retina" (2.6Ghz/16GB/512GB). I have to say that it's the first Mac I've ever truly wanted; I've used others in the past (the original "60s-tv" iMac, the white iBook, a few G5s and occasional MBP), but they were bought by other people for other people. So I'm not really a "Mac person": since 2002 I've mostly used Linux at home and Windows at work, and kinda abandoned Linux last year for Windows 7.

The first thing I noticed, and a big reason for the switch to The Land Of Steve, is how thin and light this MBP is. It's roughly half as thick as my Dell Latitude E6510 (which is powerful and packs a nice screen, but by God is it bulky), and probably about 35% lighter.

My second thought was about silence. I don't think I've ever owned a laptop this quiet, let alone one with an i7 CPU on board. You can't really appreciate it in a chaotic Apple Store, but when you're all alone at night, the lack of noise is incredibly refreshing. Note that I live in a quiet residential suburb; for any city-dweller this MBP can be considered completely silent.

Most things you've read elsewhere are also true: it boots faster than a phone, and you don't really need to actually shut it down unless forced by installs/updates; the screen is gorgeous (as long as you stick to updated apps like the Developer branch of Google Chrome, avoiding sucky ones like the official Twitter client) and it feels faster than any laptop I've ever used.

I have to say I couldn't notice any lag on my model until now, although I did feel it was a bit sluggish when I first tried one at the Store. I suspect the 2.3Ghz/8Gb configuration (which is what you get there, and what most reviewers have tried) is not enough to smoothly drive the über-screen; but I don't think I'll regret the choice not to shell out another £200 for the 2.7Ghz model, which comes with a larger cache (8Mb vs 6Mb).

And this is all that separates this particular Mac from other Macs out there. But what about differences between OSX and Windows? Obviously there are zillions of flame-threads on this subject, but these are my first thoughts as a switcher:

  • The damn keyboard layout. I must find a way to REMAP ALL THE THINGS!
  • No PgUp/PgDn/Del/PrtScrn (update: for PgUp/Dn use Fn-ArrowUp/ArrowDown). I'm wearing a black armband to mourn them right now.
  • Shortcuts are all fucked up. If you minimize a window and you want to bring it back, you have to Cmd-Tab back to the program, keep Cmd pressed, then press Alt before leaving Cmd. This is just Wrong. To maximize a window without going fullscreen, you have to invoke the "Zoom" feature, which often requires a custom shortcut. And so on and so forth. There is a steep learning curve for keyboard monkeys.
  • Trackpad gestures become necessary to survive. This might not be such a bad thing.
  • Any non-Apple peripheral will require an Internet connection to automatically download a half-decent, probably-uncustomizable driver. But, of course, why would you ever buy anything not Made By Steve?
  • Some DMG files, you launch them and they launch the app right there. Others will show a funny "drag app from this icon to that icon" screen. Others will open a window and expect you to know what to drag where. In comparison, Windows installers look admirably consistent.
  • Many developers (VmWare, Ascendo...) make you pay twice for the same product on a different platform. This is not nice. I should be able to deactivate a product on computer A and activate it on computer B with the same license. I'm still one person using one program.
  • gfxCardStatus, Little Snitch and iTerm2 are lovely. GPlus Tab and Facebook Tab suck.

More to follow in a few weeks; until Mountain Lion is officially out, I'm not going to deploy the full barrage of developer tools -- I'll probably format the disk anyway to install the new OS, so there's no point in wasting time now.

04 June 2012

Django 1.4 help file CHM version (and how to build your own)

UPDATE 2012-06-04: God save the Queen! Thanks to the long "Jubilee Holiday Weekend", I got around generating an updated version for Django 1.4. Here it is: Djangodocs 1.4 in CHM format. Enjoy!

----------

This is a funny story.

I happen to think Microsoft's proprietary CHM format is lovely. So I went looking for a CHM version of docs for Django, and google found it for me on this blog. I duly downloaded it, tried to to open it and... it wouldn't display. I could only see the TOC, but not the actual documents. I thought this might be a corrupted version, and it was for an alpha release of Django anyway, so I though I'd compile a version myself. After all, these docs are built with Sphinx, which apparently can generate all sorts of formats...

So here's the procedure to compile django's docs:

  1. download and install Sphinx.
    Easy_install Sphinx
    was all I needed. Hurrah for Python.
  2. ADDITIONAL STEP for v1.4: modify _theme\djangodocs\layout.html to remove all javascript tags, otherwise you'll get jQuery-related errors in the final output. This is a known bug.
  3. Run Sphinx to generate the initial files:
    cd Django-1.1/docs
    mkdir _build/html
    %PYTHONDIR%\scripts\sphinx-build.exe -b htmlhelp -d _build\doctrees . _build\html
    
  4. Download and install Htmlhelp.exe from the Microsoft site. This will give you the HTML Help Workshop. Note: it doesn't matter if you get a final message saying you already have a more recent version.
  5. launch the workshop, File -> Compile..., select the file Djangodoc.hhc which should now be in _build/html, and this will produce the chm.
  6. ...??? Profit!

... Then I found out the reason that downloaded CHM didn't work was a stupid patch from Microsoft. Ouch.

Anyway, if you need it, here's the file: Djangodocs 1.1 in CHM format. If it doesn't work, make sure you follow this suggested procedure, and save yourself some time...

27 March 2012

RDP Quick Screenshots, Or: How I've Learnt To Stop Worrying And Reverse The Problem

My work involves installing stuff on customers' servers, mostly running Windows. I usually have very limited access to them, often having to go through the customers' own computers, and what I can or cannot install is regulated by strict policies (which is good practice). And of course, one wants to minimize potential problems and maximize performance, so only the minimum amount of necessary applications and tools are installed. This would all be fine, if I didn't have to take lots and lots of screenshots in order to document (and prove) what I'm doing and how I'm doing it.

This is not a problem if I can work from my laptop, where I can run a powerful app like SnagIt or Camtasia, but it's a real pain if I have to use other hardware. If it's a simple environment with a handful of machines, I can make do with the default Remote Desktop client (mstsc.exe); if I'm lucky, it'll be a modern version that supports the CTRL-ALT-+ shortcut, which takes a screenshot of the active window inside the RDP session. That's not ideal: the resulting images are large BMP files, and you have to manually paste each one into a document right after taking the screenshot; it breaks your flow and there's a good chance you'll forget to paste it right away and lose the image after some careless CTRL-C... but I guess I could live with it.

Unfortunately, I mostly have to work on environments including dozens of machines, so the only practical approach is to use a RDP manager; since I cannot install any fancy app, it usually means I have to make do with the Remote Desktop Console (tsmmc.msc) or its modern equivalent Remote Desktop Manager. That means saying bye-bye to CTRL-ALT-+ and hello PrintScreen and mspaint.exe/Edit/Crop. Argh.

Today I thought I'd solve this problem once and for all. As Bruno Oliveira eloquently illustrated in his chart, automation is The Way of The Geek, and I am a goddamn geek. Embracing my Google-fu, I set off to find The One True Tool for this task.

My first stop was QuickScreenShots. It's a simple screenshotting app that doesn't require installation; just unzip it on the server and off you go. It features shortcuts to take screenshots of an active window, arbitrary region or full desktop; images can be automatically saved to a specific folder; best of all, it's written in (ta-daaa!) Python! w00t!

Unfortunately, it doesn't feature anything similar to CTRL-ALT-+. Not a problem, I thought: where there's Python, there's a way. Except that it didn't turn out to be the case here. RDP deals in graphic screens, not desktop widgets, and it has no concept of something like "the active window"; this is what Raymond Chen himself told me, and Raymond knows a thing or two about Windows (euphemism of the month). Mstsc.exe probably uses an undocumented extension (I guess through the Virtual Channel interfaces for RDP "plugins") to get the active window, and as far as I can see, it doesn't expose the feature through automation objects (although I haven't looked very hard, to be honest; at the end of the day, I figured it would probably be inaccessible when run through tsmmc.msc anyway). At one point I've even tried to hack it by using WshShell.SendKeys to fake a CTRL-ALT-+, but somehow it didn't work (I find SendKeys quite "temperamental" and very dependent on the Windows version; on one XP image, for example, the documented {PRTSC} keycode simply wouldn't work for me).

Sad and lonely, I was almost resigned to long, intimate sessions with mspaint, when I had the most classic epiphany. I realized my problem could be easily solved by reversing the approach: instead of trying to pull screenshots through the RDP client, I could run QuickScreenShots on all machines (after all, it's portable!), inside the RDP server sessions. I just need to point the "autosave folder" to a network share and lo, all my screenshots of the active window should end up there, nicely saved as PNG. It's so easy it almost hurts, considering I've wasted a couple of hours going through MSDN, but I'm happy I've found a decent solution anyway.

19 March 2012

Simple Python script to clean up HTML produced by Excel

Here's a throwaway Python script to clean up HTML produced by Microsoft Excel 2010. I leave it here just so that I can find it later, or if anybody else has the same problem -- for some reason, I couldn't google an easy solution anywhere. I'm sure this doesn't cover all the corner cases and complex layouts, but it's a starting point showing most of the techniques you'll ever need: tag stripping, attribute stripping (either en-masse or selective), and handling crappy declarations ("<!if" tags).

It's for Python 3 (although I think it'll work almost unmodified in 2.7, you'll just have to change open() calls with codecs.open()) and requires BeautifulSoup 4+, which really does all the magic. I don't know if it's the power of Py3k or BS getting better and better, but it's gone through a dozen files in a blink.

16 March 2012

Some Useful Windows 7 Utilities

I just finished one of my periodic rounds of "Windows 7 improvements", and I thought I'd share my findings.

First, Text Editor Anywhere.
If you are familiar with the classic Firefox extension "It's All Text", then you know what this is about: TEA will launch an external editor where you can edit the contents of any text area. No more losing long posts because of some random refresh! And the joy of using all the shortcuts you love in your preferred text editor. The beauty of TAE is that it works in *any* text area, regardless of it being in a browser or a program, and you can even invoke different editors.

Another incredibly useful little app is WinLaunch.
It provides a full-screen iOS-style launcher in Windows 7, which you invoke with a custom shortcut (Shift-Tab by default). It's a fantastic way to rid your desktop of all those application icons, so that your Rainmeter skin can look fabulous without sacrificing ease of access. Now, if only I could have some sort of drawer where to drop all the files I casually drop on the desktop...

Users of the Microsoft Touch Mouse will appreciate Touch Mouse Mate.
It currently adds three features to the mouse: middle-click (tapping with three fingers), tap-to-click (IMHO the mouse is a bit too sensitive for that, but at least you have the option), and a left-handed mode. The project is open source and very active, so I expect further improvements will soon follow. Personally, I'd love to be able to define custom gestures, which is the real killer feature this mouse is missing.

And that's it! Any other utility out there that I should know about? :)