Technology, Continued...

Ramblings about business, technology, development and my life

Machu Picchu

I just got back from trekking the Inca Trail for four days, culminating in a visit to the cloud city of Machu Picchu.  Words don’t describe how amazing the trip was!  The hike was challenging, with too many steps uphill to count!  But as I’m here at my computer right now, I’m wishing I was on that trail again right this second, even the hardest, most grueling part.  If you’re a technologist, I challenge you to get out and get away… do something crazy!  You won’t regret.  I’m back, and more clear-headed, rejuvenated and excited about what I do than before I left.  Even if my preference would be to be standing at Sun Gate overlooking a lost city :).

IMG_9528_dxo

Using bearer tokens with SignalR

I am using bearer tokens to authenticate my Angular app with my backend WebApi, well, API.  I am adding SignalR to the app, and could not get user.identity.name to resolve to the currently authenticated user when trying to retrieve it from the hub OnConnected method.  Long and short, I had forgotten to add the bearer token to the SignalR ajax requests.  The code to do so is below.

var accessToken = localStorage.getItem("accessToken");
$.signalR.ajaxDefaults.headers = { Authorization: "Bearer " + accessToken };


Once that was done and my startup.cs file was correctly set to use bearer tokens, I was good to go.

Windows 8.1 Update (April 2nd MSDN release) Error Solved

Easy answer: Make sure you have enough disk space free before installing the update!

Long answer: So I immediately jumped at the Windows 8.1 Update MSDN download announced yesterday at Build.  Everything went great until it rebooted during the install.  It got to 77%, then hung for several minutes, then rebooted again.  I was then told it was reverting to the previous version of windows.  When I finally logged back into my machine, a nice app screen came up telling me that the update couldn’t be installed.  At the bottom was the following error code.  I tried this twice… same error at the same place both times.

0x101 0x20007

Sorry the screenshot below is so bad – my screen capture tools weren’t loaded when it was displayed, so I had to take a pic from my Surface I had next to me.

Anyway, I did some googling and found that there are logs here… C:\$WINDOWS.~BT\Sources\Panther.  I don’t remember now, but one of them had the activity log of the entire upgrade attempt.  At the bottom was the answer.  It referenced insufficient disk space!  I had 17gb left on my drive, so it never even crossed my mind that that could be the problem.  However, I cleaned up my HD and tried again with 47gb of space, and it worked perfectly!

image

 

 

 

 

 

Problem solved.

Six Technologies Poised to Change Our Lives

Virtual Reality Headsets

This could go badly.  VR Headsets from Oculus, Sony, and presumably others will provide a level of immersion in (games, work, etc.) like never before.  Sure, this has sort of been done before, but the products being built today are less prone to having users suffer from motion sickness, while the visual quality is much better and the motion sensing is top notch.  The problem is when this gets too good.  I know, movies have already been made about people preferring to live in their VR worlds rather than in the real world.  But look at how much time people spend in video games already, when the level of immersion consists of staring at a monitor.  Once you are so immersed you completely forget about the world outside your 3D, full-depth, motion-sensing, vibrating, visually incredible world, will people ever want to leave it?

3D Printers

3D printers… so much talk, so little practical use so far.  I have one, and it lets me do some pretty cool things to impress my friends and sate my electronics project enclosure needs, but outside of that, the average person has no reason to have one.  Yet.  But as everyone knows, it’s only a matter of time before the killer apps come.  What are they?  Well, if I knew, I’d make them and get rich.  But they will come.  And even without a single killer app, the ability to click Buy and print many objects we use every day will be incredibly valuable.  For that to happen, the printers will have to support multiple colors and dissolvable support materials at a consumer price. 

Meanwhile, there’s a bigger picture outside the consumer space.  Imagine whole buildings getting printed at once.  What will happen when an industrial 3D printer can be blimped onto a concrete foundation and, from there, print the whole house, conduits and all?  Or all other sorts of industries adopt them for consumer-directed pieces of their products?  Custom car… done.  Custom furniture… check.  On demand [insert product here]… check.

3D Vision

3D spatial mapping and vision by computers is going to be vital to manufacturing.  Why?  Because drones (see below) are going to be part of the building process for many products, and they need to know where to go.  Having 3d vision down to the millimeter will be crucial for directing these drones.  Mapping a plot of land will be done with 3D vision, not surveyors.  Oh, and then there’s video games.  Imagine being able to walk through your house, your friend’s houses, and your neighborhood with your tablet, then uploading the 3D map and textures to your favorite game.  Pair this with the VR headsets, and you’ll play whatever game of destruction you want where you live and work, without breaking anything.

3X Battery Improvement

We need better battery density, and we’ll get it.  Graphene, quantum physics, metamaterials.  Something, at some point, is going to increase battery life 3x in a cost effective manner.  When it does, say bye to gasoline cars.  That will be huge.  Cars will be simple to maintain (no engine) and cheaper to run.  Our dependence on foreign oil will be broken for good.  Phones will last a day with 3x the features (you don’t think phone makers would let you get three days when they can add more features, did you?).

Drones

Drones… where to begin.  First, privacy was already dead, and drones just make it even deader.  There will be no place a drone can’t sneak into with camera and microphone in tow.  Just check out the military’s development of super-small drones to see what I mean.  That’s the bad news.  The good news is that drones will be used for manufacturing in new ways.  If a house is going to be four-sided brick, easy.  Just have the drones lay it.  No more paying a huge premium for a quality, good looking house.

Quadrocopter cars

This is the one that’s not on most people’s radar, but should be.  Everyone thinks the future of transportation is autonomous cars, and maybe it is.  But why are cars so hard to make autonomous?  First, legacy.  We have legacy streets, cities, vehicles and laws that were never made for cars that drive themselves.  If we could redo everything and have wider streets, pedestrian crosswalks that were always elevated, and vehicles that were built from the start to communicate with each other, maybe, maybe we could make it work.  But cars run in a very narrow two dimensional space that can’t be enhanced.  If a tire blows or a pedestrian isn’t where they’re supposed to be, or there’s snow, or heavy rain, or an accident around the corner you can’t see, and a car makes a mistake, we won’t tolerate it. 

Now, with all that said, sure, given enough time, anything I say will be wrong.  But I think there’s time for a new mode of transportation to take the place of the car.  I think quadrocopters as human-moving vehicles could make a lot of sense.  First, the challenges.  First, there’s the power requirements.  This is the single biggest challenge, and without the battery improvements above, this idea will never work.  But let’s assume (big assumption, but doable) that we overcome the power needs.  The second challenge is safety.  You’re in the air and something goes wrong.  You can’t exactly coast to the curb.  That’s a problem.  However, people die on the roads on a consistent basis, so automobiles aren’t exactly a model of safety from an absolute perspective.  The great thing about quadrocopters (ok, so the actual vehicle might have three, five, six or however many rotors – but quadrocopter sounds good) is that an incredible amount of redundancy can be built into a quadrocopter.  First, the batteries can be separated into two packs that each feed two opposed rotors.  Second, each rotor can have individual motors and redundant electronics.  With software, it’s been shown that a quadrocopter could land itself with half of the rotors non-operable. 

So those are the big negatives.  The positives are much bigger than the negatives.  Where to begin?  First, as the crow flies distances.  No more right-angle commutes.  The shortest distance wins.  Second, capacity.  We would now be operating in a 3D space.  This means there’s no real limit to the number of “lanes” and no limit to how many of those lanes we can stack on top of each other.  Third, safety.  Wait, didn’t I list that as a negative.  Yes, for the people in the quadrocopter in the event of something catastrophic.  But for pedestrians, it’s a new world.  There are no pedestrians in the air.  Problem solved.  Fourth, autonomy.  Making a car be able to sense it’s environment is incredibly hard.  Making an object in the air sense its environment is much easier.  Landing would be the only challenge, and it’s not a huge challenge, since you’re working in a vertical environment instead of a horizontal environment.

Summary

Why’d I write this?  Because I had some extra time today, that’s why.  As you can tell, I’m a guy who reads too much about technology.  It was time to write down some of the future thoughts swirling in my brain.  It’ll be interesting to see what I got right and what I didn’t.  Personally, if I just get the quadrocopters right I’ll be a happy commuter!

Sublime Text Key Mappings From a Visual Studio User

I have been updating my Sublime key mappings little by little to match the keystrokes I use often in Visual Studio.  Here are the ones I have so far (the text of the command should make them relatively self-explanatory.

To change the keystrokes in Sublime (I’m using V3), choose Preferences –> Key Bindings – User.

image

 

 

 

 

 

 

    { "keys": ["f12"], "command": "goto_definition" },
    { "keys": ["alt+w"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
    { "keys": ["ctrl+s"], "command": "save_all" },
    { "keys": ["ctrl+-"], "command": "jump_back" },
    { "keys": ["ctrl+shift+-"], "command": "jump_forward" },
    { "keys": ["ctrl+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
 

Phonegap and fast resume on WP8

When building a Phonegap application for the Windows Phone platform, it defaults to not enabling fast resume.  To back up a bit, when you use the back key to return to a WP8 application, it resumes where you left off.  However, when you return to the application via other means, such as the start menu, the application will restart.  There are some reasons why you might want this, but I personally can’t think of many for the average user.  Normally I want to return to my same place in the application regardless of how I’m getting to the application (one exception is with alerts, where the user does need to see the alert within the application itself).

So, if you want to have your Phonegap application fast resume, you need to change a setting the AppManifest file for the WP8 app.  With Phonegap, it will be at the following path off of your application’s home directory…

app/platforms/wp8/Properties/WMAppManifest.xml

Find the DefaultTask element and add ActivationPolicy=”Resume”.

<DefaultTask ActivationPolicy="Resume" Name="_default" NavigationPage="MainPage.xaml" />

For more information, this is a great read on fast resume.

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj735579(v=vs.105).aspx

Little tricks for the Windows Phone 8 emulator

I found two handy posts about using the WP8 emulator.

Starting the WP8 emulator without going through Visual Studio.

http://social.technet.microsoft.com/wiki/contents/articles/18173.how-to-launch-windows-phone-8-emulator-without-using-visual-studio-2012.aspx

Using the keyboard on your computer with the WP8 emulator. 

Note that it’s opposite depending on whether you’re using WP7 or WP8 (WP8 is page down).

http://aceontech.com/2013/04/08/how-to-use-your-computers-keyboard-with-the-windows-phone-emulators/

Copying Azure VMs from one account to another

I had to copy my VM blob from one account to another.  I wanted a way that wouldn’t require me to download the vhd locally, just to then have to turn around and upload it again.  Instead, I wanted to be able to have the copy done within the Azure cloud itself.  Fortunately, I found free software to do just that.  It’s called AZCopy.  Here’s the link you need:

http://blogs.msdn.com/b/windowsazurestorage/archive/2013/04/01/azcopy-using-cross-account-copy-blob.aspx

You don’t have to install anything.  Just run it from the command prompt.  Here’s the syntax of the command I used:

   1: AzCopy https://<sourceaccount>.blob.core.windows.net/<sourcecontainer>/ https://<destaccount>.blob.core.windows.net/<destcontainer>/  /sourcekey:<key> /destkey:<key> /S

I’m not sure when you have to use https and when you don’t.  My paths in Azure didn’t show https, but when I tried to copy to my destination, I kept getting the error below.

Error parsing destination location "http://dest.blob.core.windows.net/vhds/": The underlying connection was closed: An unexpected error occurred on a receive.

Once I changed it to https, it worked great.  Here’s the output of my results.

C:\_utilities>azcopy http://source.blob.core.windows.net/vhds/ https://dest.blob.core.windows.net/vhds/ /sourcekey:srckey /destkey:dstkey /S

Transferring files /

Transfer summary:
-----------------
Total files transferred: 1
Transfer successfully:   1
Transfer failed:         0

127GB copied in just a few minutes!  Perfect.

SSRS 2012 Tile View Customization

I don’t know about you, but I don’t like the default tile view in SSRS 2012.  First, I feel like there’s too much white space.  Second, I want my report titles to wrap.  And finally, I don’t want the dropdowns on the tile view.  I’m constantly getting them when I just want to view the report (especially on touch devices), and it confuses my users.

Desired Outcome

So, I want to customize SSRS report list view to change the following:

image

 

To be more like this.  Wrapping, check.  Less whitespace, check.  No dropdown, check.

image

 

Again, importantly, I DO want the dropdown in the Details view, and the changes below do so.

Instructions

To do this, we have to edit the report javascript and css files.  I found more info here:

http://msdn.microsoft.com/en-us/library/ms345247(v=sql.110).aspx

On my server, the files were under the following directory:

C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportManager

Under this folder is a js and a styles folder.  The js folder has ReportingServices.js, while the styles folder has ReportingServices.css.  These are the two files we’ll be editing.

ReportingServices.js

Warning: this is a hack done in about 30 minutes.  I haven’t tested on different browsers or in all scenarios, so use at your own risk.

ReportingServices.js is compressed, so it’s rather jumbled.  Instead of finding the existing functions that need to be changed, just go to the end and insert the following javascript:

   1: //jw 2013-07-30
   2: //customized this to stop dropdown on tile view while still allowing it on details view
   3:  
   4: //this will stop the custom formatting for the dropdown
   5: function ChangeReportItemStyleOnMouseOver(a, c, b) {
   6:     var tagname = GetUnSelectedParentTagName(this);
   7:  
   8:     if (tagname == "DIV") {
   9:         return true;
  10:     }
  11:     else {
  12:         _unselectedItemStyle = b;
  13:         _mouseOverItem = a;
  14:         if (_tabFocusedItem != "") {
  15:             ChangeReportItemStyle(_tabFocusedItem, _unselectedItemStyle);
  16:             _tabFocusedItem = ""
  17:         }
  18:         ChangeReportItemStyle(a, c)
  19:     }
  20: }
  21:  
  22: //this will stop the click event from displaying the dropdown
  23: function Clicked(b, l) {
  24:     var tagname = GetUnSelectedParentTagName(this);
  25:  
  26:     if (tagname == "DIV") {
  27:         return true;
  28:     }
  29:     else {
  30:         if (!_onLink) {
  31:             ClearTimeouts(); SelectContextMenuFromColletion(l);
  32:             _itemSelected = true;
  33:             if (b == null) b = window.event;
  34:             var i = b.target != null ? b.target : b.srcElement, a = GetOuterElementOfType(i, "table"), e = GetElementPosition(a); _selectedItemId = a.id;
  35:             _selectedIdHiddenField.value = a.value;
  36:             a.className = "msrs-SelectedItem";
  37:             ResetContextMenu();
  38:             var g = _divContextMenu.offsetHeight, h = _divContextMenu.offsetWidth, o = a.offsetHeight, p = a.offsetWidth, j = e.left, k = e.top, d = 0, c = 0;
  39:             if (typeof window.innerWidth == "number")
  40:             { d = window.innerWidth; c = window.innerHeight }
  41:             else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  42:                 d = document.documentElement.clientWidth;
  43:                 c = document.documentElement.clientHeight
  44:             }
  45:             else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
  46:                 d = document.body.clientWidth; c = document.body.clientHeight
  47:             }
  48:             var f = document.compatMode && document.compatMode != "BackCompat" ? document.documentElement : document.body, m = document.all ? f.scrollLeft : pageXOffset, n = document.all ? f.scrollTop : pageYOffset; _divContextMenu.style.left = SetContextMenuHorizonatalPosition(d, m, j, h, p) + "px";
  49:             _divContextMenu.style.top = SetContextMenuVerticalPosition(c, n, k, g, o) + "px";
  50:             ChangeOpacityForElement(100, _divContextMenu.id);
  51:             document.getElementById(_currentContextMenuId).firstChild.focus()
  52:         }
  53:     }
  54: }
  55:  
  56: //gets tag name before the object with the specified class name.
  57: //i found that it's a DIV in tile view, and not when in details view, so it's the differentiator i use to see what view i'm in
  58: //i'm sure there are multiple ways to do this, and this way is brittle, but hey, it works for now.
  59: function GetUnSelectedParentTagName(obj) {
  60:     var tagname = "";
  61:     try {
  62:         var src = obj.event.srcElement;
  63:         while (src.className != "msrs-UnSelectedItem") {
  64:             src = src.parentNode;
  65:         }
  66:         tagname = src.parentNode.tagName;
  67:  
  68:     }
  69:     catch (e) {
  70:     }
  71:     return tagname;
  72: }

That’s it.  Basically I’m finding out whether we’re in tile or details view by seeing if our menu item is contained in a DIV (for tile view) or not.  If we are in a div, I just stop processing in the key functions.

ReportingServices.css

I only changed two styles in the stylesheet.  Here’s the old style:

   1: div.msrs-tileView { float: left; height: 70px; }
   2: a.msrs-itemName  { white-space: nowrap; width: 250px; overflow: hidden; text-overflow: ellipsis; color:#000000; }

And here’s the new:

   1: div.msrs-tileView { float: left; height:50px; }
   2: a.msrs-itemName  { width: 250px; text-overflow: ellipsis; color:#000000; }

Basically, I’m tightening up the whitespace by changing the height of each tile menu item, and then I’m stopping the style from hiding the overflow text, and letting the text wrap.

Summary

That’s it.  If you do this correctly, the changes will be reflected immediately after saving the css and js files and refreshing your tile view.