Scott Hanselman

Refresh Your PC in Windows, AppData, and my missing Minecraft worlds

January 08, 2015 Comment on this post [32] Posted in Win8
Sponsored By

I thought I lost everything today. Well, not really, I have a very regular Backup Strategy (stop reading this blog post NOW and back your stuff up!) so I could get stuff back if I really needed to.

But a laptop died today. It just wouldn't start up and I had to run "Refresh my PC," a very cool feature of Windows that basically mostly reinstalls Windows without reinstalling. It promises not to lose your files. And it's (99%) true, because when I got Windows back up later my Documents and Desktop were just as I left them, untouched by the this major operation.

Refresh your PC - Windows 8.1

Fortunately I used Boxstarter, Chocolately, and a list of the programs I have installed as a Gist and was able to get my Windows machine with all my desktop programs back up and running in a few hours. All my files were backed up to the cloud and every file was where I left it.

Except the most important ones. ;)

I launched Minecraft, and saw this. And almost died.

My minecraft worlds are missing!

Where's my Minecraft save games/worlds?

I thought Windows promised to not change my files!? Well, sadly Minecraft doesn't save worlds in "My Documents\Minecraft," where it should. It puts them instead in c:\Users\YOURNAME\AppData\Roaming\.minecraft\saves which is basically like a temp folder of sorts for config data.

Fortunately after my initial freak out, even these files aren't lost, they are in C:\Windows.old\users\YOURNAME\AppData\Roaming\.minecraft\saves along with all your other AppData stuff including the npm-cache, .emacs.d, and other config data you might want.

Move them back, and you're (I'm) all set!

To the (Minecraft) Cloud!

Whew.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Getting Started with Robots for kids and children in STEM this holiday season

December 26, 2014 Comment on this post [26] Posted in Parenting
Sponsored By

Now's the perfect time to buy your kids/nieces/cousins some robots. Robots are a great way to get children excited about computers. Robots get them stoked in a way that a simple Hello World console app just can't.

If you're not careful you can spent hundreds on robots. However, I'm notoriously frugal and I believe that you can build some amazing stuff with children with a reasonable budget.

Here's some of the robot and electronics kits I recommend and have built with my kids.

4M Tin Can Robot

This is just a teaser but it's less than a trip to the movies. This silly little kit takes 2 AAA batteries and will take an aluminum can and animate it. It gets kids thinking about using found objects in their robots, as opposed to them thinking custom equipment is always required.

tincan

Quadru-Bot 14-in-1 Solar Robot

One of the challenges is "what age should I start?" and "how complex of a robot can my __ year old handle?" Kits like this are nice because they are starting with batteries and gears and include two levels of building, basic and experienced. It's also a nice kit because it includes solar power as an option and also can work in water (the bath).

713-IOSBdAL._SL1500_

OWI Robotic Arm Edge

This isn't a kit but it's a reasonably priced robotic arm to get kids thinking in terms of command and control and multiple dimensions. OWI also has a cool 3in1 robot RC kit if you prefer driving robots around and more "rebuildability."

51LAkVypvAL

Mirobot

This Christmas my 7 year old and I built a Mirobot. You can get pre-soldered and solder-yourself kits. We got the main Mirobot Kit PLUS the Addons Kit which includes clever additional modules for Line Following, Sound, and Collision Detection.

The whole Mirobot execution is brilliant. The hardware and software are all open source, so if you want to acquire the parts and make it yourself you can. You can get kits in various levels of preassembly.

It's built on an Arduino but is preloaded with some very clever software that takes advantage of its onboard Wifi. You can program it in C with Arduino tools, of course, but for kids, they can use JavaScript and an in-browser editor, much like Logo. It will create its own ad-hoc wifi network by default, or you can join it to your home network.

image

The creator is also building an Apps Platform so you can control the Mirobot from other apps within your browser and websocket your way over to the robot.

It took us about a weekend to build and you can see in the pic below that my 7 year old was able to install a pen and get the bot to draw a stickman. He was THRILLED.

10838706_883990588298288_1242836197_n

Edison

This isn't the Intel Edison, although you can make some great robots with it as well. No, this is Edison, a little LEGO compatible robot from the makers of Microbric, a great robot platform from a few years ago. I actually made a Microbric robot in 2007 and blogged about it.

Edison is fantastic and just $50. If you're a teacher and can get a multiples pack, you can get them as cheap as $35 each. You program Edison with a clean drag and drop icon system then download the program to your robot with a cable from your computer's headphone jack.

Out of the box you can have it follow a flashlight/torch, follow lines on paper, fight each other in a sumo ring, avoid walls, and lots more. In this picture there's two Edison's stacked on each other. The top one has the wheels removed and replaced with Lego elements to make robot arms.

image

LEGO Mindstorms

OK, yes, LEGO Mindstorms are $350, so that's not exactly frugal. BUT, I've seen parents buy $500 iPads without a thought, why not consider a more tactile and engineering-focused gift for a girl or boy?

This is THE flagship. It's got Wifi, Bluetooth, color sensors, iPad apps, collision detection, motors galore and unlimited replayability. There's also a huge online community dedicated to taking Mindstorms to the next level. If you can swing it, it's worth the money and appropriate for anyone from 6 to 60.

81Hn0H3SyAL._SL1500_

Snap Circuits

I couldn't love Snap Circuits more. I started with the Jr. Snap Circuits and we eventually graduated to Snap Circuits Pro. They are my #1 go-to gift idea for kids of friends and relatives.

While this isn't a robotics kit, per se, it really builds the basic understanding of batteries, electronics, and motors that kids will need to move to the next level.

91lfaA93v0L._SL1500_

What robot kids do YOU recommend?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

The real and complete story - Does Windows defragment your SSD?

December 04, 2014 Comment on this post [69] Posted in Win7 | Win8
Sponsored By

There has been a LOT of confusion around Windows, SSDs (hard drives), and whether or not they are getting automatically defragmented by automatic maintenance tasks in Windows.

There's a general rule of thumb or statement that "defragging an SSD is always a bad idea." I think we can agree we've all heard this before. We've all been told that SSDs don't last forever and when they die, they just poof and die. SSDs can only handle a finite number of writes before things start going bad. This is of course true of regular spinning rust hard drives, but the conventional wisdom around SSDs is to avoid writes that are perceived as unnecessary.

Does Windows really defrag your SSD?

I've seen statements around the web like this:

I just noticed that the defragsvc is hammering the internal disk on my machine.  To my understanding defrag provides no value add on an SSD and so is disabled by default when the installer determines the disk is SSD.  I was thinking it could be TRIM working, but I thought that was internal to the SSD and so the OS wouldn’t even see the IO.

One of the most popular blog posts on the topic of defrag and SSDs under Windows is by Vadim Sterkin. Vadim's analysis has a lot going on. He can see that defrag is doing something, but it's not clear why, how, or for how long. What's the real story? Something is clearly running, but what is it doing and why?

I made some inquiries internally, got what I thought was a definitive answer and waded in with a comment. However, my comment, while declarative, was wrong.

Windows doesn’t defrag SSDs. Full stop. If it reports as an SSD it doesn’t get defraged, no matter what. This is just a no-op message. There’s no bug here, sorry. - Me in the Past

I dug deeper and talked to developers on the Windows storage team and this post is written in conjunction with them to answer the question, once and for all

"What's the deal with SSDs, Windows and Defrag, and more importantly, is Windows doing the RIGHT THING?"

It turns out that the answer is more nuanced than just yes or no, as is common with technical questions.

The short answer is, yes, Windows does sometimes defragment SSDs, yes, it's important to intelligently and appropriately defrag SSDs, and yes, Windows is smart about how it treats your SSD.

The long answer is this.

Actually Scott and Vadim are both wrong. Storage Optimizer will defrag an SSD once a month if volume snapshots are enabled. This is by design and necessary due to slow volsnap copy on write performance on fragmented SSD volumes. It’s also somewhat of a misconception that fragmentation is not a problem on SSDs. If an SSD gets too fragmented you can hit maximum file fragmentation (when the metadata can’t represent any more file fragments) which will result in errors when you try to write/extend a file. Furthermore, more file fragments means more metadata to process while reading/writing a file, which can lead to slower performance.

As far as Retrim is concerned, this command should run on the schedule specified in the dfrgui UI. Retrim is necessary because of the way TRIM is processed in the file systems. Due to the varying performance of hardware responding to TRIM, TRIM is processed asynchronously by the file system. When a file is deleted or space is otherwise freed, the file system queues the trim request to be processed. To limit the peek resource usage this queue may only grow to a maximum number of trim requests. If the queue is of max size, incoming TRIM requests may be dropped. This is okay because we will periodically come through and do a Retrim with Storage Optimizer. The Retrim is done at a granularity that should avoid hitting the maximum TRIM request queue size where TRIMs are dropped.

Wow, that's awesome and dense. Let's tease it apart a little.

When he says volume snapshots or "volsnap" he means the Volume Shadow Copy system in Windows. This is used and enabled by Windows System Restore when it takes a snapshot of your system and saves it so you can rollback to a previous system state. I used this just yesterday when I install a bad driver. A bit of advanced info here - Defrag will only run on your SSD if volsnap is turned on, and volsnap is turned on by System Restore as one needs the other. You could turn off System Restore if you want, but that turns off a pretty important safety net for Windows.

One developer added this comment, which I think is right on.

I think the major misconception is that most people have a very outdated model of disk\file layout, and how SSDs work.

First, yes, your SSD will get intelligently defragmented once a month. Fragmentation, while less of a performance problem on SSDs vs traditional hard drives is still a problem. SSDS *do* get fragmented.

It's also worth pointing out that what we (old-timers) think about as "defrag.exe" as a UI is really "optimize your storage" now. It was defrag in the past and now it's a larger disk health automated system.

Used under CC. Photo by Simon WüllhorstAdditionally, there is a maximum level of fragmentation that the file system can handle. Fragmentation has long been considered as primarily a performance issue with traditional hard drives. When a disk gets fragmented, a singular file can exist in pieces in different locations on a physical drive. That physical drive then needs to seek around collecting pieces of the file and that takes extra time.

This kind of fragmentation still happens on SSDs, even though their performance characteristics are very different. The file systems metadata keeps track of fragments and can only keep track of so many. Defragmentation in cases like this is not only useful, but absolutely needed.

SSDs also have the concept of TRIM. While TRIM (retrim) is a separate concept from fragmentation, it is still handled by the Windows Storage Optimizer subsystem and the schedule is managed by the same UI from the User's perspective. TRIM is a way for SSDs to mark data blocks as being not in use. Writing to empty blocks on an SSD is faster that writing to blocks in use as those need to be erased before writing to them again. SSDs internally work very differently from traditional hard drives and don't usually know what sectors are in use and what is free space. Deleting something means marking it as not in use. TRIM lets the operating system notify the SSD that a page is no longer in use and this hint gives the SSD more information which results in fewer writes, and theoretically longer operating life. 

In the old days, you would sometimes be told by power users to run this at the command line to see if TRIM was enabled for your SSD. A zero result indicates it is.

fsutil behavior query DisableDeleteNotify

However, this stuff is handled by Windows today in 2014, and you can trust that it's "doing the right thing." Windows 7, along with 8 and 8.1 come with appropriate and intelligent defaults and you don't need to change them for optimal disk performance. This is also true with Server SKUs like Windows Server 2008R2 and later.

Conclusion

No, Windows is not foolishly or blindly running a defrag on your SSD every night, and no, Windows defrag isn't shortening the life of your SSD unnecessarily. Modern SSDs don't work the same way that we are used to with traditional hard drives.

Yes, your SSD's file system sometimes needs a kind of defragmentation and that's handled by Windows, monthly by default, when appropriate. The intent is to maximize performance and a long life. If you disable defragmentation completely, you are taking a risk that your filesystem metadata could reach maximum fragmentation and get you potentially in trouble.

Related Links

* photo by Simon Wüllhorst, used under CC BY 2.0.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Getting ready for the future with the Microsoft .NET Portability Analyzer

December 03, 2014 Comment on this post [10] Posted in Learning .NET
Sponsored By

.NET has been getting more and more portable. Not only is .NET Open Source going forward (read Announcing .NET 2015 - .NET as Open Source, .NET on Mac and Linux, and Visual Studio Community) but you of course know about Xamarin tools, as well as, I hope, the .NET Microframework, and much more.

You can run your .NET code all over, and there's a tool to make this even easier. While you'll rarely get 100% portable code with any platform, you can get into the magic 90-95% with smart refactoring, then keep the platform-specific shims pluggable.

The .NET Portability Analyzer is a free Visual Studio Add-in (or console app) that will give you a detailed report on how portable your code is. Then you can get a real sense of how far you can take your code, as well as how prepared you'll be for the Core CLR and alternate platforms.

.NET Portability

Take a look at this report on AutoFac, for example. You can see that the main assembly is in fantastic shape across most platforms. Understandably the more platform-specific Configuration assembly fares worse, but still there's a complete list of what methods are available on what platforms, and a clear way forward.

.NET Portability Report

You'll get suggestions with a direction to head when you bump up against a missing or not-recommended API.

img2

You can analyze specific assemblies, or an entire project. Once installed, you'll find the commands under the Analyze menu, and you can change options in the .NET Portability Analyzer options in the Tools | Options menu.

Even better, you can use this with the FREE Visual Studio Community that you can download at http://www.visualstudio.com/free.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

OmniSharp - Making cross-platform .NET a reality, and a pleasure

November 27, 2014 Comment on this post [58] Posted in ASP.NET | Open Source
Sponsored By

In case you missed it, make sure to read Announcing .NET 2015 - .NET as Open Source, .NET on Mac and Linux, and Visual Studio Community because there's been some big stuff going on.

Here's the summary of the .NET 2015 Wave of awesomeness.

The other thing I wanted to talk about is a newly organized group of technologies called OmniSharp. Just to be sure there's no confusion, OmniSharp isn't a Microsoft project. While there are two Microsoft folks on the team of 8 or so, we are working on it as community members, not in an official capacity.

I "launched" this project in my talk at the Connect() mini-conference in New York a few weeks back. You can watch that video here on Channel 9 now if you like. However, the technologies around and under OmniSharp have been around for years...like over a decade!

As a team and a community we pulled together a bunch of projects and plugins, got organized, and created https://github.com/omnisharp and http://www.omnisharp.net. Jonathan Channon has a great overview blog post you should check out that talks about how Jason Imison created OmniSharpServer which is an...

HTTP wrapper around NRefactory allowing C# editor plugins to be written in any language. NRefactory is the C# analysis library used in the SharpDevelop and MonoDevelop IDEs. It allows applications to easily analyze both syntax and semantics of C# programs. It is quite similar to Microsoft's Roslyn project; except that it is not a full compiler – NRefactory only analyzes C# code, it does not generate IL code.

OmniSharp runs as its own process and runs a local Nancy-based web api that your editor of choice talks to. If you have an editor that you like to use, why not get involved and make a plugin? Perhaps for Eclipse?

We now have plugins for these editors:

  • Sublime
  • Brackets from Adobe
  • Atom from GitHub
  • Emacs
  • Vim

And these work on (so far) all platforms! It's about choice. We wanted to bring more than autocomplete (which is basically "I think you typed that before") to your editor, instead we want actual type-smart intellisense, as well as more sophisticated features like refactoring, format document, and lots of other stuff you'd expect only to see in Visual Studio.

We also brought in the Sublime Kulture package which gives Sublime users support for ASP.NET 5 (formerly ASP.NET vNext), so they can launch Kestrel (our libuv based local webserver), run Entity Framework migrations, and other arbitrary commands from within Sublime.

.NET in Sublime, in Vim, in Brackets, in Atom, and everywhere else, cross-platform

Here's OmniSharp running in emacs on my Windows machine. The emacs setup (here is an example) is a little more complex than the others, but it also gives emacs folks an extreme level of control. Note that I had to launch the OmniSharp server manually for emacs, while it launches automatically for the other editors.

image

Here is an ASP.NET MVC app running in Sublime. The Sublime OmniSharp package output can be seen in the debug console there (Ctrl+~ to see it).

image

OmniSharp is in very active development. We are looking at bringing in Roslyn, using the new ASP.NET Design Time Host, and improving robustness. It's not perfect, but it's pretty darn cool. There's lots of details in Jonathan's writeup with great animated gifs showing features. Also note that we have a Yeoman generator for ASP.NET that can get you started when creating ASP.NET 5 apps on Mac or Linux. The yeoman generator can create Console apps, MVC apps, and NancyFx apps.

You can get started at http://omnisharp.net.  See you there!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.