Quantcast
Channel: Scott Hanselman's Blog
Viewing all 1148 articles
Browse latest View live

Introducing Visual Studio Code for Windows, Mac, and Linux

$
0
0
Screen Shot 2015-04-28 at 11.33.49 PM

What a wonderful time to be developer. I'm down here at the BUILD Conference in San Francisco and Microsoft has just launched Visual Studio Code - a code-optimized editor for Windows, Mac, and Linux and a new member of the Visual Studio Family.

Visual Studio Code (I call it VSCode, myself) is a new free developer tool. It's a code editor, but a very smart one. It's cross-platform, built with TypeScript and Electron, and runs on Windows, Mac, and Linux.

Visual Studio Code has syntax highlighting for dozens of languages, the usual suspects like CoffeeScript, Python, Ruby, Jade, Clojure, Java, C++, R, Go, makefiles, shell scripts, PowerShell, bat, xml, you get the idea. It has more than just autocomplete (everyone has that, eh?) it has real IntelliSense. It also as IntelliSense for single files like HTML, CSS, LESS, SASS, and Markdown. There's a huge array of languages that Visual Studio Code supports.

IMHO, the real power of this editor is its project IntelliSense for C#, TypeScript, JavaScript/node, JSON, etc. For example, when an ASP.NET 5 application is being edited in Visual Studio Code, the IntelliSense is provided by the open source projects Roslyn and OmniSharp. This means you get actual intelligent refactoring, navigation, and lots more. Visual Studio Code's support for TypeScript is amazing because it has JavaScript and TypeScript at its heart.

Visual Studio Code has git support, diffs, interesting extensibility models through gulp, and is is a great debugger for JavaScript and Nodejs apps. They are also working on debugging support for things like the .NET Core CLR and Mono on all platforms.

This a code-focused and code-optimized lightweight tool, not a complete IDE. There's no File | New Project or visual designers. If you live and work in the command line, you'll want to check free tool out.

You can download Visual Studio Code now at http://code.visualstudio.com.

They'll be blogging at http://blogs.msdn.com/b/vscode and you can email them feedback at vscodefeedback@microsoft.com and follow them at @code.

Download Visual Studio Code and check the the docs to get started. Also note the docs for ASP.NET support and Node.js support. Visual Studio Code is a preview today, but it's going to move FAST. It automatically updates and will be updating in weeks, not months.

And here's some screenshots of Visual Studio Code because it's awesome. Code what you like, how you like, on what you like, and you can run it all (by the way) in Azure. ;)

Screen Shot 2015-04-28 at 11.17.59 PM
Screen Shot 2015-04-28 at 11.28.35 PM

 
image

Have fun!


Sponsor: Big thanks to the folks over at Grape City for sponsoring the feed this week. GrapeCity provides amazing development tools to enhance and extend application functionality. Whether it is .NET, HTML5/JavaScript, Reporting or Spreadsheets, they’ve got you covered. Download your free trial of ComponentOne Studio, ActiveReports, Spread and Wijmo.


© 2015 Scott Hanselman. All rights reserved.
     

Setting up Windows 10 for IoT on your Raspberry Pi 2

$
0
0
Windows 10 IoT on small embedded devices

Windows 10 Raspberry Pi robotThis week at the BUILD conference in San Francisco Microsoft released the first preview of Windows 10 IoT (Internet of Things) for Raspberry Pi 2 (as well as other lovely devices like the Intel Galileo and MinnowBoard Max).

First, as I mentioned in February the Raspberry Pi 2 runs the Windows 10 IoT version. That means there is no "shell" or Windows Explorer. It's not a tiny desktop PC, but rather the core brain of whatever embedded maker thing you choose to build with it. The core of it is Windows. You've got PowerShell, you can run Windows Universal Apps that you write in C#, and you can talk to peripherals.

Over here at http://microsoft.hackster.io there is a great list of projects you can build with Windows IoT, including a cool robot you can control with an Xbox Controller.

Installing Windows 10 on your Raspberry Pi 2

This is an early build so things will change and get easier I'm sure. To be frank, getting the builds for Raspberry Pi took some confusing on my part to download.

  • hto the Windows Embedded Connect site and sign in.
  • Pick the Build you want. I got Windows 10 IoT Core Insider Preview Image for Raspberry Pi 2.
  • You'll need to install this older "File Transfer Manager" if you don't have it. If you have Chrome, you'll need to click the ".dlm" file and open it with the File Transfer Manager. You'll also need to accept two EULAs.
  • Then you'll get a large ZIP file with the image you want inside. Unzip somewhere.
  • Here's a kicker, you'll need a Windows 10 Preview machine to run these commands and install.
    • I built one with a laptop I had around. I'm not sure why Windows 10 is needed. However, once it's setup you can use Windows 8.1 to talk to the Pi 2 or Remote PowerShell in.
  • You should also get Microsoft Visual Studio 2015 RC.
    • After you install 2015, go try to make a Universal App and it will download the Universal Apps SDK.
  • Follow the instructions here.  Below is my summary along with the gotchas that slowed me down.

Now, plug your micro SD card into your Windows 10 PC (I use a micro to USB adapter) and open an Administrator PowerShell and run:

  • wmic diskdrive list brief and make note of the physical disk number of your SD Card.

next run this and change PhysicalDriveN to whatever your SD Card's physical number is.

    dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\\.\PhysicalDriveN /SkipPlatformCheck

  • NOTE: I had some issues and got "Error 50" on one of my micro SD cards. Changing cards worked. Not sure what's up.

Now, just put your micro SD card into your Pi 2 and boot up your Pi 2 while connected to a display and Ethernet. It will initially startup very slow. It could be 2 to 4 minutes before you get to the main screen. Just hang in there until you see this screen. This is the Default app and just shows the IP Address of your Raspberry Pi 2.

Installing Windows 10 on a Raspberry Pi 2 

Now, from your local admin PowerShell run these commands to remote into your Pi 2. The default name is MINWINPC but you can also use the IP Address.

net start WinRM

Set-Item WSMan:\localhost\Client\TrustedHosts -Value MINWINPC
remove-module psreadline -force
Enter-PsSession -ComputerName MINWINPC -Credential MINWINPC\Administrator

When the credentials dialog opens, make sure you use yourrpi2machinename\Administrator or yourrpi2ipaddress\Administrator for the user name. I was just using Administrator. The default password is p@ssw0rd and you should change it.

See here how the PowerShell prompt changes to include the remote machine's name after I've remoted in?

remoting into Windows 10 on a Raspberry Pi 2

On your Windows machine install the MSI that was included in the download. It will start a small watcher utility that will scan your network and look for Microsoft IoT devices. It's easy to lose them if their IP address changes. It also has a nice right click menu for getting to its embedded web server.

Windows IoT Core Watcher

Included and running on the image is a web server that will let you explore attached devices and running processes.

Raspberry Pi 2 Windows 10 Web Management

You can also deploy applications from here although you'll usually do it from Visual Studio.

Raspberry Pi 2 Windows 10 Web Management

As of the time of this blog post they didn't have WiFi and Bluetooth ready yet but they are updating it often so I am sure we'll see updates soon. Here is a list of devices that work today via USB.

There's lots of samples. You can make Background (headless) IoT apps or do ones with a UI since the Raspberry Pi has HDMI built in.

Finally, here's turning on an LED from C# (with comments and defensive code).

using Windows.Devices.Gpio;


private void InitGPIO()
{
var gpio = GpioController.GetDefault();

// Show an error if there is no GPIO controller
if (gpio == null)
{
pin = null;
GpioStatus.Text = "There is no GPIO controller on this device.";
return;
}

pin = gpio.OpenPin(LED_PIN);

// Show an error if the pin wasn't initialized properly
if (pin == null)
{
GpioStatus.Text = "There were problems initializing the GPIO pin.";
return;
}

pin.Write(GpioPinValue.High);
pin.SetDriveMode(GpioPinDriveMode.Output);

GpioStatus.Text = "GPIO pin initialized correctly.";
}

Deploying from Visual Studio

Make sure the remote debugger is running with schtasks /run /th StartMsVsmon and connect with no authentication while it's running.

image

Now you can deploy a Universal App (with UI!) directly from Visual Studio:

image

And here is my amazing app. Which is basically just a bunch of controls I through onto the XAML. But still. Fancy!

My XAML app running on my Raspberry Pi 2 with Windows 10

Windows Remote Arduino and Virtual Arduino Shields

A few other cool maker things worth pointing out are Windows Remote Arduino and Virtual Arduino Shields. Remote Arduino lets you talk to your Arduino from your Windows  machine using the Firmata protocol. Then you can reach out to an Arduino device and give it commands from a Windows Universal app. The Virtual Arduino Shields lets you use a Windows Phone as a well, just that, virtual shields. Shields for Arduino can add up and when you're prototyping you may not want to shell out for a Gyro or GPS. A cheap phone like a Lumia 530 has like $200 worth of sensors (gps, touch display, gyro, internet, speech, etc) in it that you can exploit.

It's early days but I'm pretty stoked about all the options that Makers have available. The ASP.NET team is in talks with the IoT folks to see if we can get ASP.NET 5 running on Windows IoT on a Raspberry Pi as well, so stay tuned. Get started here.

Related Links


Sponsor: Big thanks to the folks over at Grape City for sponsoring the feed this week. GrapeCity provides amazing development tools to enhance and extend application functionality. Whether it is .NET, HTML5/JavaScript, Reporting or Spreadsheets, they’ve got you covered. Download your free trial of ComponentOne Studio, ActiveReports, Spread and Wijmo.



© 2015 Scott Hanselman. All rights reserved.
     

BUILD 2015 ASP.NET 5 Training Videos - Introduction and Deep Dive

$
0
0

First, here's a few great annoucments and little details that you might have missed during the BUILD Conferenceapalooza last week. Amidst all the Windows 10 and the Holograms, Microsoft also did these interesting things.

Not to mention a lot of blog posts, not the least of which being these: ScottGu, TMyerson, Soma, BHarry, ScottHa, VS team, VS Code, ALM series, .NET roll-up, ASP.NET 5 and EF 7, Azure SDK 2.6, C++, and more

But, that's not what this blog post is about. This one is about you learning ASP.NET 5. Join us LIVE every Tuesday for the ASP.NET Community Standup to start.

At BUILD this year Scott Hunter and Damian Edwards and I teamed up for two hours of ASP.NET 5 training. Those videos are up now at Channel 9 and we think they are pretty great. At the end you should have a good working understanding about what's going on with ASP.NET 5 and the DNX environment, as well as cross platform development and why. You'll also want to spend some time at our beta docs site (built with ReadTheDocs) here http://docs.asp.net and get involved.

One note about these videos. Be sure to download the HIGH-RES version as they include the split screen and let you see both the screen AND the people. The low-res ones will give you just the screen sharing.

Introduction to ASP.NET 5 - Part 1 - Download

Deep Dive into ASP.NET 5 - Part 2 - Download

I hope you enjoy these!


Sponsor: Big thanks to the folks over at Grape City for sponsoring the feed this week. GrapeCity provides amazing development tools to enhance and extend application functionality. Whether it is .NET, HTML5/JavaScript, Reporting or Spreadsheets, they’ve got you covered. Download your free trial of ComponentOne Studio, ActiveReports, Spread and Wijmo.



© 2015 Scott Hanselman. All rights reserved.
     

How to set a Network to a "Private Network" in Windows 8.1

$
0
0

A while back Windows introduced this concept of public networks and private networks. Basically it comes down to a question of "do I mostly trust this network?" However, it's never been totally obvious how to change this back and forth. There's lots of posts on the internet explaining how, but most are pretty complex with a lot of steps.

The most common reason to want Windows to treat the current network as a Private Network is so you can have someone connect to your machine, either share files over SMB, or connect via Remote Desktop (RDP). I hit this issue probably once a month where I can't figure out why I can't see this machine over Remote Desktop, and it's because it thinks I'm on a Public Network.

One technique is to go to Network within Windows Explorer and try to get this yellow bar to show up.

Network Discovery and file Sharing are turned off. Network Computers and devices are not visible.

Clicking on it will give you a choice that isn't clear to Non-Technical Family Member.

Do you want to turn on Network discovery and file sharing for all public networks? NO

No is the right answer, always. But this is a bad dialog because it looks like a Sophie's Choice.

You WANT to treat THIS NETWORK - the one you are on - as a Private Network. Select No.

A better, clearer way to change a Network to Private Network

  • Press the Windows Key + W to search Settings.
  • Type "Network Connections" and Press Enter

Windows 8.1 Network Connections

  • Click on your Network
  • Turn "Find PCs and Content" to ON. This Network is now a Private Network.

Find Devices and Content

Don't believe me? Bring it up side by side with the Classic Network Center and watch it switch back and forth in real-time!

Switching a Network Private in Windows 8
Switching a Network Public in Windows 8

I hope this helps you out as much as it did me!


Sponsor: Big thanks to the folks over at Grape City for sponsoring the feed this week. GrapeCity provides amazing development tools to enhance and extend application functionality. Whether it is .NET, HTML5/JavaScript, Reporting or Spreadsheets, they’ve got you covered. Download your free trial of ComponentOne Studio, ActiveReports, Spread and Wijmo.


© 2015 Scott Hanselman. All rights reserved.
     

The Mysterious Case of the Rogue Roaming Browser History - Removing OneView Internet Login

$
0
0

I like a good mystery and I hope you do, too. I'll give you two versions. First, the TL;DR version so you can just fix it, and later second, the maddening technical details.

See how it flashes OneView Internet Login in the title for a moment?

TL;DR - Why does my Internet Explorer say OneView Internet Login?

If you go googling for "OneView Internet Login" google will suggest things like "...remove." You'll find Yahoo Answers where folks are thinking they have a toolbar installed or a virus because when they launch Internet Explorer they see a flash of OneView Internet Login in the title bar.

To remove it, go to the Star in Internet Explorer's toolbar and click History, then By Site. Find "One View Internet Login," right click and delete that history record.

Note here in this screenshot that the site is http://google.com but the Title is OneView Internet Login. Delete that.

NOTE: If your home page is not google, then find your IE home page by Site, and delete the entry with the wrong title. Or, go nuclear and clear all history.

Delete it from your history

CSI: My Computer - Why does OneView Internet Login show up on all my computers? What is it and why won't it go away?

A year ago or so I stayed at a Hyatt Hotel. Hotels like the Hyatt often use "Captive Portals" when getting you on their internet. A captive portal "captures" your browser's traffic so no matter what site you asked for you'll get their login screen. So you get on their wi-fi, you type googlebing and they redirect you to GlobalSuite.net or whatever to sign up. Only then does your traffic go through.

If you visit a hotel like this and hit it with IE for the first time with a fresh cache (nothing in your history or you've recently cleared your history) the Title that gets saved in the browser database will be the URL of the site you asked for but the title of the Hotel's Captive Portal. Weird? Just wait.

I noticed that my laptop would flash OneView Internet in the title (see the animated gif above) when opening my home page for the first time. Every once in a while I'd go looking for it, search the registry, do a hard-drive-wide grep or findstr but then I'd give up.

Later, though, my desktop at home started showing OneView Internet Login in the title bar on startup. To be clear, that's my desktop computer that hasn't left my house.

Roaming, my friends. All browsers roam things now. They roam passwords, history, bunches of stuff. This record, this cache, this tab, this something was getting roamed to all 5 of my machines. Now every time I open a browser on any machine I own I get a little gentle reminder of how hotel wi-fi sucks and how the GlobalSuite OneView Internet Login Captive Portal is sending a 301 or lousy headers or something dumb. Next time I stay there I'll do a Fiddler trace and prove it. Until then I wanted to find out where this was being stored on my hard drive.

Where is IE History stored? It's stored in a database using a technique called Extensible Storage Engine or ESE. In fact, Windows has shipped this database tech for over 13 years. You can even use it in your apps as a free and fast local database, but no one knows it exists. Over at NirSoft there are a host of wonderful utilities (they are saints, truly, give them money) and one of them is the ESEDatabaseView.

Run ESEDatabaseView and go File | Open IE10 Locked Database (even though you may be using IE11) and you'll be into the depths.

NirSoft's ESEDatabaseView

In a tabled called Container one I found a bunch of history entries:

The offending Entry

There's my first tab, my home page, but I didn't find "OneView Internet Login" or even the word OneView. I searched the while database, every table.

I was stuck here for a while.

Then I noticed way off to the right (like I literally had to scroll off to the right) there was  column called ResponseHeaders with a bunch of HEX.

20 01 00 00 1C 01 00 00 31 53 50 53 A1 14 02 00 00 00 00 00 C0 00 00 00 00 00 00 46
11 00 00 00 17 00 00 00 00 13 00 00 00 00 00 00 00 41 00 00 00 10 00 00 00 00 1F 00
00 00 17 00 00 00 4F 00 6E 00 65 00 56 00 69 00 65 00 77 00 20 00 49 00 6E 00 74 00
65 00 72 00 6E 00 65 00 74 00 20 00 4C 00 6F 00 67 00 69 00 6E 00 00 00 00 00 15 00
00 00 18 00 00 00 00 40 00 00 00 40 E8 3E C4 96 8E D0 01 11 00 00 00 0D 00 00 00 00
13 00 00 00 00 00 00 00 11 00 00 00 09 00 00 00 00 13 00 00 00 00 00 00 00 11 00 00
00 22 00 00 00 00 13 00 00 00 00 00 00 00 11 00 00 00 06 00 00 00 00 13 00 00 00 0A
00 00 00 55 00 00 00 15 00 00 00 00 1F 00 00 00 22 00 00 00 68 00 74 00 74 00 70 00
3A 00 2F 00 2F 00 77 00 77 00 77 00 2E 00 67 00 6F 00 6F 00 67 00 6C 00 65 00 2E 00
63 00 6F 00 6D 00 2F 00 66 00 61 00 76 00 69 00 63 00 6F 00 6E 00 2E 00 69 00 63 00
6F 00 00 00 00 00 00 00 00 00 00 00 DC 00 00 00 D8 00 00 00 31 53 50 53 A1 14 02 00
00 00 00 00 C0 00 00 00 00 00 00 46 11 00 00 00 20 00 00 00 00 03 00 00 00 00 00 00
00 11 00 00 00 14 00 00 00 00 03 00 00 00 01 00 00 00 15 00 00 00 28 00 00 00 00 40
00 00 00 70 0D 51 33 D8 6C D0 01 11 00 00 00 21 00 00 00 00 13 00 00 00 00 00 00 00
3D 00 00 00 1D 00 00 00 00 42 00 00 00 1E 00 00 00 70 00 72 00 6F 00 70 00 34 00 32
00 39 00 34 00 39 00 36 00 37 00 32 00 39 00 35 00 00 00 00 00 08 00 00 00 EB 03 00
00 00 00 00 00 15 00 00 00 1E 00 00 00 00 40 00 00 00 3C DC B8 DF 12 6D D0 01 11 00
00 00 1C 00 00 00 00 03 00 00 00 00 00 00 00 11 00 00 00 27 00 00 00 00 13 00 00 00
01 00 00 00 00 00 00 00 00 00 00 00           

First thing I noticed (I assume you do also) is all the zeros. They are mostly not used as if this is UTF16. But I really look for HEX that I know. That means CR, LF, and Space, so 0D, 0A, and 20.

See that there?

4F 00 6E 00 65 00 56 00 69 00 65 00 77 00 20 00 49 00 6E 00 74 00 65 00 72 00 6E 00
65 00 74 00 20 00 4C 00 6F 00 67 00 69 00 6E 00 00 00 00 00 15 00 00 00 18

That's One View Internet Login. I converted from Hex to ASCII/UTF16. There's lots of online Hex to String Convertors where you can just paste this into a text box. I can also put the string above into a PowerShell string and convert it like this:

$HEXDATA.Split(“ “) | FOREACH {WRITE-HOST –object ( [CHAR][BYTE]([CONVERT]::toint16($_,16))) –nonewline }

There it is, OneView Internet Login. The title of the portal was cached along with the original URL (google.com) and the location to the favicon. When IE hits the page it shows what it has and then corrects it as soon as it gets the current title.

image

What's not clear to me is why this never expired. This title sat around for a year, at least. Maybe an IE engineer will read this and answer in the comments. If they do I will update the post with their answer.

The Good News is that if you delete the history record manually as seen at the very top of this post, that delete will roam and automatically fix this issue on all your machines (to be clear, all those that are logged in with the same Microsoft Account and roaming your browser data.

Remember, Dear Reader, the Internet (and your computer and its operating system) is not a black box. Look inside.


Sponsor: Big thanks to the folks over at Grape City for sponsoring the feed this week. GrapeCity provides amazing development tools to enhance and extend application functionality. Whether it is .NET, HTML5/JavaScript, Reporting or Spreadsheets, they’ve got you covered. Download your free trial of ComponentOne Studio, ActiveReports, Spread and Wijmo.



© 2015 Scott Hanselman. All rights reserved.
     

Git-deployable F# based Web Applications in the Azure Cloud with WebSharper

$
0
0

Web Apps with WebSharper and F#Last month after I wrote a small prototype to get the F# Suave.io web framework running on Azure Web Apps (a git deployed managed Platform as a Service) I started looking for more F# Azure resources.

Here's a list of some other existing F# programming technologies that are great with Azure. Did I miss any? I surely did. There's a huge list up at FSharp.org for resources running F# on any cloud.

  • Fog (an F# Azure data scripting API)
  • MBrace (a scalable distributed programming model for F#)
  • FSharp.Data (a set of F# type providers for common cloud data manipulation scenarios)
  • Suave (a simple web development F# library for lightweight microservices including route flow and task composition)
  • FSharp.CloudAgent - a simple framework to easily distribute workloads over the cloud using standard F# Agents as the processing mechanism. Support exists for both simple and reliable messaging via Azure Service Bus, and for both workers and actors.
  • AzureStorageTypeProvider - An F# Azure Type Provider which can be used to explore Blob, Table and Queue Azure Storage assets and easily apply CRUD operations on them
  • Try F# - A web programming console for F# that can be reoriented towards Azure programmability
  • HadoopFs - A lightweight F# implementation of the Hadoop Streaming API
  • FSharp.Azure - A wrapper over WindowsAzure.Store using idiomatic F#

There's also the WebSharper web framework. WebSharper isn't ASP.NET with F#, it's its own idiomatic thing. What's that really mean, "idiomatic?"

You know how when you Google Translate a sentence it doesn't quite work? I mean, it works, but it doesn't feel right. It doesn't feel right because the translator understands the words, and some phrases, but not the idioms - the underlying thoughts that are unique to that language. There was a time a few years back when folks were constantly looking for C# to VB convertors. This is something that's quite possible, almost line for line. However, changing an imperative language into a functional one is not like turning American English into British English. ;) Let functional languages be functional.

F# people like to do things their way and the language has very different goals and ideas than C# so it makes sense there would be a opinionated web framework for F#. I like it.

(Although I'm sure there will be a way to use ASP.NET 5 and MVC with F# in the future, this post isn't about that.)

WebSharper has a VS Extension so you can File New new projects, and here's a hello world ToDo List app (minus the HTML view, which you can see here)

namespace UINextApplication1


open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Notation

[<JavaScript>]
module Client =
type IndexTemplate = Templating.Template<"index.html">

let Tasks = ListModel.FromSeq ["Have breakfast"]

let Main =
JQuery.Of("#tasks").Empty().Ignore

let newName = Var.Create ""

IndexTemplate.Main.Doc(
ListContainer =
(ListModel.View Tasks |> Doc.Convert (fun name ->
IndexTemplate.ListItem.Doc(
Task = View.Const name,
Done = (fun e -> Tasks.Remove name)))
),
Task = newName,
Add = (fun e ->
Tasks.Add(newName.Value)
Var.Set newName "")
)
|> Doc.RunById "tasks"

More interesting is the recent blog post by Adam Granicz where he expands on my "Suave to Azure via GitHub" prototype and shows how to deploy a real F# WebSharper app to Azure Websites via GitHub.

One of the main improvements is that my solution used FAKE and I found myself wanting a binary version of the FSharp compiler as  NuGet. An issue was open and closed within days, simplifying the deployment. Additionally their WebSharper solution creates an ASP.NET app that runs in the context of ASP.NET and IIS, while my Suave solution needed a separate process. WebSharper 3.1 was recently released, and you can see their sample running live in Azure here: http://websharper-clientserver.azurewebsites.net

And of course, you can deploy it to Azure right from here using the Deploy to Azure button!

Deploy to Azure

Do you dabble in F#, are you doing F# professionally? What do you think about F#-based web applications?


Sponsor: Big thanks to Atalasoft for sponsoring the blog and feed this week! If your company works with documents, definitely check out Atalasoft's developer tools for web & mobile viewing, capture, and transformation. They've got free trials and a remarkable support team, too.



© 2015 Scott Hanselman. All rights reserved.
     

Syncing Windows Live Writer Drafts to the Cloud (Dropbox) and other bug fixes

$
0
0

I still use Windows Live Writer (http://www.windowslivewriter.com) to post to this blog. It remains the best little blogging app out there. It has a nice plugin ecosystem, great WYSIWYG editor (using IE) even though it hasn't been updated since 2012. A bunch of us are working to get it open sourced, and I'll let you know the second I know something.

But for now, let me fix two things about Windows Live Writer that have been bugging me.

Clearing Cached Blog Themes

First, a small bug. My HTML Styles look like this, and have for a while. See how the background is black? Annoying. I always assumed it was a GDI or graphics bug. In exploring the Windows Live Writer code I learned a few things.

Windows Live Writer with black styles

It turns out that Windows Live Writer is trying to render your styles by using your download blog theme's CSS inside those little boxes! My blog (and others, I've heard) doesn't render nicely.

The downloaded them is stored in %AppData%\Windows Live Writer\blogtemplates and you can easily fix this annoyance by simply deleting the folders below blogtemplates.

Using the Default Windows Live Writer Theme

Ah, much nicer.

Syncing your Windows Live Writer Drafts with OneDrive or Dropbox

I've seen some blog posts with folks suggesting junction or reparse points (symbolic links) to hack together a way to "roam your draft blog posts" with Windows Live Writer. It's much easier than that, in fact. You can just set a registry key with your preferred Drafts folder. I put mine in my Dropbox, but you could also use OneDrive or Box. This means your local draft blog posts will "roam" to all your machines. If you're someone who works on a blog post for a few days you'll appreciate this new ability. You can start a post at work and finish it at home. Even the images will roam.

Head over to HKCU\SOFTWARE\Microsoft\Windows Live\Writer in your registry (via Regedit.exe) and make a new String Value called "Posts Directory."

image

Windows Live Writer will make new Drafts and Recent Posts folders in the location you specify. I set this registry key on all my machines that I have Dropbox installed and now all my blog post drafts are there too!

I hope this helps you out! And I'll be sure to let you know about our plans with Windows Live Writer as soon as I know more. ;)


Sponsor: Big thanks to Atalasoft for sponsoring the blog and feed this week! If your company works with documents, definitely check out Atalasoft's developer tools for web & mobile viewing, capture, and transformation. They've got free trials and a remarkable support team, too.


© 2015 Scott Hanselman. All rights reserved.
     

Publishing an ASP.NET 5 app to Docker on Linux with Visual Studio

$
0
0

Docker Apps are mostly portableIt's early days, but this is a nice preview of the possibilities of things to come. I often use LEGO bricks in the way of an analogy when talking about software systems. I like the idea of choice, flexibility, and plug-ability. Choosing your language, operating system, deployment method and style, etc are all important.

There is a preview of an extension for Visual Studio 2015 (the release candidate at the time of this writing) that adds Docker support. If you have VS2015 RC you can get the Docker Extension here. You can certainly manage things from the command line, but I think as you go through this post you'll appreciate the convenience of this extension.

NOTE: It's also worth pointing out that there is a Windows client command line for Docker as well. You can "choco install docker" and read about it here.

The Brief What's Docker Explanation

If you aren't familiar with Docker, here's the super basics.

  • Virtual Machines: You likely know what a virtual machine is. It's the whole operating system, the whole computer, virtualized. If you have a 10 megabyte app you want to run, you may end up putting it in a 10 gigabyte virtual machine and carrying it around. That gives great security and isolation as your app is all alone on its own private VM, but it's a little overkill. Now you want to deploy 100 apps, and you've got space, CPU, and other things to think about. VMs also start slow and have to be actively maintained.
  • Docker/Linux Containers (and Windows containers "Docker for Windows Server"): Docker containers are sandboxes running on the same OS kernel. They are easy to deploy and start fast.  As a side effect of running on the same kernel, containers let you share most of that 10 gigabytes (as an example number) of support software between lots of apps, giving you less isolation but also using a LOT fewer resources. Containers start fast and the underlying shared resources are what's maintained and kept up to date.

Docker also is a way to package up an app and push it out in a reliable and reproducible way. So you can say that Docker is a technology, but also a philosophy and a process.

Docker will work on Windows and Linux

Docker and Visual Studio

Once you have the Docker for Visual Studio 2015 extension (preview) installed, go ahead and make an ASP.NET 5 app. Right click the project and hit Publish.

Publishing to Docker from Visual Studio

Note the Docker Containers section that's been added? You still have PAAS (Platform as a Service) and can also publish to VMs within Azure as well. Select Docker and you'll be here:

Selecting a Docker VM

We'll make a new VM to host our Docker stuff. This VM will have be the host for our containers. Today it'll be an Ubuntu LTS VM. Note that the dialog includes all the setup for Docker, ports, certs, etc. I could use existing VMs, of course.

Making a Docker VM

If you don't have a VM, then the initial create takes a while (5-10 min or more) so hang back. If you already have one, or the one you created is ready, then march on.

Visual Studio put in all our Docker details

Make special note of the Dockerfile option. You'll usually want to select your own manually created Dockerfile, assuming you're doing more than just a Hello World like I am.

The ASP.NET Dockerfile is up on GitHub: https://github.com/aspnet/aspnet-docker and in the Docker registry: https://registry.hub.docker.com/u/microsoft/aspnet/

In the build window you'll see lots of docker-related output. Here's a snipped version for flavor.

VERBOSE: Replacing tokens in Dockerfile: C:\Users\Scott\AppData\Local\Temp\PublishTemp\approot\src\WebApplication6\Properties\PublishProfiles\Dockerfile

VERBOSE: Package output path: C:\Users\Scott\AppData\Local\Temp\PublishTemp
VERBOSE: DockerHost: tcp://hanseldocker.cloudapp.net:2376
VERBOSE: DockerImageName: webapplication6
VERBOSE: DockerPublishHostPort: 80
VERBOSE: DockerPublishContainerPort: 80
VERBOSE: DockerAuthOptions: --tls
VERBOSE: DockerAppType: Web
VERBOSE: DockerBuildOnly: False
VERBOSE: DockerRemoveConflictingContainers: True
VERBOSE: LaunchSiteAfterPublish: True
VERBOSE: SiteUrlToLaunchAfterPublish:
VERBOSE: Querying for conflicting containers which has the same port mapped to the host...
Executing command [docker --tls -H tcp://hanseldocker.cloudapp.net:2376 ps -a | select-string -pattern ":80->" | foreach { Write-Output $_.ToString().split()[0] }]
VERBOSE: Building Docker image: webapplication6
Executing command [docker --tls -H tcp://hanseldocker.cloudapp.net:2376 build -t webapplication6 -f "C:\Users\Scott\AppData\Local\Temp\PublishTemp\approot\src\WebApplication6\Properties\PublishProfiles\Dockerfile" "C:\Users\Scott\AppData\Local\Temp\PublishTemp"]
VERBOSE: time="2015-05-27T10:59:06-07:00" level=warning msg="SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories."
VERBOSE: Sending build context to Docker daemon 28.01 MB
VERBOSE: Step 0 : FROM microsoft/aspnet:vs-1.0.0-beta4
VERBOSE: vs-1.0.0-beta4: Pulling from microsoft/aspnet
VERBOSE: e5c30fef7918: Pulling fs layer
VERBOSE: e5c30fef7918: Pull complete
VERBOSE: e5c30fef7918: Already exists
VERBOSE: Digest: sha256:27fbe2377b5d4e66c4aaf3c984ef03d22afbfee3d4e78e10ff38cac7ff162d2e
VERBOSE: Status: Downloaded newer image for microsoft/aspnet:vs-1.0.0-beta4
VERBOSE: ---> e5c30fef7918
VERBOSE: Step 1 : ADD . /app
VERBOSE: ---> cf1f788321b3
VERBOSE: Removing intermediate container dd345cdcc5d9
VERBOSE: Step 2 : WORKDIR /app/approot/src/WebApplication6
VERBOSE: ---> Running in f22027140233
VERBOSE: ---> 7eabc0da4645
VERBOSE: Removing intermediate container f22027140233
VERBOSE: Step 3 : ENTRYPOINT dnx . Kestrel --server.urls http://localhost:80
VERBOSE: ---> Running in 4810324d32a5
VERBOSE: ---> e0a7ad38eb34
VERBOSE: Removing intermediate container 4810324d32a5
VERBOSE: Successfully built e0a7ad38eb34
The Docker image "webapplication6" was created successfully.
VERBOSE: Starting Docker container: webapplication6
Executing command [docker --tls -H tcp://hanseldocker.cloudapp.net:2376 run -t -d -p 80:80 webapplication6]
Docker container started with ID: 6d4820044df200e87f08cb5becbec879d1b58fcab73145ca3aa99a424c162054
To see standard output from your application, open a command line window and execute the following command:
docker --tls -H tcp://hanseldocker.cloudapp.net:2376 logs --follow 6d4820044df200e87f08cb5becbec879d1b58fcab73145ca3aa99a424c162054
VERBOSE: received -1-byte response of content type text/html; charset=utf-8
Executing command [Start-Process -FilePath "http://hanseldocker.cloudapp.net/"]
Publish completed successfully.

The interesting parts are the calls to dnx (the .NET Execution host), the warning that I started on Windows and I'm going to Linux, as well as the fact that we're using the "microsoft/aspnet" docker image.

ASP.NET in a Linux Docker Container

In my example, I had VS and the extension make my certificates. If I want to connect to this instance from the Windows Docker command line, I need to either pass those certs in, or set an env var. Here I'm running "ps" to see the remote docker containers in this Azure Linux VM. The Docker client looks in %USERPROFILE%\.docker for certs., so you just need to set DOCKER_HOST or pass it in like this.

C:\>docker --tls -H=tcp://hanseldocker.cloudapp.net:2376 ps


CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d4820044df2 webapplication6:latest "dnx . Kestrel --ser 58 minutes ago Up 58 minutes 0.0.0.0:80->80/tcp silly_poincare

It worked great. Also be sure to explore the PublishProfiles folder that gets created in your Visual Studio project under "Properties." A PowerShell script and a Shell script get created in that folder that you can use to publish your app from the command line. For example:

.\hanseldocker-Docker-publish.ps1 -packOutput $env:USERPROFILE\AppData\Local\Temp\PublishTemp -pubxmlFile .\hanseldocker-Docker.pubxml

or from Linux:

cd ProjectFolder (like WebApplication/src/WebApplication)

source dnvm.sh
dnu restore --no-cache
mkdir ~/Temp
dnu publish . --out ~/Temp/ --wwwroot-out "wwwroot" --quiet
cd Properties/PublishProfiles
chmod +x ./Docker-publish.sh
./Docker-publish.sh ./Docker.pubxml ~/Temp/

I'm looking forward a cross-platform cross-tools choice-filled future. Finally, there's a great 7 part video series here called "Docker for .NET Developers" that you should check out on Channel 9.


Sponsor: Big thanks to Atalasoft for sponsoring the blog and feed this week! If your company works with documents, definitely check out Atalasoft's developer tools for web & mobile viewing, capture, and transformation. They've got free trials and a remarkable support team, too.



© 2015 Scott Hanselman. All rights reserved.
     

Totally stressed out? Sync to Paper

$
0
0
Messy Moleskine photo by Alexandre Dulaunoy and used under Creative Commons

One of the things I often talk about when I give presentations on Personal Productivity is that more people should Sync To Paper. I first had this idea in 2006 while working on a completely overwhelming project at my last job. I was already deeply into using OneNote, which was rather new at the time, so I was putting everything onto my laptop. I was convinced that my unorganized brain could "get organized" if I just wrote everything down in some cloud-based text file.

The problem is, at least for me, is that there isn't a great way to see the big picture when you've just got pixels to look at. Life is much higher resolution than I think folks realize. I'm frankly surprised that so many of you can feel organized and productive on those 11" laptops. What a tiny window into your life!

Anyway, when I was working on this huge project the database was extremely complex. Hundreds of tables and relationships to manage. It was far too much for anyone to keep in their heads or view on a screen. So they turned to the plotter. Remember those? The database team would print out massive posters and hang them on the wall. They'd stand together in front of them and stare and think.

You see syncing to paper a lot with user interface/user experience teams (UI/UX). We'll wallpaper entire hallways with mockups of what the system should look like, putting them in high traffic areas so everyone can absorb them and collaborate.

When my life is overwhelming and I am at PEAK STRESS, I do a three things.

  • I get a haircut, because at least I got that handled.
  • I clean my office, so I'm not reminded of the chaos of my life by the chaos of clutter around me.
  • And I sync to paper. I get a Moleskine notebook (Here's how to pronounce Moleskine, BTW) and I find a clear page and I write down what's stressing me out. I sync all my devices to paper. Calendars, Todos, thoughts, life, to paper.

The physicality of it is very satisfying in a visceral way. I've tried to do the same on a Surface or iPad with a stylus, but it doesn't work for me. The removal of technology and the scratch of a good quality pen on paper (I use a space pen) is very cathartic. Often I'm working on solving a technical problem so stepping away from tech is as important as the paper. It's a forced context switch. Even more, as a kinesthetic learner I feel like the moving of my hands differently, even if I never refer to the written notes again, the process helps cement the issues.

True Story: If you watch the Microsoft BUILD Keynote (a big deal, in tech circles) you'll see me come out for my 15 minute demo holding my Moleskine notebook. No one else does this. In fact, they tease me a little about my notebook. In fact, I'm usually given a 30 page typed script to memorize. It includes screenshots, talking points, gotchas, demo instructions, passwords, all the stuff I need for my demo. Folks work on these scripts for weeks and then deliver them to me. It's VERY stressful for everyone. We sit together for days and go over these huge documents and I freak out and panic and then get out my Moleskine and synthesize 30 pages into one. Here's what I took on stage with me for the BUILD 2015 keynote. Insane isn't it? But without it I would have freaked out. Now the stage crew knows me as "the guy with the notebook." And yes, I know my handwriting sucks and that this is an unintelligible pile. It still worked, and worked well. ;)

I have horrible handwriting

When I'm completely a mess OR I'm trying to get my head around a large problem, I'll cover the floor with paper, or find a wall or large whiteboard and try to work it out.

We focus on touchscreen and pinch gestures a lot these days, but for me "zoom out" means literally and figuratively taking a step back from a piece of paper and trying to absorb the big picture.

Paper is the cheapest retina display you'll ever use. Give it a try, at least until I can afford a Surface Hub for my office. ;)

Microsoft Surface Hub

Do you sync to paper? How does it work for you?

UPDATE: I was pointed to a post from Robert Greiner who promotes the same idea! Great minds think alike. I encourage you to also read his thoughts on the concept, as they are different from mine. He likes the temporary aspect of paper, and the pain of writing as ways to keep one focused.

Related Links

* Messy Moleskine photo by Alexandre Dulaunoy and used under Creative Commons



© 2015 Scott Hanselman. All rights reserved.
     

Router redirecting to unwanted Adobe Flash update malware site - Moon Virus?

$
0
0

1000wmainBear with me, for now this will be a tiny post, a placeholder, but I am looking for feedback, ideas, comments and I will keep this post updated.

The scenario: My local sandwich shop where I often hang out and work remotely has a wireless router that started to redirect me to a fake "update your flash" and download a "Install flashplayer_10924_i13445851_il345.exe" malware file. There are no viruses, rootkits, or malware on my PC. This affects their PoS (Point of Sale) system, tablets, iPhones. Also, it's not a DNS hijack, as the URL from the HTTP doesn't change. It's a MitM attack (Man in the Middle) where x number of HTTP GETs work fine and then every few hundred the router returns it's own HTML. The requestor doesn't know the difference.

The router he has is a V1000W Wireless N VDSL Modem Router. I'm suspecting the "Moon" virus but I'm not sure, as this isn't a Linksys. The firmware is ancient from 2009 and that's the latest one I can find.

Before you reply:

  • I'm technical, but the public is often not. Comments like "run openwrt" are certainly valid for a techie, but I'd like to know something more populist:
    • Can this router (and others like it) be fixed? Or is this bricked? Can I flash it with the original firmware to restore?
    • Remote management isn't enabled. What port did the attack happen on?
    • How can I confirm it has it (all signs point to it) with some curl command?
  • What routers have this? What is the source?
  • What can a regular Jane/Joe do about this if they have Frontier/FIOs/CenturyLink, etc?

Thoughts?



© 2015 Scott Hanselman. All rights reserved.
     

What's the deal with Windows 10 for the Non-Technical Friend

$
0
0

The calls are starting to come in, as I, like you, Dear Reader, am the head of IT Support for my friends and family. You'd think my cell phone was an IT helpline, and my email is filled with Word documents with pasted in screenshots along with subject lines like "Is this safe?!?!?"

Anyway, Window 10 is coming soon, and this little icon (the Windows icon) is stating to show up in folks' taskbars. For the techies, it's called GWX (Get Windows 10) and it's there to prep your machine and possible download Windows 10 if you want to reserve a spot. It's added by KB3035583.

image

If you click it, you'll get this screen where you can add your email and when July comes around your system will start downloading Windows 10 automatically.

You may also see this in Windows Update if you run Windows Update manually as I do.

Windows 10 is coming soon

You get to decide when you want to install it, it's not automatic.

Free Upgrade to Windows 10

The important part you and your non-technical friend should know and explore is the "Check your PC" section. Click the "hamburger" menu in the upper left corner, then click "Check your PC." Here's mine. Looks like I need to update or uninstall one program that isn't yet compatible, but my devices (video, usb stuff, etc) are cool.

Windows 10 will work on this PC

There's a great FAQ (Frequently Asked Questions) on Windows 10 here that you should check out.

Here's my personal translation/take on the most important parts:

  • Windows 10 upgrades start July 29th and you can choose to upgrade for free until July 29, 2016 so no rush. If you want wait and see, you can.
  • The upgrade is free for that period (July 29th 2015 until 2016, a year later). Upgrading after July 29th, 2016 will cost something.
  • You can upgrade machines running 7 and 8.1.
  • You machine should have these specs, which are pretty low and reasonable. Most anyone with a running PC can upgrade.
  • Yes, Solitaire and Minesweeper and Hearts will be removed BUT you can download the new versions of Solitaire and Minesweeper free in the Windows Store. They are pretty nice versions.
  • You'll move to either Windows 10 Home or Windows 10 Pro, according to this table:
    What Windows 10 version will I get?
  • You apps will keep running. I'm running all sorts of apps, many quite old, on Windows 10 and I have had no issue. The Compatibility Wizard still exists, though, so you can "lie" to really old apps and tell them they are running on Windows 95, or whatever. Just right-click the App that isn't working and click "Troubleshoot Compatibility," or right-click, Properties, then Compatibility. I haven't had to do this myself, yet, so consider this a rare thing.

So far it's been pretty interesting and I think that if non-technical friend liked Windows 7 and tolerated Windows 8 that they will like Windows 10. I've been doing "Windows 10 Build to Build" upgrade videos over at my YouTube and I would love it if you'd subscribe to my YouTube as well.

It's amazing that Windows 7 users and Windows 8 users will all be able to upgrade and come forward to a single version of Windows. As a developer (both web and apps) it'll be nice to have people on an "evergreen" Windows where I can do things like Feature Detection and not think as much about versioning.



© 2015 Scott Hanselman. All rights reserved.
     

How to enable HTTP Strict Transport Security (HSTS) in IIS7+

$
0
0

I got a report of a strange redirect loop on a website I (inherited, but help) manage. The reports were only from Chrome and Firefox users and just started suddenly last week, but the code on this site hadn't changed in at least 3 years, maybe longer.

Chrome shows an error "this webpage has a redirect loop"

What's going on here? Well, it's a redirect loop, LOL. But what KIND of redirects?

We know about these redirects, right?

  • 302 - Object Moved - Look over here at THIS URL!
  • 301 - Moved Permanently - NEVER COME HERE AGAIN. Go over to THIS URL!

A redirect loop builds up in the Chrome Developer Tools

But there's another kind of redirect.

  • 307 - Internal Redirect - Someone told me earlier to go over HERE so I'm going to go there without talking to the server. Imma redirect myself.

A 307 Internal Redirect

Note the reason for the 307! HSTS. What's that?

HSTS: Strict Transport Security

HSTS is a way to keep you from inadvertently switching AWAY from SSL once you've visited a site via HTTPS. For example, you'd hate to go to your bank via HTTPS, confirm that you're secure and go about your business only to notice that at some point you're on an insecure HTTP URL. How did THAT happen, you'd ask yourself.

But didn't we write a bunch of code back in the day to force HTTPS?

Sure, but this still required that we ask the server where to go at least once, over HTTP...and every subsequent time, user keeps going to an insecure page and then redirecting.

HSTS is a way of saying "seriously, stay on HTTPS for this amount of time (like weeks). If anyone says otherwise, do an Internal Redirect and be secure anyway."

Some websites and blogs say that to implement this in IIS7+ you should just add the CustomHeader require for HSTS like this in your web.config. This is NOT correct:

<system.webServer>

<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000"/>
</customHeaders>
</httpProtocol>
</system.webServer>

This isn't technically to spec. The problem here is that you're sending the header ALWAYS even when you're not under HTTPS.

The HSTS (RFC6797) spec says

An HTTP host declares itself an HSTS Host by issuing to UAs (User Agents) an HSTS Policy, which is represented by and conveyed via the

Strict-Transport-Security HTTP response header field over secure transport (e.g., TLS).

You shouldn't send Strict-Transport-Security over HTTP, just HTTPS. Send it when they can trust you.

Instead, redirect folks to a secure version of your canonical URL, then send Strict-Transport-Security. Here is a great answer on StackOverflow from Doug Wilson.

Note the first rule directs to a secure location from insecure one. The second one adds the HTTP header for Strict-Transport-Security. The only thing I might change would be to formally canonicalize the www. prefix versus a naked domain.

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security"
pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>

Note also that HTTP Strict Transport Security is coming to IE and Microsoft Edge as well, so it's an important piece of technology to understand.

What was happening with my old (inherited) website? Well, someone years ago wanted to make sure a specific endpoint/page on the site was served under HTTPS, so they wrote some code to do just that. No problem, right? Turns out they also added an else that effectively forced everyone to HTTP, rather than just using the current/inherited protocol.

This was a problem when Strict-Transport-Security was turned on at the root level for the entire domain. Now folks would show up on the site and get this interaction:

  • GET http://foo/web
  • 301 to http://foo/web/ (canonical ending slash)
  • 307 to https://foo/web/
  • 301 to http://foo/web (internal else that was dumb and legacy)
  • rinse, repeat

What's the lesson here? A configuration change that turned this feature on at the domain level of course affected all sub-directories and apps, including our legacy one. Our legacy app wasn't ready.

Be sure to implement HTTP Strict Transport Security (HSTS) on all your sites, but be sure to test and KNOW YOUR REDIRECTS.

Related Links



© 2015 Scott Hanselman. All rights reserved.
     

Software and Saving Babies

$
0
0

I used to have a saying to put things into perspecive when things were getting really crazy at work and we were freaking out over the Daily Crisis:

Breathe. It's just software, we're not saving babies here.

Now, to be clear, if you ARE saving babies or working on software that does, for crying out loud, don't breathe and make sure you've got unit tests!

Baby Squirrel by Flickr User Audreyjm529 used under CC

But for the majority of us, we're not saving babies. We're not writing Mars Rover code. We're making insurance systems, shopping carts, the next Facebook or Uber, or just doing CRUD. Perspective helps. Sometimes you just need to go for a walk, take a vacation, or well, quit. You've got your health, family, and little else.

His father asked Ethan in a raspy voice, "You spend time with your son?"

"Much as I can," he’d answered, but his father had caught the lie in his eyes.

"It’ll be your loss, Ethan. Day'll come, when he’s grown and it’s too late, that you'd give a kingdom to go back and spend a single hour with your son as a boy. To hold him. Read a book to him. Throw a ball with a person in whose eyes you can do no wrong. He doesn't see your failings yet. He looks at you with pure love and it won't last, so you revel in it while it's here."

Ethan thinks often of that conversation, mostly when he's lying awake in bed at night and everyone else is asleep, and his life screaming past at the speed of light—the weight of bills and the future and his prior failings and all these moments he's missing—all the lost joy—perched like a boulder on his chest.

- Pines (The Wayward Pines Trilogy, Book 1)

It's cliché, sure, but sometimes clichés need to be said more. Wisdom is the comb you get when you hair is gone, right?

There's a post on Hacker News today called "I quit the tech industry" that you should read. The TL;DR is that working in software for money just wasn't working for this person. It wasn't feeding their spirit, so now they're going to try to make something else work. What a challenging decision it must have been, but at the same time, if something isn't working, why keep doing it? Perhaps it's burnout, but perhaps it's something else. More power to this person for taking care of themselves, and I wish them all the best.

How do you avoid burnout? How do you stay passionate? Sound off in the comments.

* Baby Squirrel by Flickr User Audreyjm529 used under CC



© 2015 Scott Hanselman. All rights reserved.
     

Visual Studio Web Development Tip - Add Chrome Incognito Mode as a Browser

$
0
0

Here's a little Visual Studio web development tip that I've been using lately. You know how Visual Studio picks up your installed browsers and has them available as a dropdown list?

List of Browsers in Visual Studio

I found it very useful when debugging to add Google Chrome's Incognito Mode as a browser of its own.

Pull down the chevron and click Browse With...

Browse With Menu

Add Chrome from either it's standard or user location:

  • System: C:\Program Files (x86)\Google\Chrome\Application\
  • User: C:\Users\UserName\AppData\Local\Google\Chrome\Application

Then add --incognito as command line switch and name the browser something like "Google Chrome - Incognito."

You can do the same thing with Firefox and Internet Explorer.

Here I'm adding Internet Explorer with the -private option.

Internet Explorer Private mode

This is a useful thing for developers if you're doing anything with cookies or caching and you've found yourself clearing the cache or browser history a lot.

Added Internet Explorer Private Mode to Visual Studio

Question for you dear Reader - Is this a feature you would want by default? Would you want not just every browser added, but also the Private Mode for each as well?



© 2015 Scott Hanselman. All rights reserved.
     

Historical Debugging, Profiling, New Diagnostic Tools in Visual Studio 2015

$
0
0

The full range of .NET 2.0 through 4.6 in Visual Studio 2015I've been working with Visual Studio 2015 lately, even for older projects. You can create and edit all kids of .NET app from .NET 2.0 all the way up through .NET 4.6, as well as ASP.NET 5 apps on the Core CLR.

In my case I've been doing some pair programming with Mark Downie on DasBlog, the blog system that runs this blog right here. DasBlog is very old, and used to be very actively developed. The question "is DasBlog dead" is asked a lot, but the answer is really "DasBlog is done." For years it has been very feature-full and feature-complete. However, this blog has been running on .NET 2.0 for years. Mark and I thought it would be nice to upgrade DasBlog to .NET 4.6, so we did. We've also moved DasBlog over to GitHub. You'll find it at http://github.com/shanselman/dasblog.

Now, to be clear, DasBlog was amazing in 2004 and 2008 but it's aging now. Mark and I think that's the fun of it, though. Mark's added Twitter Card and Facebook Open Graph support, and together we've fixed a few oddities and bugs that have popped up in the leap from 2.0 to 4.6. However DasBlog remains idiomatic .NET 2.0 which means it's C# 2.0, and doesn't even make good use of Linq or generics. We're thinking about a few updates, moving the Templating system to RazorEngine, updating to Linq queries, smarter threading for collections, better caching, as well of Mark's ideas around social.

You might think it's weird to use Visual Studio 2015 to work with a .NET 2.0 app, but it's useful to remember that you get to use new Visual Studio features even with older frameworks. One of the most useful new features is the Diagnostic Tools toolbox. It's a boring name for an amazing new part of VS. I'm not sure what they could call it other than Diagnostic Tools, but it's insanely convenient.

Diagnostics Tools in Visual Studio 2015

Often we think of Debugging and Profiling as two separate activities, and honestly, I talk to developers all the time that have never Profiled an app. They know that Profiling exists as a tool and a concept, but for whatever reason they forget about it, don't get around to it, or haven't adopted it as a fundamental part of their daily workflow.

The Diagnostic Tools in Visual Studio 2015 bring in data from a number of sources, Breakpoints, the Debugger, Tracing and Debug out, as well as Intellitrace Events and Historical Debugging (on supported SKUs).

Notice in the screenshot above, I can even see a little tip showing how many milliseconds has elapsed between two breakpoints. It's little features like this that take data that has long been available but not in front of your face. Why dig for it?

You can see how many milliseconds between calls

I can even go back in time with Historical Debugging. See how I can backup and see the state of Local Variables and the Call Stack when I'm at a Breakpoint?

Historical Debugging

If you have a SKU with IntelliTrace, you can get extra info if you'd like to enable Historical Debugging.

IntelliTrace

See how I've got Memory and CPU graphs, and I didn't have to do anything? This pops up automatically when Debugging:

Diagnostic Tools gives you all these lovely charts

I can take Memory Snapshots, go to the next Breakpoint, take another and compare!

Memory Snapshots

If you've got Visual Studio 2015 and haven't started using these tools, I'd suggest you start exploring. They're useful enough that they've got me using VS2015 RC for all my projects, even older .NET 2.0 ones.

NOTE: Remember that Visual Studio Community is free for Open Source projects, and supports extensions! http://www.visualstudio.com/free



© 2015 Scott Hanselman. All rights reserved.
     

How to use Process Monitor and Process Explorer

$
0
0

I was chatting with Phil Haack today about a weird little bug/feature we were seeing in GitHub for Windows. I don't have the source code for the application, but I wanted to explore what was going on and get some insight so I could give Phil a decent bug report.

He and I spent some time on Skype sharing screens today and he commented "we should be recording this." So I went back and did just that.

Please take a moment and Subscribe to my YouTube Channel here: http://youtube.com/shanselman

In this short video I remind folks how Procmon and ProcExp work, how powerful they are and I learn some interesting things about GitHub for Windows!

Let me know if you find short videos like these useful, and if you do, suggest topics in the comments!

Also, a reminder, if you've got non-technical family or friends who want help with Windows 8, give them a YouTube Playlist designed just for them! http://hanselman.com/windows8



© 2015 Scott Hanselman. All rights reserved.
     

Lenovo Yoga 2 Pro Micro-HDMI not working? Easy fix.

$
0
0

Micro HDMI sucks.This blog post is likely not for you, unless it totally is. Which is why I'm posting it.

My Dad's Lenovo Yoga 2 Pro was driving him batty for months. It was bugging me even more, as I am the assigned IT manager for my family. I'm sure you are also, as you're reading this blog, right?

Anyway, I talk this computer up for months, he gets the computer, and it has this tiny Micro-HDMI connector.

Let me just say that Micro-HDMI is the most evil of all display connectors. I mean, it literally does everything wrong.

Micro-HDMI sucks because:

  • Micro-HDMI looks like Micro USB and I can't explain to my Dad that they are different.
  • Micro-HDMI is the most fragile of all ports. If you blow on it you'll lose signal.
  • It's like the tiny shorty soda pop can of Tab. It's not Diet Coke. It's not enough. It's useless.

Which brings me to the point. His didn't work. Never worked. I tried new drivers, flashing BIOS, new cables, jiggling the connector, everything.

Except the obvious - cutting up the cable.

It turns out that many cables (especially cheap ones from Amazon) don't expose enough metal to make a decent connection.

Take a razor blade and cut a good millimeter around the cable's rubber housing to expose more metal.

Yep, I cut the cableCut around the cable. Remove 1mm or so.

Boom. It works immediately. Dad's thrilled. I'm a good son again and Micro-HDMI continues to suck as a display connector.

Full-sized HDMI or Mini-DP (Display Port) from now on, my friends.

Please, regale me in the comments with tales of why YOU too hate Micro-HDMI, Dear Reader.



© 2015 Scott Hanselman. All rights reserved.
     

Windows 10 is coming...here's what to tell non-technical parent

$
0
0

Windows 10 is coming on July 29th! I've been doing Build to Build videos on my YouTube showing what's changing and how it will affect you.

I got a request to do a video showing Windows 7, Windows 8, and Windows 10 and how to reserve your upgrade, as well as a little demo of the Start Screen. Here's that video!

NOTE: I apologize for the mediocre audio. I had a microphone failure and ended up using the laptop microphone for the last part because I was excited to get the video out. It's not representative of the quality I'm known for, and it won't happen again.

Are you the IT manager for your extended family? Will you be upgrading non-technical parent to Windows 10 or letting them do it themselves? Sound off in the comments below.



© 2015 Scott Hanselman. All rights reserved.
     

VS Refactoring Essentials (formerly) NR6Pack - Free analyzers and refactoring for Visual Studio 2015

$
0
0

There are some amazing free and open source C# and VB.NET analyzers and refactorings that you can download and use now in Visual Studio 2015. Formerly called "NR6Pack" they have now be renamed VS Refactoring Essentials, a nice nod to VSWebEssentials I must say.

The best part, of course, is that since the Visual Studio Community Edition is not only FREE but also now supports extensions, that any open source or indie developer can get pack some serious power into their Visual Studio installations.

There's some interesting history here as the project and its core technology has been around for a while. It's moved from SharpDevelop into NRefactory, then NRPack, and now with the major Roslyn refactor by Mike Krüger, you've got a nice Roslyn code-base and a free extension for all called VS Refactoring Essentials.

There's lots of great refactorings, too many to include screenshots for all of them, but here's a few favorites.

Sometimes you'll dig deep into a dictionary without being defensive. VS Refactoring Essentials will notice and check the dictionary key first. Note that you'll always get a preview of what it's going to change first!

CheckDictionaryKeyValueCodeRefactoring

Conditionals can sometimes get away from you. VS Refactoring Essentials will simplify common conditionals and make them easier to read.

SimplifyConditionalTernaryExpressionAnalyzer

When setting boolean flags you'll sometimes set it, check something, and update that same flag. This refactoring will notice that and do it all on one line for you.

ConvertIfToOrExpressionAnalyzer

I never get ?: and ?? correct. VS Refactoring Essentials will help you move between ternary operators and null coalescing.

ConvertConditionalTernaryToNullCoalescingAnalyzer

FYI - This is a purely open source project that is not affiliated with Microsoft. It's part of the SharpDevelop OSS project and is MIT-licensed. Big thanks to the SharpDevelop team!

NOTE: Visual Studio 2015 will launch on July 20th. Be sure to download Visual Studio 2015 Community on that date. Until then, the V2015RC of Community is here.

Be sure to follow @VSRefactoring on twitter and thanks for them for their hard work and community focus! Go download Refactoring Essentials here for VS2015. Report issues on their GitHub.



© 2015 Scott Hanselman. All rights reserved.
     

Introducing Web Tiles for Microsoft Band - My diabetes data on a Band!

$
0
0

Microsoft Bands in various colorsI love wearables. Check out my blog post from 11 years ago on my "Wrist.NET" Microsoft SPOT watch. This was a time before ubiquitous connectivity and it was an amazing device that provided tons of glanceable information.

Fast-forward to today and I've used a Fitbit, an Apple Watch, a few Pebble Watches, and a Microsoft Band. The thing that I wanted in 2004 - and the thing I want today - has always been an easy way to make an application for my wearable device. When the Microsoft Band (If you get one, print out this Sizing PDF first and measure your wrist) came out I immediately wanted to know what the SDK looked like! How easily could I make a new Tile on my Band?

Well, while the Band SDK is super powerful, just like the Apple Watch and most wearables, if I wanted to make a Band Tile I needed to make a mobile app first! That was a bummer for me. If I want to make a new simple Tile and share it with my friends I first need to make an app, and to have full coverage, I'll need three versions of the app (iPhone, Windows Phone, Android) as well?

The Band isn't a watch, and it's not just a pedometer. The Microsoft Band has ten sensors: an optical heart rate sensor, 3-axis accelerometer, gyrometer, GPS, light sensor, skin temp sensor, UV sensor, capacitive sensor, a microphone and one for skin response. I wanted a way to easily connect it to anything else I could think of. Lights, my glucose meter, my Nest, and on and on.

I went to the Band team and started pitching them an idea I called Web Tiles. Since every Band user already has the Microsoft Band (Health) app, why not let the existing app be a bridge and it would own new custom tiles! Web Tiles for glanceable data with a low barrier to entry, and the full Band SDK for rich interactivity. I figured we could write new Tiles with web tech. My personal use case was that I wanted a Web Tile to show my blood sugar from Nightscout, an open source app I use to manage my diabetes. Fortunately the Band Team were like-minded and we collaborated. Eventually they really started running and Web Tiles was born. You may have noticed that we gently introduced Web Tiles at the BUILD conference using my sugar data in the demo.

Web Tiles for Microsoft Band

Today the first preview version of Web Tiles is ready to go. You can make a custom Web Tile in just minutes for your Microsoft Band and install it now. You can put it on your OneDrive or blog, or even just email it to a friend.

If you're slightly technical, you can create Web Tiles with just the documentation, Notepad (or the VS Code editor) and a Zip utility. For the rest of us, you can use the online Web Tile Authoring Tool and it will generate the tile and give it to you for download.

Web Tiles are glanceable tiles that are feed by JSON, XML, or ATOM datasources. If you want to make one, feel free to use my Blood Sugar JSON datasource: http://hanselmanbanddata.azurewebsites.net and the Web Tile Authoring Tool.

The Web Tile Authoring Tool

Web Tile Authoring Tool

Otherwise, here's a little more detail. Be sure to check out the Band team's blog posts and web site!

More Technical Stuff

There is a new runtime inside the Microsoft Health app for iOS, Windows Phone, and Android to manage Web Tiles and keep them fresh. Web Tiles are a zip file with a manifest with image files and JSON inside. You can put Web Tiles anywhere on the web or in email attachments. They have a .webtile extension, but you can use the mshealth-webtile:// custom URL scheme to launch the app and download a webtile, like mshealth-webtile://?action=download-manifest&url=http://www.microsoft.com/mywebtile.webtile

A minimal Web Tile would look like this:

  • mytile.webtile (it's a renamed zip, and paths matter!)
    • /manifest.json // Contains web tile definition and references to other assets
    • /icons/*.png // PNG icons used in the web tile

Tiles can have multiple pages, in a master/detail style, binding to the data however you'd like.

image

Small Nightscout LogoTo make a Web Tile that shows my blood sugar from my Nightscout site, I created this 46x46 PNG of the Nightscout logo and pulled from the JSON feed that represents my own glucose values http://hanselmanbanddata.azurewebsites.net.

The JSON for my Diabetes Web Tile is here, as an example. You'll also find it in the How-To documentation for Web Tiles. The first part is obvious, just a manifest. Then the Tile Icon. I just have one. Then we have a single Tile with a Simple style and three lines. The format you see there "bgs[0].sgv" is a way of pulling from the JSON. Like foo.bar.baz[0] if the JSON were nested named objects. The resources are named, and then later bound in strings within pages.

You could create a Web Tile for anything you have that has a JSON endpoint. I'm going to make a Web Tile to monitor my 3D Printer using Octoprint's REST API for example.

{

"manifestVersion": 1,
"name": "Nightscout",
"description": "Nightscout Blood Sugar",
"version": 1,
"versionString": "1",
"author": "Scott Hanselman",
"organization": "Nightscout",
"contactEmail": "",
"tileIcon": {
"46": "icons/tileIcon.png"
},
"refreshIntervalMinutes": 15,
"resources": [
{
"url": "http://hanselmanbanddata.azurewebsites.net/api/Band",
"style": "Simple",
"content": {
"bgs0sgv": "bgs[0].sgv",
"bgs0bgdelta": "bgs[0].bgdelta",
"bgs0direction": "bgs[0].direction"
}
}
],
"pages": [
{
"layout": "MSBand_NoScrollingText",
"condition": "true",
"textBindings": [
{
"elementId": "1",
"value": "Sugar: {{bgs0sgv}}"
},
{
"elementId": "2",
"value": "Delta: {{bgs0bgdelta}}"
},
{
"elementId": "3",
"value": "Trend: {{bgs0direction}}"
}
]
}
]
}

I mail the Web Tile to myself and see this on my iPhone. (Again, it could be in Dropbox, OneDrive, etc)

Emailing a WebTile to myself

Now I "Open in Microsoft Health..."

Adding a Web Tile to my Band

Click Save...

Now I have 2 web tiles in my band

And I've got two new custom Web Tiles now!

IMG_2465

And here's my Band with my Web Tile installed! (Yes, at this moment in time my sugar is a little high, but I'm on it.)

In the future I'd like to see events, buttons, triggers, push notifications, inline images, charts/sparklines, and more. What do you want to use Web Ties for? Is this cool?

I'm sure the team is interested in the direction you'd like to see Web Tiles go. Interactions? Events? Real-time? More sensor support? Authentication? Sound off in the comments, vote on the Microsoft Band and Health UserVoice page and absolutely email them directly at healthms@microsoft.com.

DONATE: If you appreciate this blog and what I'm doing here, please donate to fight diabetes. Read about my story at http://hanselman.com/fightdiabetes, watch my Diabetes YouTube video, and make a tax-deductable domation here http://hanselman.com/fightdiabetes/donate



© 2015 Scott Hanselman. All rights reserved.
     
Viewing all 1148 articles
Browse latest View live