Sunday, October 21, 2012

The Future of Digital Cameras

In the past couple of years, heralded by the iPhone 4, cameras in smart phones have begun producing images that are “good enough.” An old photographer adage says that “the best camera is the one you have with you,” and our mobile phones now produce photos that are as good as entry-level point-and-shoot cameras.

Thus smartphones are eroding the point-and-shoot camera market.

This is a good thing: it’s forcing camera manufacturers to step up to compete. If a consumer is going to buy a camera, it needs to produce a considerably better image than the camera they already have in their pocket on their phone. Many people choose DSLRs for their “real” camera, and just use their mobile phone for their “everyday” camera.

A new race is underway: bigger sensors and better optics in smaller packages. Sony is leading the way with their niche $2800 Sony RX1 camera, a 35mm fixed camera with a full-frame sensor.

Recently I picked up their more palatable $600 Sony RX100, a pocket-sized point and shoot with a sensor considerably larger than any other similarly-sized camera on the market. Along with full manual controls, it’s capable of producing images that are best in class. Two images from the RX100 are below, the second being a 100% crop.

This trend is sure to continue. Bigger sensors and better optics in smaller packages. Leave the bulk of a DSLR behind and embrace the future.

image

image

Monday, July 30, 2012

Premature Optimisation

For over a year in 2008 through 2010, I led a performance optimisation effort of a small team at a very large client on a shockingly complex e-commerce solution. We profiled the codebase, optimised the environment, implemented code optimisations, and worked to get them in our test environments.

One lesson that stands out from that is that you should never optimise code without evidence that it is a bottleneck. Run a profile, analyse the hot-path, and then (most likely) cache the result of the operation or find a smarter algorithm to accomplish the same task.

I had a colleague on my current project raise a concern about the performance of UTC to Local time conversion. I dismissed it as arithmetic, but he persisted. So we tested it and measured it at our volume as taking 34 milliseconds. For some applications that might be a concern, but not for ours.

Bottlenecks usually involve moving data over a network, or naïve algorithms that are O(c^n) or O(n!) on moderate to large datasets. (Remember that in-memory Linq statements are really just expressive foreach loops, I’ve been burned by that before.)

In general, however, it’s best to write readable and maintainable code. Hacking an algorithm because you think it might be slow (like worrying about time zone conversion) is a poor reason to make a decision on how to design your solution. Gather some evidence. Premature optimisation is the root of all evil.

Wednesday, July 18, 2012

Self-Driving Cars, Taxis, and Rentals

A prediction about the future, 2017 or 2020 or so:

I'll be able to pull out my smartphone and order a self-driving car. It will come to my GPS location and pick me up. In the event that it's a busy street and the car is non-obvious, my phone will alert me that the car has arrived. This is much like ordering a taxi today by phone, with the added advantage that no one can steal it en route. I'll tap my phone on the door to unlock it with NFC. After I ordered it with my smartphone and was waiting for the few minutes for it to come and get me, I entered my destination into the same smartphone app. The car takes off immediately. When I'm done, I tap out with NFC again, and that's it. My account is charged for the trip. It will probably work like most toll and transit passes where they deduct from a small pre-paid balance and it auto-recharges.

In this world, easily-ordered self-driving cars will replace taxis, shared car services and rental car companies. Why go through the hassle of booking a time slot in the shared car and worry about getting it back on time when it's just as cheap to order a self-driving car? Not to mention driving! Driving is so...pedestrian...so 2012.

Self-driving taxi/shared cars like this will finally be the killer app for full electric cars. These self-aware cars will drive themselves home when the battery is low.

They'll also be a death blow to something like 80% of car ownership. It will be pointless for people in big cities to own cars since borrowing one will be effortless and much more economic and efficient. These same fleet companies will offer discount long-term rates for road trips and holidays.

At first a few players will compete with proprietary systems. Some five years after, the marketplace will standardise, and these cars will become an interchangeable commodity. Governments will step in and run them as "public transit." Luxury brands will come in so that elitists don't have to share cars with the rest of us.

Or so I hope. This on the news that California has recently legalised self-driving cars.

Tuesday, July 17, 2012

Managing Powershell Profile.ps1 with SkyDrive

I use SkyDrive to sync pretty much all of my data (I was an early adopter and so they gave me 25GB free). SkyDrive lives at $home\SkyDrive, and my Powershell Profile.ps1 lives at $home\Documents\WindowsPowerShell\Profile.ps1.

To manage it, I created a folder named $home\SkyDrive\Documents\WindowsPowerShell and used mklink to create a symbolic link (yes, NTFS supports symlinks). Start cmd.exe as an Administrator:

cd \users\username\Documents
mklink /D "WindowsPowerShell" "..\SkyDrive\Documents\WindowsPowerShell"


Now I can keep my profile and various modules & utilities (notably PSCX and git-tfs) in my Powershell folder and roam from machine to machine. Bliss!

Friday, June 08, 2012

Windows 8 Hardware

Last week at Computex, we saw a number of new hardware devices taking advantage of the new touch capabilities in Windows 8. From touchscreen ultrabooks to transformers to sliders to the craziest PC I’ve ever seen, the Taichi, which has two full HD screens, one on either side of its lid. All this choice begs the question: what use cases do I hope to achieve with this hybrid desktop/touch OS/hardware future?

  • Software development, my livelihood. I typically have 30+ windows open at once, heavy multitasking, highly keyboard driven.
  • Heavy email & presentations. Again, tied to my livelihood. A physical keyboard is desirable.
  • Note taking. I use paper notebooks (my favourite is a Moleskine Cahier, Large Squared) and OneNote extensively, but they’re separate. I remember in 2007 fantasizing about a “OneNote Extender” that had an active digitiser (pen input), a screen based on colour e-ink and a battery that lasted all day. My great dream of OneNote everywhere may be nigh at last.
  • Media consumption. Movies, music. I’d love built-in WIDI or WHDI so that I can have a second display that’s not physically connected. Fire up a movie, flick it to the second screen, and continue computing on the laptop, wirelessly.
  • Business needs. A TPM and fingerprint reader will make my life easier and protect any sensitive client data.
  • Photo and video editing
  • Web browsing / Facebook / Twitter / Online shopping
  • Reading (replace Kindle?)

So those are the use cases, but what about hardware? I typically prop my laptop up on a stand and plug in an external keyboard and mouse anyway (my favourites are Cherry MX-based keyboards and Logitech trackballs), so a slate with an iMac-esque desktop dock could be very nice. Leave the stand/kb/mouse/charger waiting at home, and tote just the slate when you’re out and about. A transformer could fit this bill too.

Another related option is something small, like a 7” slate that also plugs into a dock, this time with a touchscreen display.

Or split them into two: a workhorse laptop for my livelihood (a la the new MacBook Pro…I just wish that Retina display was a touchscreen) and a media-consumption & note-taking Windows RT device. I’d love something about the same size as my Moleskine (would equate to a 7 or 8” screen) with incredible battery life and pen input. My fingers are crossed for Nokia to deliver something great here.

Decisions, decisions. It’s hard to predict what use cases and hardware options will win me over in the coming months.

Monday, April 16, 2012

My next mobile is an HTC One X

It’s no secret that I’ve historically been a consumer of Microsoft’s mobile devices, their development platforms, and their cloud services. And so it may come as a bit of a surprise that today I ordered an HTC One X, running Android 4.0, Ice Cream Sandwich.

htc-one-x-pressAs my last phone was a Samsung Focus running WP7.5 Mango, it’s a departure from my comfort zone, but an experiment I really want to try. I have a lot of time and technology invested around the Microsoft stack: I use Live Mesh, store a bunch of documents in Sky Drive, have a Zune Pass, use Office, and have a corporate Exchange account for email. Zune on Windows is the most beautiful piece of software possibly ever, and its subscription music service is one of the best. I don’t do heavy Office work on the phone, but I use OneNote all the time for jotting things down (book or movie recommendations from friends, for example) and making shopping lists on my PC and effortlessly syncing it over the cloud. I keep a workout journal in Excel, but have only used Word or Powerpoint for viewing stuff from my colleagues.

tech_nokia_lumia_900I’ve been waiting for the Lumia 900 (in Cyan) since it was announced four months ago at CES. It’s making a splash in The States, but hasn’t been announced in Australia and I’m getting sick of waiting. It’s beautiful, and in my opinion the most striking piece of industrial design in the mobile market right now (the One X is my second favourite, and the iPhone 4 is my third—but really the iPhone only loses marks for sticking to their 4:3 aspect 3.4” screen and leaving all that dead space on the front).

And when I say “sick of waiting,” I don’t just mean this device. I want a bigger display, and I want it in high PPI retina territory: WP7 only supports one resolution, 480x800, and that’s that, no matter if it’s a 3.4” screen or a 4.7” screen. “Wait for Apollo,” we hear, “it will support dual core processors, NFC and more screen resolutions.”

Not that specs are all that important; WP7 is incredibly well optimized to run on low-end hardware, so for most practical purposes it runs as well on a single core as Android does on a quad core. What I do care about in specs where the One X has an edge is a beautiful screen. HTC One X has the best display on the market, says The Verge. 720p, 4.7”, IPS LCD, "near-perfect 180 degree viewing angles and perhaps the most accurate color reproduction.” Damn, I want that in my pocket.

I’m sick of waiting for Skype. But again, it’s not just that one app (although Microsoft bought Skype 11 months ago and STILL no full-featured WP7 app?), it’s representative of WP7’s rank in the market: tons of apps are only for iPhone and Android. It’s that Adobe Reader has been buggy from day one and seen zero updates. I don’t think this really will affect my life, since about the only apps I use on my phone are a stopwatch, a weather app and LastPass. WP7 has done a phenomenal job of building out the base capability of the OS to include key Twitter and Facebook scenarios making those apps largely unnecessary, plus Sky Drive support eliminating the need for a Dropbox. Their “people first” tag line is true, and I love the way contacts are always up to date with their various statuses and photos. “Wait for it to catch on a little more, it’s a long game to build market- and mindshare.”

And so I’ll wait. I’ll wait for Apollo, and hopefully this One X will tide me over. I had my turn with iOS; it has a great ecosystem but I always felt locked in and restrained in how things work (the way Apple broke backwards compatibility with iPod docs and require Apple-approved accessories lest they disable them in software really steam me). But that’s me, I’m a software developer who makes a living on Microsoft, I have different expectations of how a computer should suit me. I don’t know how I’ll like Android, but when I read The Verge’s review of the Lumia 900, it makes me question what I’m missing: death by a thousand cuts, they say. So let’s see what all the fuss is about, shall we?

Tuesday, January 03, 2012

Personal Cell Phone Timeline

For the sake of nostalgia, a trip down cell-phone memory lane.

c.2000: Nokia 8260, in blue. My first phone ever. What a great, little, itty-bitty feature phone. Not entirely sure of the carrier or model number, but I’m picking 8260 since Cingular/TDMA seems right.
Nokia8260


c.2002: Ericsson T62U. I remember it being comfortable to hold. Cingular, TDMA/GSM both I think. Not entirely sure of the model number but the photo is correct, and the fact that Cingular offered it as a bridge device is convincing.
Ericsson T62U

c.2004: Motorola V400 Camera Phone. Cingular GSM. I actually forgot I owned this phone and never would have remembered the model number had I not found an old email from when I sold it on eBay.
Motorola V400

2005: Audiovox SMT5600. My first smart phone, running Windows Mobile 2003. T-Mobile GSM. I still have this phone; it’s SIM-unlocked. Not all of the buttons still work reliably, but hey, in a pinch, it can dial a number. Supported voice turn-by-turn nav with a Bluetooth GPS unit (GlobalSat BT-338) and (now defunct) software called Mapopolis. What a great device.
audiovox-smt5600

2006: T-Mobile Dash. Awesome phone. Great keyboard. Proprietary HTC headphone jack (jerks).
tmobile-dash_xl

2007: HTC Mogul. Sprint. Giant brick slider, but boy was its data connection FAST for the time! I remember getting like 20X data speeds for half the price of T-Mobile. Keyboard flaked out by the end of its life.
Sprint-Mogul-CDMA-PDA-phone

2008: HTC Touch Diamond. Sprint. Sleek, small, sexy phone with a soft-touch maroon back. Pretty nice skin on WinMo.
htc-touch-diamond-sprint2

2009: iPhone 3GS. A very nice phone, especially once jailbroken.
iphone-3gs

2010: Samsung Focus (i917) / WP7, WP7.5.
samsung-focus-1

2012/April: HTC One X. Gave up waiting for Microsoft. Loved the graceful curve of the body, and it had the most perfect display I'd seen probably ever at that point in time. The slipshod UI turned me off. I blamed Android but retrospectively I suspect it was HTC I should have blamed.



2013/May: Nokia Lumia 920. Lord what a beast. Big, heavy, outstanding camera, could (and did) take a beating. WP8 really started feeling like a "finished" OS.


2014/April: Lumia 925 with Windows Phone 8.1. The svelte version of what the 920 should have been been, with Redmond's most competitive mobile operating system to date. "Cortana, remind me to update my blog this evening."



  • 2014 / 2015 - Moto X, with a very cool leather back (no case needed). Short lived phone. The Stagefright vulnerability knocked it off the work network, it took months to patch, and only lasted a few days back on the work network after getting patched. What a shame.
  • 2014 / 2015 - iPhone 4c - backup phone while waiting for Moto X to get patched.
  • 2016 / 2017 - iPhone 6 - since Android was useless at work, I gave up and got the latest and greatest iPhone.
  • 2017 - 2018 - Google Pixel.
  • 2018 - 2021 - Google Pixel 3.
  • 2021 - present - Samsung Galaxy S21 Ultra. Pretty good take on Android, though I would prefer stock. Also wish the phone had a place to stick the pen.

Saturday, December 17, 2011

Convert Mac Pages to HTML in Powershell


# A very crude Mac Pages to HTML converter in Powershell
# Preserves no formatting save for line breaks.
# Useful to extract the text so you can paste into Word

# A .pages file is a Zip; extract it to get the index.xml file 
# and parse out the paragraphs. 
# Note there's also a preview.pdf in the zip if all you need is to print.

# Pass the .pages file on the command line
# .\Pages-ToHtml.ps1 '.\Path\To\File.pages' > Converted.html
#
# Requires PSCX
Import-Module PSCX
$file = (Read-Archive $args[0] -format Zip ) | Where-Object { $_.Path -ieq "index.xml" } | Expand-Archive -PassThru
$xml = [xml](Get-Content $file)
$layout = $xml.document."text-storage"."text-body".section.layout
# Stripped of all formatting
#$layout.InnerText
# Write paragraphs only
$layout.p | ForEach-Object {
    echo "<p>"

    $_."#text"
    echo 
"</p>"
}

Saturday, July 02, 2011

How to require SSL in IIS7 and Azure with Rewrite

imageThis is a tidy solution. Instead of requiring SSL (and giving 500s if they come over HTTP), use IIS URL Rewrite to check for HTTPS being off—and if so, redirect them (permanent 301) to the same path over SSL. The converse could also be done.

Good news is URL rewrite comes installed out of the box at Azure (looks like v1.2 and above).

Here's an example web.config showing the configuration to ensure that the secure directory requires SSL.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Enforce SSL" enabled="false" stopProcessing="true">
          <match url="/?(secure.*)" ignoreCase="true" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Thursday, June 09, 2011

Enabling IPv6 on Comcast with Buffalo WZR-HP-G300NH

I'm running Buffalo's latest (as of this writing) DD-WRT firmware, V24-SP2 build 16783.

The DD-WRT IPv6 tutorial is in the ballpark, but didn't work for my setup. See the section on 6rd for Comcast-specific scripts; for me, the script never succeeded on startup (I presume because the WAN wasn't up before the script was executed). Here's what actually worked:

  • In the web interface, Administration / Management.
    • IPv6: Enable
    • Radvd: Disable
    • JFFS2: Enable
    • Clean JFF2: Enable (this will format a writable partition where you can store user scripts)
  • Apply, and then reboot the router.
  • For some reason, nslookup 6rd.comcast.net throws a segmentation fault on my router… so the script below shows a hard-coded value IP address. The original script linked above intended to parse the result of nslookup.
  • Use SSH/SCP/SFTP to copy this script onto the router to /jffs/etc/config/ipv6comcast.wanup:

#!/bin/sh
insmod /lib/modules/`uname -r`/kernel/net/ipv6/sit.ko
HOST6RD=69.252.80.66
#nslookup 6rd.comcast.net segfaults
WANIP=$(ip -4 addr show dev eth1 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
if [ -n "$WANIP" ]
then
V6PREFIX=$(printf ' 2001:55c:%02x%02x:%02x%02x' $(echo $WANIP | tr . ' '))
ip tunnel add tun6rd mode sit ttl 255 remote any local $WANIP
ip link set tun6rd mtu 1280
ip link set tun6rd up
ip addr add $V6PREFIX:0::1/32 dev tun6rd
ip addr add $V6PREFIX:1::1/64 dev br0
ip -6 route add 2000::/3 via ::$HOST6RD dev tun6rd
kill -HUP $(cat /var/run/radvd.pid)
fi
echo "interface br0 { \
MinRtrAdvInterval 3; MaxRtrAdvInterval 10; AdvLinkMTU 1280; AdvSendAdvert on; \
prefix $V6PREFIX::/64 { AdvOnLink on; AdvAutonomous on; AdvValidLifetime 86400; \
AdvPreferredLifetime 86400; }; };" \
> /tmp/radvd.conf
radvd -C /tmp/radvd.conf start

Friday, May 20, 2011

Tuesday, May 17, 2011

Triggering Multiple Commands on a Single Button Click in Silverlight XAML

If you're using RIA services and have ever drag-and-dropped a datasource onto a user control, you've likely seem the generated Load button that fires a command to load data:

<Button Content="Load" Margin="3" Name="myDomainDataSourceLoadButton" Command="{Binding Path=LoadCommand, ElementName=myDomainDataSource}" />

If your control has multiple DomainDataSources and you'd like to trigger them all by a single button click, you can change your markup:

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

<Button Content="Load" Margin="3" Name="myDomainDataSourceLoadButton">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click">
            <i:InvokeCommandAction Command="{Binding Path=LoadCommand, ElementName=myDomainDataSource}"/>
            <i:InvokeCommandAction Command="{Binding Path=LoadCommand, ElementName=myOtherDomainDataSource}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Button>

I left out the markup for the DomainDataSource and its query parameters, etc, but this should get the point across.

Wednesday, May 11, 2011

Performance Testing in Azure Dev Fabric

I'm running an application at Azure that runs in Full IIS Mode with Dev Fabric version 1.4 on x64 Windows 7. I set out to run some performance tests, since Memory\Page Faults/sec is high during a few scenarios in production.

Unfortunately, the Visual Studio tooling has not caught up to Azure, so it takes a bit of hacking and Powershell goodness to get the data you need. On the positive side, the Visual Studio tooling is just a UI for the same command line tools we're about to use. Plus, analysis happens exactly the same way that you're used to in Visual Studio.

This tutorial assumes you want Memory and Performance metrics using instrumented assemblies. If you don't want/need Memory, skip the relevant bullet.

NB: Be sure you're using the 64-bit versions of these commands if that is your platform. Also run Powershell as an Administrator if you use UAC. Also, oddly, vsperfcmd doesn't seem to return from the ISE, so you have to use good ol' powershell.exe.

  • Install x64 Performance Tools for Visual Studio 2010 SP1
  • (Optional) Enable CLR memory profiling (allocations, or allocations and lifetimes (shown))
    • & "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64\VSPerfCLREnv.cmd" /globaltracegclife
    • (You may have to reboot for the command to take effect)
    • Important: When you're done, be sure to run the same command with /Off and /GlobalOff switches, otherwise EVERY .NET app on your system will be publishing these metrics and run like dog crap.
  • Build your application
  • Instrument your assemblies in-place
    • $vsinstr = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64\vsinstr.exe"
      dir ".\MyCloudApp\bin\Debug\MyCloudApp.csx\roles\MyWebRole\approot\bin\MyNamespace*.dll" | foreach-object {
          & $vsinstr $_.FullName;
      }
  • Start the performance profiler; it seems this must start before your application (Note I'm naming the .vsp output with a timestamp for easier scripting and history tracking)
    • $vsperfcmd = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64\vsperfcmd.exe"
      $date = get-date -F yyyyMMddHHmmss
      &$vsperfcmd /START:TRACE /OUTPUT:perf_$date.vsp /user:Everyone
  • Start your application via the Azure cloud tool csrun.exe
    • $csrun = "C:\Program Files\Windows Azure SDK\v1.4\bin\csrun.exe"
      &$csrun /devstore:start
      &$csrun .\MyCloudApp\bin\Debug\MyCloudApp.csx .\MyCloudApp\bin\Debug\ServiceConfiguration.cscfg
  • Wait for the appropriate process to start and grab its PID. In my case, since I'm using Full IIS Mode and interested in capturing metrics from RoleEntryPoint and deeper, that process is WaIISHost.exe. If you are running a worker role, that process is WaWorkerHost.exe; "old" web roles use WaWebHost; web sites running under Full IIS Mode use the regular w3wp.exe (though getting the right app pool may be more difficult).
    • while(-not $process) {
          $process = Get-Process | where { $_.ProcessName -ieq "waiishost" };
          start-sleep 0.1;
      }
  • When ready, start capturing instrumented data
    • & $vsperfcmd /processOn:$($process.Id)
  • When done, disconnect and shut down
    • & $vsperfcmd /processOff:$($process.Id)
    • & $vsperfcmd /shutdown

Now open the .vsp and—there you have it—a performance report generated from code running in Azure dev fabric!

image

Wednesday, April 27, 2011

Converting RunAmocs to Huaraches

RunAmoc - LITE<br/>Black
Last summer I bought a pair of RunAmocs, a barefoot running moccasin. They're neat—but I didn't like the fit. They're too loose for running (contrary to other reviews online), and after the initial excitement wore off, I decided that I didn't like the style. Great vision, but it needed to be secured better on the foot.

I finally decided to tear them to bits and turn them into running sandals. I had a few other spare parts lying around, namely, a pair of elastic shoe laces from my "big fat running shoes" days. So I got to cutting.

WP_000236 WP_000238

And then learned about tying. And in the end, ended up with a beautiful little sandal. The elastic closure is incredibly secure while being very easy to get on and off. They way they move with your feet is incredible—I can't believe how many pairs of minimalist shoes I've gone through to find this.

WP_000239

WP_000240The way these things move with your feet is very impressive. Not with your feet—as a part of your feet. I've never felt less resistance to move with me in footwear. This is a 2mm road sole with another 2mm or so of lightly-padded faux (?) leather. I trimmed the toes to fit a little better…but got too aggressive on the right foot. Live and learn. I ordered some pieces from Barefoot Ted's Luna Sandals and will try another iteration shortly. I also picked up some longer 42" elastic laces in plain black (not the reflective black, above) and a proper leather punch (instead of a drill). I am excited.

Friday, April 15, 2011

Using a Vodafone AU Prepaid Data SIM in a Phone

The APN for a prepaid data SIM (at least the one I got bundled with a hardware modem):

APN: vfprepaymbb
Username: web
Password: web

They don't make that obvious, but it works. Cool. Seems to receive phone calls, too… not sure how that counts against the quota.