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

Exploring the new .NET "dotnet" Command Line Interface (CLI)

$
0
0

I've never much like the whole "dnvm" and "dnu" and "dnx" command line stuff in the new ASP.NET 5 beta bits. There's reasons for each to exist and they were and they have been important steps, both organizationally and as aids to the learning process.

My thinking has always been that when a new person sits down to learn node, python, ruby, golang, whatever, for the most part their experience is something like this. It should be just as easy - or easier - to use .NET.

This is just a psuedocode. Don't sweat it too much.

apt-get install mylang #where mylang is some language/runtime

#write or generate a foo.fb hello world program
mylang foo #compiles and runs foo

I think folks using and learning .NET should have the same experience as with Go or Ruby.

  • Easy To Get - Getting .NET should be super easy on every platform.
    • We are starting to do this with http://get.asp.net and we'll have the same for .NET Core alone, I'm sure.
  • Easy Hello World - It should be easy to create a basic app and build from there.
    • You can "dotnet new" and get hello world. Perhaps more someday?
  • Easy Compile and Run
    • Just "dotnet run" and it compiles AND executes
  • Real .NET
    • Fast, scalable, native speed when possible, reliable

I've been exploring the (very early but promising) work at https://github.com/dotnet/cli that will ship next year sometime.

IMPORTANT NOTE: This toolchain is [today] independent from the DNX-based .NET Core + ASP.NET 5 RC bits. If you are looking for .NET Core + ASP.NET 5 RC bits, you can find instructions on the http://get.asp.net/.

One I installed the "dotnet" cli, I can do this:

>dotnet new

>dotnet restore
>dotnet run

Imagine with me, when you combine this with the free Visual Studio Code editor which runs on Mac, Windows, and Linux, you've got a pretty interesting story. Open Source .NET that runs everywhere, easily.

Here is a longer command line prompt that includes me just typing "dotnet" at the top to get a sense of what's available.

C:\Users\Scott\Desktop\fabulous>dotnet

.NET Command Line Interface
Usage: dotnet [common-options] [command] [arguments]

Arguments:
[command] The command to execute
[arguments] Arguments to pass to the command

Common Options (passed before the command):
-v|--verbose Enable verbose output

Common Commands:
new Initialize a basic .NET project
restore Restore dependencies specified in the .NET project
compile Compiles a .NET project
publish Publishes a .NET project for deployment (including the runtime)
run Compiles and immediately executes a .NET project
repl Launch an interactive session (read, eval, print, loop)
pack Creates a NuGet package

C:\Users\Scott\Desktop\fabulous>dotnet new
Created new project in C:\Users\Scott\Desktop\fabulous.

C:\Users\Scott\Desktop\fabulous>dotnet restore
Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16231

CACHE https://www.myget.org/F/dotnet-core/api/v3/index.json
CACHE https://api.nuget.org/v3/index.json
Restoring packages for C:\Users\Scott\Desktop\fabulous\project.json
Writing lock file C:\Users\Scott\Desktop\fabulous\project.lock.json
Restore complete, 947ms elapsed

NuGet Config files used:
C:\Users\Scott\AppData\Roaming\NuGet\nuget.config
C:\Users\Scott\Desktop\nuget.config
C:\Users\Scott\Desktop\fabulous\nuget.config

Feeds used:
https://www.myget.org/F/dotnet-core/api/v3/flatcontainer/
https://api.nuget.org/v3-flatcontainer/

C:\Users\Scott\Desktop\fabulous>dotnet run
Hello World!

Note that I ran dotnet restore once before on another projects so that output was not very noisy this time.

Native Compilation of .NET applications

This is cool, but things get REALLY compelling when we consider native compilation. That literally means our EXE becomes a native executable on a platform that doesn't require any external dependencies. No .NET. It just runs and it runs fast.

It's early days, and right now per the repro it's just hello world and a few samples but essentially when you do "dotnet compile" you get this, right, but it requires the .NET Core Runtime and all the supporting libraries. It JITs when it runs like the .NET you know and love.

.NET Core Compiled EXE

But if you "dotnet compile --native" you run it through the .NET Native chain and a larger EXE pops out. But that EXE is singular and native and just runs.

Native compiled .NET Core EXE

Again, early days, but hugely exciting. Here's the high-level engineering plan on GitHub that you can explore.

Related Projects

There are many .NET related projects on GitHub.


Sponsor: Big thanks to Redgate for sponsoring the feed this week! Have you got SQL fingers? Try SQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio. Find out more with a 28 day free trial!



© 2015 Scott Hanselman. All rights reserved.
     

Best practices for private config data and connection strings in configuration in ASP.NET and Azure

$
0
0

Image Copyright Shea Parikh / getcolorstock.com - used under licenseA reader emailed asking how to avoid accidentally checking in passwords and other sensitive data into GitHub or source control in general. I think it's fair to say that we've all done this once or twice - it's a rite of passage for developers old and new.

The simplest way to avoid checking in passwords and/or connection strings into source control is to (no joke) keep passwords and connection strings out of your source.

Sounds condescending or funny, but it's not, it's true. You can't check in what doesn't exist on disk.

That said, sometimes you just need to mark a file as "ignored," meaning it's not under source control. For some systems that involves externalizing configuration values that may be in shared config files with a bunch of non-sensitive config data.

ASP.NET 4.6 secrets and connection strings

Just to be clear, how "secret" something is is up to you. If it's truly cryptographically secret or something like a private key, you should be looking at data protection systems or a Key Vault like Azure Key Vault. Here we are talking about medium business impact web apps with API keys for 3rd party web APIs and connection strings that can live in memory for short periods. Be smart.

ASP.NET 4.6 has web.config XML files like this with name/value pairs.

<appSettings>      

<add key="name" value="someValue" />
<add key="name" value="someSECRETValue" />
</appSettings>

We don't want secrets in there! Instead, move them out like this:

<appSettings file="Web.SECRETS.config">      

<add key="name" value="someValue" />
</appSettings>

Then you just put another appSettings section in that web.secrets.config file and it gets merged at runtime.

NOTE: It's worth pointing out that the AppSettings technique also works for Console apps with an app.config.

Finally, be sure to add Web.secrets.config (or, even better, make it *.secrets and use a unique extension to identify your sensitive config.

This externalizing of config also works with the <connectionStrings> section, except you use the configSource attribute like this:

<connectionStrings configSource="secretConnectionStrings.config">

</connectionStrings>

Connection Strings/App Secrets in Azure

When you're deploying a web app to Azure (as often these apps are deployed from source/GitHub, etc) you should NEVER put your connection strings or appSettings in web.config or hard code them.

Instead, always use the Application Settings configuration section of Web Apps in Azure.

Application Settings and Secrets in Azure

These collection strings and name value pairs will automatically be made available transparently to your website so you don't need to change any ASP.NET code. Considered them to have more narrow scope than what's in web.config, and the system will merge the set automatically.

Additionally they are made available as Environment Variables, so you can Environment.GetEnvironmentVariable("APPSETTING_yourkey") as well. This works in any web framework, not just ASP.NET, so in PHP you just getenv('APPSETTING_yourkey") as you like.

The full list of database connection string types and the prepended string used for environment variables is below:

  • If you select “Sql Databases”, the prepended string is “SQLAZURECONNSTR_”
  • If you select “SQL Server” the prepended string is “SQLCONNSTR_”
  • If you select “MySQL” the prepended string is “MYSQLCONNSTR_”
  • If you select “Custom” the prepended string is “CUSTOMCONNSTR_”

ASP.NET 5

ASP.NET 5 has the concept of User Secrets or User-Level Secrets where the key/value pair does exist in a file BUT that file isn't in your project folder, it's stored in your OS user profile folder. That way there's no chance it'll get checked into source control. There's a secret manager (it's all beta so expect it to change) where you can set name/value pairs.

ASP.NET also has very flexible scoping rules in code. You can have an appSettings, then an environment-specific (dev, test, staging, prod) appSettings, then User Secrets, and then environment variables. All of this is done via code configuration and is, as I mentioned, deeply flexible. If you don't like it, you can change it.

var builder = new ConfigurationBuilder()

.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

if (env.IsDevelopment())
{
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}

builder.AddEnvironmentVariables();
Configuration = builder.Build();

So, in conclusion:

  • Don't put private stuff in code.
    • Seems obvious, but...
  • Avoid putting private stuff in common config files
    • Externalize them AND ignore the externalized file so they don't get checked in
  • Consider using Environment Variables or User-level config options.
    • Keep sensitive config out of your project folder at development time

I'm sure I missed something. What are YOUR tips, Dear Reader?

Resources

Image Copyright Shea Parikh - used under license from http://getcolorstock.com


Sponsor: Big thanks to Infragistics for sponsoring the blog this week! Responsive web design on any browser, any platform and any device with Infragistics jQuery/HTML5 Controls.  Get super-charged performance with the world’s fastest HTML5 Grid - Download for free now!



© 2015 Scott Hanselman. All rights reserved.
     

When did we stop caring about memory management?

$
0
0

MEMORY! - Image from Wikimedia CommonsThis post is neither a rant nor a complaint, but rather, an observation.

There's some amazing work happening over in the C#-based Kestrel web server. This is an little open source webserver that (currently) sits on libuv and lets you run ASP.NET web applications on Windows, Mac, or Linux. It was started by Louis DeJardin but more recently Ben Adams from Illyriad Games has become a primary committer, and obsessive optimizer.

Kestrel is now doing 1.2 MILLION requests a second on benchmarking hardware (all published at https://github.com/aspnet/benchmarks) and it's written in C#. There's some amazing stuff going on in the code base with various micro-optimizations that management memory more intelligently.

Here's my question to you, Dear Reader, and I realize it will differ based on your language of choice:

When did you stop caring about Memory Management, and is that a bad thing?

When I started school, although I had poked around in BASIC a bit, I learned x86 Assembler first, then C, then Java. We were taught intense memory management and learned on things like Minix, writing device drivers, before moving up the stack to garbage collected languages. Many years later I wrote a tiny operating system simulator in C# that simulated virtual memory vs physical memory, page faults, etc.

There's a great reference here at Ravenbook (within their Memory Pool System docs) that lists popular languages and their memory management strategies. Let me pull this bit out about the C language:

The [C] language is notorious for fostering memory management bugs, including:

  1. Accessing arrays with indexes that are out of bounds;
  2. Using stack-allocated structures beyond their lifetimes (see use after free);
  3. Using heap-allocated structures after freeing them (see use after free);
  4. Neglecting to free heap-allocated objects when they are no longer required (see memory leak);
  5. Failing to allocate memory for a pointer before using it;
  6. Allocating insufficient memory for the intended contents;
  7. Loading from allocated memory before storing into it;
  8. Dereferencing non-pointers as if they were pointers.

When was the last time you thought about these things, assuming you're an application developer?

I've met and spoken to a number of application developers who have never thought about memory management in 10 and 15 year long careers. Java and C# and other languages have completely hidden this aspect of software from them.

BUT.

They have performance issues. They don't profile their applications. And sometimes, just sometimes, they struggle to find out why their application is slow.

My buddy Glenn Condron says you don't have to think about memory management until you totally have to think about memory management. He says "time spent sweating memory is time you're not writing your app. The hard part is developing the experience is that you need to know when you need to care."

I've talked about this a little in podcasts like the This Developer's Life episode on Abstractions with guests like Ward Cunningham, Charles Petzold, and Dan Bricklin as well as this post called Please Learn to Think about Abstractions.

How low should we go? How useful is it to know about C-style memory management when you're a front-end JavaScript Developer? Should we make it functional then make it fast...but if it's fast enough, then just make it work? The tragedy here is that if it "works on my machine" then the developer never goes back to tighten the screws.

I propose it IS important but I also think it's important to know how a differential gear works, but that's a "because" argument. What do you think?


Sponsor: Big thanks to Infragistics for sponsoring the blog this week! Responsive web design on any browser, any platform and any device with Infragistics jQuery/HTML5 Controls.  Get super-charged performance with the world’s fastest HTML5 Grid - Download for free now!



© 2015 Scott Hanselman. All rights reserved.
     

WallabyJS is a slick and powerful test runner for JavaScript in your IDE or Editor

$
0
0

I was reminded by a friend to explore WallabyJS this week. I had looked at WallabyJS a while back when it was less mature but I hadn't installed a more recent version. WOW. It's coming along nicely and is super-powerful. You should check it out if you write JavaScript. It's also super fast, for these reasons:

Wallaby.js is insanely fast, because it only executes tests affected by your code changes and runs your tests in parallel.

WallabyJS has plugins for the IntelliJ platform, Visual Studio, Atom, and more recently, there's preview support for Visual Studio Code and Sublime Text support is coming soon.

It supports supports TypeScript, CoffeeScript, and ES7. Wallaby supports jasmine for running tests but you can plug in your own testing framework and assertion library as you like.

Installing WallabyJS for Visual Studio Code is very easy now that Code supports extensions.

Installing WallabyJS on Visual Studio Code

Once you've installed the extension it will download what's needed and bootstrap WallabyJS. I did have a small issue installing, but and uninstall/reinstall fixed it, so it may have been just a blip.

Visual Studio Code running WallabyJS

If you want to see it in action quickly without much setup, just clone their Calculator sample at

git clone https://github.com/wallabyjs/calculator-sample.git

Do note that it's not totally obvious once you've installed WallabyJS that you have to "start" its server manually...for now.

Starting WallabyJS

Once it has started, it's mostly automatic and runs tests as you type and save. You can access all WallabyJS's commands with hotkeys or from the Visual Studio Code command palette.

WallabyJS Commands in VS Code

It's great to see a powerful tool like this working in Visual Studio Code. Remember you can get VSCode (now open source!) for any platform here code.visualstudio.com and you can get WallabyJS at their main site.


Sponsor: Big thanks to my friends at Redgate for sponsoring the feed this week.Check out their amazing FREE eBook! Discover 52 tips to improve your .NET performance: Our new eBook features dozens of tips and tricks to boost .NET performance. With contributions from .NET experts around the world, you’ll have a faster app in no time. Download your free copy.



© 2015 Scott Hanselman. All rights reserved.
     

ASP.NET 5 is dead - Introducing ASP.NET Core 1.0 and .NET Core 1.0

$
0
0

Naming is hard.

There are only two hard things in Computer Science: cache invalidation and naming things. - Phil Karlton

It's very easy to armchair quarterback and say that "they should have named it Foo and it would be easy" but very often there's many players involved in naming things. ASP.NET is a good 'brand' that's been around for 15 years or so. ASP.NET 4.6 is a supported and released product that you can get and use now from http://get.asp.net.

UPDATE NOTE: This blog post is announcing this change. It's not done or released yet. As of the date/time of this writing, this work is just starting. It will be ongoing over the next few months.

However, naming the new, completely written from scratch ASP.NET framework "ASP.NET 5" was a bad idea for a one major reason: 5 > 4.6 makes it seem like ASP.NET 5 is bigger, better, and replaces ASP.NET 4.6. Not so.

So we're changing the name and picking a better version number.

Reintroducing ASP.NET Core 1.0 and .NET Core 1.0

  • ASP.NET 5 is now ASP.NET Core 1.0.
  • .NET Core 5 is now .NET Core 1.0.
  • Entity Framework 7 is now Entity Framework Core 1.0 or EF Core 1.0 colloquially.

Why 1.0? Because these are new. The whole .NET Core concept is new. The .NET Core 1.0 CLI is very new. Not only that, but .NET Core isn't as complete as the full .NET Framework 4.6. We're still exploring server-side graphics libraries. We're still exploring gaps between ASP.NET 4.6 and ASP.NET Core 1.0.

ASP.NET Core 1.0

Which to choose?

To be clear, ASP.NET 4.6 is the more mature platform. It's battle-tested and released and available today. ASP.NET Core 1.0 is a 1.0 release that includes Web API and MVC but doesn't yet have SignalR or Web Pages. It doesn't yet support VB or F#. It will have these subsystems some day but not today.

We don't want anyone to think that ASP.NET Core 1.0 is the finish line. It's a new beginning and a fork in the road, but ASP.NET 4.6 continues on, released and fully supported. There's lots of great stuff coming, stay tuned!


Sponsor: Big thanks to Wiwet for sponsoring the feed this week. Build responsive ASP.NET web apps quickly and easily using C# or VB for any device in 1 minute. Wiwet ASP.Net templates are integrated into Visual Studio for ease of use. Get them now at Wiwet.com.



© 2016 Scott Hanselman. All rights reserved.
     

Review: littleBits Gadgets and Gizmos electronics kits for STEM kids

$
0
0

GGK_Box_Everything_600x400_v-2I love posting about STEM (Science, Technology, Engineering, and Mathematics) and some of the great resources, products, and software that we can use to better prepare the next generation of little techies.

Here's some previous posts I've done on the topics of STEM, kids, programming, and learning with young people:

The 8 year old (recently 7, now barely 8) has been playing with littleBits lately and having a blast. He loved SnapCircuits so littleBits seemed like a reasonable, if slightly higher-level, option.

SnapCircuits boldly has kids as young as three or four creating circuitry from a simple light and switch all the way up to a solar-powered radio or a burglar/door alarm. It doesn't hide the complexities of volts and amps and includes low-level components like resistors. Frankly, I wish my first EE (Electrical Engineering) class in college was taught with SnapCircuits.

LittleBits (usually a lowercase L) jumps up a layer of abstraction and includes motors, motion detectors, LED arrays, and lots more. There are also specific kits for specific interests like a littleBits Musical Electronics Synth Kit and a littleBits Smart Home Kit that include specific littleBits that extend the base kit.

littleBits1

The key to littleBits is their magic magnet that makes it basically impossible to do something wrong or hurt yourself. The genius here is that the magnet only goes one way (because: magnets) and the connector underlying transmits both power and data.

You start with a power bit, then add an "if" statement like a switch, then move to do a "do" statement like a motor or light or whatever. In just about 20 minutes my 8 year old was able to take a LEGO custom Star Wars Blaster and add totally new functionality like lights and sounds..

The 8 year old wanted to show his Star Wars Blaster/Fan combo made with @littlebits #video

A video posted by Scott Hanselman (@shanselman) on


One of the aspects of littleBits that I think is powerful but that wasn't immediately obvious to me is that you shouldn't be afraid to use glue or more permanent attachments with your projects. I initially tried to attach littleBits with rubber bands and strings but realized that they'd smartly included "glue dots" and Velcro as well as 3M adhesive pads. Once we stopped being "afraid" to use these stickers and adhesives, suddenly little projects became semi-permanent technical art installations.

We got the "Gizmos & Gadgets" kit which is a little spendy, but it includes 15 bits that enables you to do basically anything. The instructions are great and we a had remote-controlled robot that could drive around the room running within an hour. It's a great setup, a fun kit, and something that kids 8-14 will use all the time.

Here are some fantastic examples of other Star Wars related littleBits projects for you to explore:

*Amazon links are referral links on my blog. Click them and share them to support the blog and the work I do, writing this blog on my own time. Thanks!


Sponsor: Big thanks to Wiwet for sponsoring the feed this week. Build responsive ASP.NET web apps quickly and easily using C# or VB for any device in 1 minute. Wiwet ASP.Net templates are integrated into Visual Studio for ease of use. Get them now at Wiwet.com.



© 2016 Scott Hanselman. All rights reserved.
     

Interactive Coding with C# and F# REPLs (ScriptCS or the Visual Studio Interactive Window)

$
0
0

REPLs are great! REPL stands for Read–eval–print loop and is pronounced "REP-L" quickly, like "battle." Lots of languages and environments have interactive coding and REPLS at their heart and have for years. C# and F# do also, but a lot of people don't realize there are REPLs available!

ScriptCS

In 2013 once the Roslyn open source C# compiler started to mature, Glenn Block and many friends made ScriptCS. It now lives at http://scriptcs.net and has a great GitHub and active community. The Mono project has also had a REPL for a very long time.

The C# Interactive Shell CSI

You can install ScriptCS in minutes with the Chocolatey Package Manager or OneGet with Chocolatey on Windows 10. In the screenshot above I'm writing code at the command prompt, making mistakes, and fixing them. It's a great way to learn and play with C#, but it's also VERY powerful. You can create C# Scripts (.csx files) kind of like PowerShell but it's just C#!

Visual Studio's REPLs - CSI and FSI

The Visual Studio team meets/met with the ScriptCS folks in the open and even publishes their meeting notes on GitHub! In May of last year they got ScriptCS working in OmniSharp and Visual Studio Code, which is amazing. There's a great set of directions here on how to set up ScriptCS in Visual Studio Code and the code is moving fast on GitHub.

Visual Studio 2015 Update 1 has REPLs within the IDE itself. If you have Visual Studio 2015, make sure you've updated to Update 1. If you don't have VS, you can get the free Visual Studio Community at http://visualstudio.com/free.

VS ships a command line RELP called "CSI" that you can use to run ".csx" scripts as well. Turns out the source code for CSI is basically nothing! Check it out at http://source.roslyn.io/#csi/Csi.cs and you can see how easy it would be for you to add scripting (interactive or otherwise) to your own app.

C# Interactive REPL inside Visual Studio

There's a great C# Interactive Walkthrough by Kasey Uhlenhuth that you should take a moment and play with. She's the Program Manager on this feature and also has a great video on Channel 9 on how to use the C# Interactive REPL.

Introducing the Visual Studio 'C# REPL'

Of course, F# has always had a REPL called "fsi.exe" that also ships with VS. You may have this on your PATH and not realize it, in fact. F# script files are ".fsx" so there's a nice symmetry with scripting and REPLs available in both languages, either in VS itself, or at the command line.

The F# Interactive Shell

F#'s REPL is also inside VS, right here next to the C# Interactive Window.

C# Interactive and F# Interactive in VS

These are all great options for learning and exploring code in a more interactive way than the traditional "write, compile, wait, run" that so many of us are used to.

Let's hear in the comments how (or if!) you're using REPLs like these two make your programming life better.


Sponsor: Big thanks to Wiwet for sponsoring the feed this week. Build responsive ASP.NET web appsquickly and easily using C# or VB for any device in 1 minute. Wiwet ASP.Net templates are integrated into Visual Studio for ease of use. Get them now at Wiwet.com.



© 2016 Scott Hanselman. All rights reserved.
     

GitHub Activity Guilt and the Coder's FitBit

$
0
0

I got an interesting email today from Corey P., reprinted in part here, with permission.

I’m curious, how you feel about GitHub’s activity graph? I’ve found myself getting increased levels of guilt/stress over that graph. So much so I’m considering not using GitHub for personal projects (only use it for contributing pull requests, reporting issues, etc.). 

I can’t help but feel like others judge me by it (phony syndrome?). I have this gnawing feeling that I need to do something in the open so I can have some sort of paper trail or else I’ll be looked down upon by people (perspective employers? colleagues?).

This is a great question. Let's look at my GitHub Graph.

235 Total Contributions

Yikes. Is this good or bad? It's pretty spartan over Sep-Nov, although I was travelling a lot.

Maybe Damian Edwards? He leads ASP.NET, although he isn't technically a dev (as far as HR is concerned). He's got me beat by double.

564 Total Contributions

OK, what's a serious contender look like? Here's Monica Dinculescu, Googler and dev on Polymer:

3244 Total Contributions

or David Fowler, architect and dev on ASP.NET

1885 Total Contributions

What's our takeaway here? That I suck and Monica's amazing? (True, though, I do suck, and please have a listen to Monica as she explains Web Components to me on a recent podcast episode)

Here's what I think about charts like this, and I'm interested in your opinion.

  • GitHub's activity chart shows public repos, not private activity.
  • I have a lot of small projects I work on during the week in private or local repos. and sometimes I don't make them public due to (slight) embarrassment at my works in progress.
  • It's not always healthy to measure yourself against others, particularly if it makes you feel bad or is somewhat unhealthy.
  • Jobs vary. Being a manager does take you away from coding sometimes.
  • If it bothers you, set a reasonable goal and work towards it, but do it for a good reason. (See how Reason and Reasonable factor in greatly there?)

Will I ever be as prolific as Monica or David? Likely not, but it's cool to know what the top of the bar is. Also, we have different jobs. Monica is working actively on a public open source project, while I'm not currently committing code to ASP.NET Core. Even Damian, a Lead PM on ASP.NET Core gets caught up in the "management" of it all. I doubt he gives his green chart a second thought.

My job currently doesn't have me committing to public repros as often as I'd like, but I'm not going let this chart dictate my value to the team. I will use it as one of many measuring sticks and I'd encourage you to as well. Perhaps set a goal to commit to an OSS project a few times a week?

GitHub Acitivty as it relates to Hiring

Sasha Laundy brought up a number of important points on Twitter about your GitHub Activity graph. She says:

If GitHub commits are only side projects, what kinds of people have time to put towards that? and if you can be silently discredited in hiring because of your public profile, how does that impact equity & diversity?

She has a great point. It's worth arguing that given the GitHub Activity Graph shows only public activity, making judgments based on it would naturally skew towards:

  • The already skilled vs. the codenewbie
  • People with more spare time, e.g. young, single, etc
  • Folks who work on OSS full-time (their company pays them to commit publically to code)

To her point, if your GitHub Activity page is given similar weight as your LinkedIn, how will you ever know if you've been quietly excluded from a job based on this chart? If you're just getting started or if you're a 20 year Enterprise software developer you may end up with an empty graph and find an uninformed recruiter glossed over your potential or experience based how much "green" they see.

What do YOU think of this? Does your GitHub Activity Graph stress you out like getting 10,000 steps on your FitBit? Or do you just roll with it? Sound off in the comments.



© 2016 Scott Hanselman. All rights reserved.
     

The Joy of Live Coding - CodePen, REPLs, TOPLAP, Alive, and more

$
0
0

A few weeks ago I talked about Interactive Coding with C# and F# REPLs. There's a whole generation that seemingly missed out on LIVE CODING. By that, I mean, writing and running code at the same time.

Lots of folks used C, C++, Delphi, C#, Java, etc over the last 15-20-30 years and had a pretty standard Write, Compile, Walk Away, Run process working for them. Twenty years ago I was often waiting 30 min or more for stuff that takes seconds now. Many of you today may have to wait hours for compilation.

However, there's so many environments available today that can allow us to write code while it runs. Instant satisfaction...and the browser is becoming a fantastic IDE for Live Coding.

When I use the term "Live Coding" though, there's actually a couple of definitions. I'm conflating them on purpose. There's Live Coding as in "coding LIVE while people watch" and there's "coding and watching your program change as you type." Of course, you can do them both, hence my conflating.

Live Coding - Music and Art

Mike Hodnick mentioned Live Coding to me in the context of music and art. Live Coders use a wide array of languages and tech stacks to make music and art, including JavaScript, Ruby, Haskell, Clojure, and a number of DSL's. Here is a YouTube video of Mike - Live Coding music using Tidal, a language for musical improvisation.

Resources

  • Overtone - Collaborative Programmable Music.
  • TOPLAP - An organization dedicated to live coding.
  • Cyril - Live Coding Visuals
  • SuperCollider - Real time audio synthesis
  • Tidal - Live Coding Music

Some prominent live coders:

Live Coding - JavaScript and Experimentation

There's another kind of live coding that makes me happy, and that's things like CodePen. Sometimes you just want to write some HTML, CSS, and/or some JavaScript. No IDEA, no text editor...AND you want it to be running as you type.

Code and Watch. That's it.

Some of you LIVE in CodePen. It's where most of your work and prototyping happens, truly. Others who read this blog may be learning of CodePen's existence this very moment. So don't knock them! ;)

CodePen is lovely

CodePen is a "playground for the front-end side of the web." There have been a number of Live Coding Playgrounds out there, including...

But it's fair to say that CodePen has stayed winning. The community is strong and the inspiration you'll find on CodePen is amazing.

Oh, and just to end this blog post on a high note, ahem, and combine Live Coding of Music with  ahem, here's a Roland 808 (that's a Rhythm Controller) written entirely in CodePen. Ya, so. Ya. And it works. AWESOME. Here's the code you can play with, it's by Gregor Adams.

Magical Roland 808 written in CodePen

There's even Live Coding in Visual Studio now with the "Alive" plugin at https://comealive.io.

What kinds of Live Coding tools or experiences have YOU seen, Dear Reader? Share in the comments!


Sponsor: Thanks to my friends at Redgate for sponsoring the blog this week! Have you got SQL fingers? Try SQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio. Find out more with a free trial!



© 2016 Scott Hanselman. All rights reserved.
     

Benchmarking .NET code

$
0
0
You've got a fast car...photo by Robert Scoble used under CC

A while back I did a post called Proper benchmarking to diagnose and solve a .NET serialization bottleneck. I also had Matt Warren on my podcast and we did an episode called Performance as a Feature.

Today Matt is working with Andrey Akinshin on an open source library called BenchmarkDotNet. It's becoming a very full-featured .NET benchmarking library being used by a number of great projects. It's even been used by Ben Adams of "Kestrel" benchmarking fame.

You basically attribute benchmarks similar to tests, for example:

[Benchmark]

public byte[] Sha256()
{
return sha256.ComputeHash(data);
}

[Benchmark]
public byte[] Md5()
{
return md5.ComputeHash(data);
}

The result is lovely output like this in a table you can even paste into a GitHub issue if you like.

Benchmark.NET makes a table of the Method, Median and StdDev

Basically it's doing the boring bits of benchmarking that you (and I) will likely do wrong anyway. There are a ton of samples for Frameworks and CLR internals that you can explore.

Finally it includes a ton of features that make writing benchmarks easier, including csv/markdown/text output, parametrized benchmarks and diagnostics. Plus it can now tell you how much memory each benchmark allocates, see Matt's recent blog post for more info on this (implemented using ETW events, like PerfView).

There's some amazing benchmarking going on in the community. ASP.NET Core recently hit 1.15 MILLION requests per second.

That's pushing over 12.6 Gbps a second. Folks are seeing nice performance improvements with ASP.NET Core (formerly ASP.NET RC1) even just with upgrades.

It's going to be a great year! Be sure to explore the ASP.NET Benchmarks on GitHub https://github.com/aspnet/benchmarks as we move our way up the TechEmpower Benchmarks!

What are YOU using to benchmark your code?


Sponsor: Thanks to my friends at Redgate for sponsoring the blog this week! Have you got SQL fingers?Try SQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio. Find out more with a free trial!



© 2016 Scott Hanselman. All rights reserved.
     

The Importance of the LED Moment - I DID THAT

$
0
0

Last March my friend Saron and I created MarchIsForMakers.com and spent the whole month creating and learning with hardware.

It's March again! We're going to spend the whole month of March adding to http://www.marchisformakers.com.

If you want to support our project, make sure you tell teachers, schools, family and friends about us, and tweet with the hashtag #marchisformakers.

Here's some of the highlights of this fantastic project from March of 2015. You can get ALL the content on our site, so bookmark and visit often.

Getting Started

You may have heard of Raspberry Pis and Arduinos, and perhaps considered doing a little tinkering, either with the children in your life or on your own? Where do you start?

What's "Hello World" in the world of hardware? It's making an LED light up!

I optimize my workflow for lots of tiny victories.

There's a moment when your tinkering. Getting that first program to compile or that first light to light up. Saron and I call it the LED Moment. When you are teaching a kid (a 100 year old kid or a little kid) how to successfully control an LED they'll light up..."I DID THAT." I pushed a button or ran a program or just plug it into a battery. There's a moment when a person see they can take control of the physical word, harness electricity, combine hardware and software and TURN A FREAKING LIGHT ON. That's the moment we are going for. Let's do it.

Arduino and an LED

Check out the article on CodeNewbies about Raspberry Pis and Arduinos by Julian. Arduinos are inexpensive and open source microcontrollers that are VERY affordable. I've got 4 or 5 around the house!

91goKoGWHtL._SL1500_

You'll want an Arduino UNO to start with. They are about $20 on Amazon but they don't include a USB cable (perhaps you have one) or an optional power supply. If you're planning on tinkering you might consider getting a "Super Starter Kit" or a Starter Kit WITH the Arduino that has all sorts of fun stuff like buttons and cables and fans and resistors.

For our little LED project you'll just want:

Ask around, you may have friends with these in their junk drawers so don't spend money unnecessarily.

Don't have an Arduino or can't get one? Fear not, you can simulate one in your browser for free! Check out http://123d.circuits.io/
image

Ok, if you have a physical Arduino, go download the free Arduino Software for WIndows, Mac or Linux.

Different Boards

There are a number of different flavors of Arduino boards. Lots, in fact! Since it's an open source hardware spec anyone can make one and add their own special sauce. Here is just a few of the dozens of boards.

  • Arduino Uno - Arguably the most popular introductory model. It connects via USB and looks like a standard COM port to your computer. No wi-fi, no ethernet, although you can get an "Arduino Shield" add-on board that snaps on top to extend it to do most anything.
  • Arduino Yun - A fancy Arduino with a micro-SD slot, Wi-Fi, Ethernet, and more. It even supports an OpenWRT Linux called Linino.
  • Intel's Arduino 101 Kit - This board is an Arduino from Intel that adds Bluetooth Low Energy AND a 6 axis Accelerometer.

I have an Intel board with me today, so I need to tell the Arduino Software about it by downloading an "Arduino Core." You'll want to tell the software which board YOU are using.

I go Tools | Boards | Board Manager and search for "Intel" and install it. This tells the Arduino Software what it needs to know for my board to act right.

image

Plug the board in using a USB cable and make sure that you've selected the right board and the right port in your Arduino software.

I'm going to take my LED and put the short leg - that's the negative leg - into Arduino's GND, or Ground. Then I take the long or positive leg of the LED and connect it to the resistor,  then put the resistor into the Arduino's pin 13. We are going to control that pin with software we write!

BlinenLights

We are going to pulse the LED by turning pin 13 HIGH, waiting a second, then going low. Like this, within the Arduino Software:

void setup() {

pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH); // turn LED on (HIGH voltage)
delay(1000); // wait a second
digitalWrite(13, LOW); // turn LED off by making voltage LOW
delay(1000); // wait a second
}

Press Upload and my little Arduino Sketch is sent to my board and starts running! And here it is!

#MarchIsForMakers @intelIoT @arduinoorg #video

A video posted by Scott Hanselman (@shanselman) on

Again, every board is different. In my case, my Intel Arduino 101 board also has that gyroscope/accelerometer built in. I'll try playing with that soon!

What are you going to make this Month?



© 2016 Scott Hanselman. All rights reserved.
     

Finding the Perfect Mouse

$
0
0

I have a small problem. I'm always looking for great computer mice. I've tried a number of mice (and keyboards!) over the years.

Five black computer mice, laid out left to right, and described in order below

Here's the current line up.

But the left one...oh this mouse. That's the Logitech MX Master Wireless Mouse and it's really top of the line and it's my current daily driver. It's usually $99 but I've seen it for $74 or less on sale.

The Logitech MX Master is a high end mouse, but rather than catering to gamers as so many mice do, it seems to be aimed more towards creators and makers. Prosumers, if you will.

Highlights

  • The MX Master has rechargeable LiPo batteries that are charged with a simple micro USB cable. So far they've lasted me two weeks or more with just a few minutes of charging. Plus, you can use the mouse with the cord attached. There's a 3 light LED on the side as well as software support so you won't be surprised by a low battery.
  • Fantastic customizable software.
    Exceptional Logitech Mosue Customization Software
  • Uses the "Unifying Receiver" which means a single dongle for multiple Logitech products. I also have the Logitech T650 Touchpad and they share the same dongle.
  • Even better, the MX Master also supports Bluetooth so you can use either. This means I can take the mouse on the road and leave the dongle.
  • Tracks on glass. My actual desktop is in entirely glass. It's a big sheet of glass and I've always had to put mouse pads on it, even with Microsoft Mice. This mouse tracks the same on a pad or a glass surface.
  • Heavy but the right kind of heavy. It's about 5 oz and it has heft that says quality but not heft that's tiring to push around.

One of the most unusual features is the Scroll Wheel. Some mice of a smooth scroll wheel with no "texture" as you scroll. Others have very clear click, click, click as you scroll. The MX Master has both. That means you can use "Ratchet" mode (heh) or "Freespin" mode, and you can assign a Mode Shift. If I click the wheel you can hear a clear mechanical click as (presumably) a magnet locks into place to provide the ratcheting sound and feel which is great for precision. Click again and you are FLYING through long PDFs or Web Pages. It's really amazing and not like any mouse I've used in this respect.

On top of that there is a SmartShift feature that automatically switches you between modes depending on the speed and vigor that you spin the wheel. All of this is configurable, to be clear.

It's a nice mouse for advanced folks or Devs because not only can you change basically every button (including a unique "gesture button" at your thumb where you click it and move the mouse for things like 'Next Virtual Desktop') but you can also have...

image

...configurations on a per-application basis!

image

This is fantastic because I want Chrome to scroll and feel one way and Visual Studio to scroll and feel another.

It's been 6 weeks with this new mouse and it's now my daily driver for code, blog posts, Office, and everything.

Trying out this new @Logitech MX Master mouse. This thing is SO SMOOTH.

A photo posted by Scott Hanselman (@shanselman) on

 

What's your favorite mouse or pointing device? Let's hear it in the comments!


PSA: Be sure to check out http://MarchIsForMakers.com all month long for great hardware podcasts, blogs, and videos! Spread the word and tweet with #MarchIsForMakers!

* Referral links help me buy mice. Click them for me please.



© 2016 Scott Hanselman. All rights reserved.
     

Building Visual Studio Code on a Raspberry Pi 3

$
0
0

Visual Studio Code running on a Raspberry Pi 3 - Michonne Approves

I picked up a Raspberry Pi 3 recently for MarchIsForMakers. The Raspberry Pi 3 is a great starter computer for makers not just because it is faster than the Pi and Pi 2, but because it has Wifi built in! This makes setup and messing around a lot easier.

Here's some great tutorials for getting started with the Raspberry Pi, Node, and Visual Studio Code.

I also recommend folks setup a VNC Server for their Raspberry Pi so you can TightVNC (meaning, remote in and control) into the Pi from your PC. You can also setup your Raspberry Pi to share the clipboard so you can copy from Windows and Paste into the VNC window when you are remoted into your Pi.

But why not build Visual Studio Code and get it running natively on the Pi? Marc Gravell did it first on Twitter, but I wanted to figure out how he did it and if it was still possible (he did it before some significant refactoring) and also to see if VS Code was faster (or even usable) on a Rasberry Pi 3.

Compiling Visual Studio Code on a Raspberry Pi 3

From the VS Code GitHub, you need Node, npm, and Python. The Pi has Python but it has an old node, so needed a newer node that ran on ARM processors.

get http://node-arm.herokuapp.com/node_latest_armhf.deb

sudo dpkg -i node_latest_armhf.deb

There are some NPM native modules like node-native-keymap that didn't work when I built the first time, so you'll need some supporting libraries first:

sudo apt-get install libx11-dev

Then, from my Raspberry Pi, I did this to build my own instance of VS Code.

git clone https://github.com/microsoft/vscode

cd vscode
./scripts/npm.sh install --arch=armhf

This took the Raspberry Pi 3 about 20 minutes so be patient.

Then, run your instance with ./scripts/code.sh from that same folder.

Note: Electron and Chromium underneath it use some very specific features of X Servers like "xrandr" for dynamic resizing and you may have trouble getting Visual Studio Code to run under a remote VNC session. Consider using RealVNC or TigerVNC for your Raspberry Pi, rather than the older TightVNC. RealVNC is a commercial product but they'll give you a free license for your Raspberry Pi.

Once you've updated to a newer VNC you can run VS Code

image

Check out MarchIsForMakers all month long as we partner with CodeNewbies and play and learn with maker hardware! Last week we unboxed my Raspberry Pi 3, set it up, and got it to blink an LED!

What have YOU done with your Raspberry Pi? Sound off in the comments.


Sponsor: Big thanks to Redgate for sponsoring the feed this week! Feeling the pain of managing & deploying database changes by hand? New Redgate ReadyRoll creates numerically ordered SQL migration scripts to take your schema from one version to the next. Try it free!



© 2016 Scott Hanselman. All rights reserved.
     

How to set up a Raspberry Pi 3 from scratch (with video)!

$
0
0

My messy electronics workspaceMarchIsForMakers continues! It's my month-long collaboration with Saron from CodeNewbie. We've had some amazing guests on our respective podcasts and some great technical content. Please do check it out at http://marchisformakers.com and subscribe to my podcast Hanselminutes as well as the CodeNewbie podcast.

Here's a few of the things we've made for you lately:

Just last week I received my Raspberry Pi 3 in the mail. I called Saron and we decided not only to do an unboxing video, but an "unboxing, setup, AND make it do something" video.

Could we setup a Raspberry Pi 3 from scratch and get it to blink an LED in less than an hour?

Every STEM house should have a Raspberry Pi or six! We've got 4? Or 5? They end up living inside robots, or taped to the garage door, or running SCUMMVM Game Emulators, or powering DIY GameBoys.

If you have a Raspberry Pi 3, awesome. If not, this should work with an original Pi or a Pi 3. You'll want to make sure you have a few parts ready to save you time and trips to the store! I recommend a complete Raspberry Pi Kit when you're just getting started as it guarantees you'll be up and running in minutes. They include the mini SD Card (acts as a hard drive), a power supply, a case, etc. All you need to provide is a USB Keyboard and Mouse. I ended up getting a cheap Mini USB wired keyboardand cheap USB wired mouse for simplicity.

I like to use the new NOOBS setup direct from Raspberry Pi: https://www.raspberrypi.org/help/noobs-setup/. You can get SD cards with NOOBS preinstalled are available from many of our distributors and independent retailers, such as Pimoroni, Adafruit and Pi Hut if you like, but I had a blank card laying around.

I downloaded SD Formatter 4.0 for either Windows or Mac and prepped/formatted my card. Then I downloaded NOOBS and unzipped it directly into the root of my now-empty SD Card.

You plug the SD card into the Raspberry Pi and pick Raspbian as your Operating System (although there are other choices this is easiest for beginners) and wait a bit. The default login is "pi" and the password is "raspberry."

In this video we not only set it up, but we also got VNC working using RealVNC for Raspberry Pi, then Blinked an LED using Python. It was a blast, and was a little touch and go for a moment near the end as we had to pull out the multimeter to debug!

I hope you enjoy it. Also, be sure to explore the #MarchIsForMakers hashtag on Twitter to see lots of other fun stuff folks are doing during our month-long celebration.

What have you made this month?


Sponsor: Thanks to Seq for sponsoring the feed this week! Need to make sense of complex or distributed apps? Structured logging helps your team cut through that complexity and resolve issues faster. Learn more about structured logging with Serilog and Seq at https://getseq.net.



© 2016 Scott Hanselman. All rights reserved.
     

Docker for Windows Beta announced

$
0
0

Docker Desktop AppI'm continuing to learn about Docker and how it works in a developer's workflow (and Devops, and Production, etc as you move downstream). This week Docker released a beta of their new Docker for Mac and Docker for Windows. They've included OS native apps that run in the background (the "tray") that make Docker easier to use and set up. Previously I needed to disable Hyper-V and use VirtualBox, but this new Docker app automates Hyper-V automatically which more easily fits into my workflow, especially if I'm using other Hyper-V features, like the free Visual Studio Android Emulator.

I signed up at http://beta.docker.com. Once installed, when you run the Docker app with Hyper-V enabled Docker automatically creates the Linux "mobylinux" VM you need in Hyper-V, sets it up and starts it up.

"Moby" the Docker VM running in Hyper-V

After Docker for Windows (Beta) is installed, you just run PowerShell or CMD and type "docker" and it's already set up with the right PATH and Environment Variables and just works. It gets setup on your local machine as http://docker but the networking goes through Hyper -V, as it should.

The best part is that Docker for Windows supports "volume mounting" which means the container can see your code on your local device (they have a "wormhole" between the container and the host) which means you can do a "edit and refresh" type scenarios for development. In fact, Docker Tools for Visual Studio uses this feature - there's more details on this "Edit and Refresh "support in Visual Studio here.

The Docker Tools for Visual Studio can be downloaded at http://aka.ms/dockertoolsforvs. It adds a lot of nice integration like this:

Docker in VS

This makes the combination of Docker for Windows + Docker Tools for Visual Studio pretty sweet. As far as the VS Tools for Docker go, support for Windows is coming soon, but for now, here's what Version 0.10 of these tools support with a Linux container:

  • Docker assets for Debug and Release configurations are added to the project
  • A PowerShell script added to the project to coordinate the build and compose of containers, enabling you to extend them while keeping the Visual Studio designer experiences
  • F5 in Debug config, launches the PowerShell script to build and run your docker-compose.debug.yml file, with Volume Mapping configured
  • F5 in Release config launches the PowerShell script to build and run your docker-compose.release.yml file, with an image you can verify and push to your docker registry for deployment to other environment

You can read more about how Docker on Windows works at Steve Lasker's Blog and also watch his video about Visual Studio's support for Docker in his video on Ch9 and again, sign up for Docker Beta at http://beta.docker.com.


Sponsor: Thanks to Seq for sponsoring the feed this week! Need to make sense of complex or distributed apps? Structured logging helps your team cut through that complexity and resolve issues faster. Learn more about structured logging with Serilog and Seq at https://getseq.net.


© 2016 Scott Hanselman. All rights reserved.
     

Developers can run Bash Shell and user-mode Ubuntu Linux binaries on Windows 10

$
0
0

As a web developer who uses Windows 10, sometimes I'll end up browsing the web and stumble on some cool new open source command-line utility and see something like this:

A single lonely $

In that past, that $ prompt meant "not for me" as a Windows user.

I'd look for prompts like

C:\>

or

PS C:\>

Of course, I didn't always find the prompts that worked like I did. But today at BUILD in the Day One keynote Kevin Gallo announced that you can now run "Bash on Ubuntu on Windows." This is a new developer feature included in a Windows 10 "Anniversary" update (coming soon). It lets you run native user-mode Linux shells and command-line tools unchanged, on Windows.

After turning on Developer Mode in Windows Settings and adding the Feature, run you bash and are prompted to get Ubuntu on Windows from Canonical via the Windows Store, like this:

Installing Ubuntu on Windows

This isn't Bash or Ubuntu running in a VM. This is a real native Bash Linux binary running on Windows itself. It's fast and lightweight and it's the real binaries. This is an genuine Ubuntu image on top of Windows with all the Linux tools I use like awk, sed, grep, vi, etc. It's fast and it's lightweight. The binaries are downloaded by you - using apt-get - just as on Linux, because it is Linux. You can apt-get and download other tools like Ruby, Redis, emacs, and on and on. This is brilliant for developers that use a diverse set of tools like me.

This runs on 64-bit Windows and doesn't use virtual machines. Where does bash on Windows fit in to your life as a developer?

If you want to run Bash on Windows, you've historically had a few choices.

  • Cygwin - GNU command line utilities compiled for Win32 with great native Windows integration. But it's not Linux.
  • HyperV and Ubuntu - Run an entire Linux VM (dedicating x gigs of RAM, and x gigs of disk) and then remote into it (RDP, VNC, ssh)
    • Docker is also an option to run a Linux container, under a HyperV VM

Running bash on Windows hits in the sweet spot. It behaves like Linux because it executes real Linux binaries. Just hit the Windows Key and type bash.

After you're setup, run apt-get update and get a few developer packages. I wanted Redis and Emacs. I did an apt-get install emacs23 to get emacs. Note this is the actual emacs retrieved from Ubuntu's feed.

Running emacs on Windows

Of course, I have no idea how to CLOSE emacs, so I'll close the window. ;)

Note that this isn't about Linux Servers or Server workloads. This is a developer-focused release that removes a major barrier for developers who want or need to use Linux tools as part of their workflow. Here I got Redis via apt-get and now I can run it in standalone mode.

Running Redis Standalone on Windows

I'm using bash to run Redis while writing ASP.NET apps in Visual Studio that use the Redis cache. I can then later deploy to Azure using the Azure Redis Cache, so it's a very natural workflow for me.

Look how happy my Start Menu is now!

A happy start menu witih Ubuntu

Keep an eye out at http://blogs.msdn.microsoft.com/commandline for technical details in the coming weeks. There's also some great updates to the underlying console with better support for control codes, ANSI, VT100, and lots more. This is an early developer experience and the team will be collection feedback and comments. You'll find Ubuntu on Windows available to developers as a feature in a build Windows 10 coming soon. Expect some things to not work early on, but have fun exploring and seeing how bash on Ubuntu on Windows fits into your developer workflow!


Sponsor:  BUILD - it’s what being a developer is all about so do it the best you can. That’s why Stackify built Prefix. No .NET profiler is easier or more powerful. You’re 2 clicks and $0 away, so build on! prefix.io



© 2016 Scott Hanselman. All rights reserved.
     

Visual C++ for Linux and Raspberry Pi Development

$
0
0

It's bananas over at Microsoft. Last week they announced you can run Bash on Ubuntu on Windows 10, and now I'm seeing I missed an announcement of an extension to Visual Studio that enables Visual C++ for Linux Development.

With this extension you can author C++ code for Linux servers, desktops and devices. You can manage your connections to these machines from within VS. VS will automatically copy and remote build your sources and can launch your application with the debugger. Their project system supports targeting specific architectures, including ARM which means Raspberry Pi, folks.

ASIDE: I also noticed there's a C/C++ extension for Visual Studio Code also. I need to add that to my list of stuff to check out, it looks pretty compelling as well.

Once Visual C++ for Linux Development is installed, you go and File New Project like this. Cool to see Linux in that list along with a Raspberry Pi project.

File New | Linux App

You can pick x86, x64, and ARM, and you can see Remote GDB Debugger is an option.

Remote GDB Debugger

Here I'm running Ubuntu in a VM and connecting to it over SSH from Visual Studio. I needed to set up a few things first on the Ubuntu machine

sudo apt-get install openssh-server g++ gdb gdbserver

Once that was setup, connecting to the remote Linux machine was pretty straightforward as VS is using SSH.

Debugging C++ apps remotely talking to a Linux VM

Pretty cool.

NOTE: Today this cool extension has nothing to do with the Bash on Ubuntu on Windows announcement or that subsystem.  The obvious next question is "can I use this without a VM and talk to gdb on the local Linux subsystem?" From what I can tell, no, but I'm still trying to get SSH and GDB working locally. It's theoretically possible but I'm not sure if it's also insane. Both teams are talking, but again, this feature isn't related to the other.

This extension feels a little beta to me but it does a good job providing the framework for talking to Linux from VS. The team looks to be very serious and even has a cool demo where they code and debug a Linux desktop app.

If you're looking for a another full featured solution for Linux and Embedded Systems development with Visual Studio, be sure to download and check out VisualGDB, it's amazing.


Sponsor: Quality instrumentation is critical for modern applications. Seq helps .NET teams make sense of complex, asynchronous, and distributed apps on-premises or in the cloud. Learn more about structured logging and try Seq free for 30 days at https://getseq.net.



© 2016 Scott Hanselman. All rights reserved.
     

Installing Fish Shell on Ubuntu on Windows 10

$
0
0

So hopefully by now you've heard that you can run Bash via Ubuntu on Windows...and not in a VM. You can run the Bash Shell and real ELF Linux Binaries (this is not emulation) on Windows 10.

I've recorded a 30 min video with developers from the project and there's a blog post from Dustin from Ubuntu about HOW this works if you want more technical details. You should also check out the Command Line Blog and subscribe and head over to User Voice to help pick the next features.

It's beta, but it's super fun. A common question is "hey bash is lovely but what about _____ shell." Right now as I understand it supports bash and adding other shells may not work, and if it does, you're hacking around. So, let's hack around.

I noticed this shell called Fish Shell and noticed that Ruby Nealon had Fish tweaked and running. I asked for some more detail and they were happy to oblige with a medium post. Thanks Ruby!

Let me give it a try.

Add the Fish Apt Repo and install.

I headed over to the fish site and did this.

sudo apt-add-repository ppa:fish-shell/release-2

sudo apt-get update
sudo apt-get install fish

Oh, and I also changed my Console Font to use Ubuntu Mono because

Note: I'm hearing it will be WAY easier to add new fonts as the console continues improving. The conhost.exe stuff improves console for everyone, including cmd.exe, powershell.exe, and bash. That console work includes VT100, ANSI, and other stuff, and is separate, but complementary to the bash work.

Nice font.

Bash on Ubuntu on Windows - Cats and Dogs Living Together Mass Hysteria

Because we're still launching bash, we need to use the .bashrc today to launch fish, so you'll need to add ssh-agent fish, and exit to your .bashrc if you want to try this.

OK, next, kind of unrelated to fish, but still useful, I wanted to setup git and ssh-agent, so I generate a new key, add it to ssh agent, following these guides.

Theming Fish

Ruby also points out that Fish has a "Oh My Fish" framework for packages and themes. You can get it easily:

curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish

omf help

Ruby also included their own fish_prompt.sh file here for the "chain" theme that I installed with "omf install chain" as some glyphs rendered weird. If you want unicode characters like → in your prompt, make sure your files are UTF-8 and not ANSI or you'll get squares!

Now my prompt uses fish, has cool auto complete, nice colors, shows the git dirty bit and branch.

image

Yes, I realize there are literally fiftyleven billion ways to customize bash, zsh, and lots of other shells to do much cooler stuff than this. I too, am old, and I to have used *nix for years. But it was fun and easy to get fish running on Ubuntu on Windows. Thanks Ruby!


Sponsor: Quality instrumentation is critical for modern applications. Seq helps .NET teams make sense of complex, asynchronous, and distributed apps on-premises or in the cloud. Learn more about structured logging and try Seq free for 30 days at https://getseq.net.



© 2016 Scott Hanselman. All rights reserved.
     

How to host your own NuGet Server and Package Feed

$
0
0

Local NuGet FeedHosting your own NuGet Server, particularly when you're a company or even a small workgroup is a super useful thing. It's a great way to ensure that the build artifacts of each team are NuGet Packages and that other teams are consuming those packages, rather than loose DLLs.

A lot of folks (myself included a minute ago) don't realize that Visual Studio Team Services also offers private NuGet Feeds for your team so that's pretty sweet. But I wanted to try out was setting up my own quick NuGet Server. I could put it on a web server in my closet or up in Azure.

From the NuGet site:

There are several third-party NuGet Servers available that make remote private feeds easy to configure and set-up, including Visual Studio Team Services, MyGet, Inedo's ProGet, JFrog's Artifactory, NuGet Server, and Sonatype's Nexus. See An Overview of the NuGet Ecosystem to learn more about these options.

File Shares or Directories as NuGet Server

Starting with NuGet 3.3 you can just use a local folder and it can host a hierarchical NuGet feed. So I head out to the command line, and first make sure NuGet is up to date.

C:\Users\scott\Desktop>nuget update -self

Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 3.3.0.
NuGet.exe is up to date.

Then I'll make a folder for my "local server" and then go there and run "nuget init source dest" where "source" is a folder I have full of *.nupkg" files.

This command adds all the packages from a flat folder of nupkgs to the destination package source in a hierarchical layout as described below. The following layout has significant performance benefits, when performing a restore or an update against your package source, compared to a folder of nupkg files.

There's two ways to run a "remote feed" handled by a Web Server, rather than a "local feed" that's just a file folder or file share. You can use NuGet.Server *or* run your own internal copy of the NuGet Gallery. The gallery is nice for large multi-user setups or enterprises. For small teams or just yourself and your CI (continuous integration) systems, use NuGet.Server.

Making a simple Web-based NuGet.Server

From Visual Studio, make an empty ASP.NET Web Application using the ASP.NET 4.x Empty template.

New Empty ASP.NET Project

Then, go to References | Manage NuGet Packages and find NuGet.Server and install it. You'll get all the the dependencies you need and your Empty Project will fill up! If you see a warning about overwriting web.config, you DO want the remote web.config so overwrite your local one.

Nuget install NuGet.Server

Next, go into your Web.config and note the packagesPath that you can set. I used C:\LocalNuGet. Run the app and you'll have a NuGet Server!

You are running NuGet.Server v2.10.0

Since my NuGet.Server is pulling from C:\LocalNuGet, as mentioned before I can take a folder filled with NuPkg files (flat) and import them with:

nuget init c:\source c:\localnuget

I can also set an API key in the web.config (or have none if I want to live dangerously) and then have my automated build push NuGet packages into my server like this:

nuget push {package file} -s http://localhost:51217/nuget {apikey}

Again, as a reminder, while you can totally do this and it's great for some enterprises, there are lots of hosted NuGet servers out there. MyGet runs on Azure, for example, and VSO/TFS also supports creating and hosting NuGet feeds.

The main point is that if you've got an automated build system then you really should be creating NuGet packages and publishing them to a feed. If you're consuming another group's assemblies, you should be consuming versioned packages from their feeds. Each org makes packages and they flow through the org via a NuGet server.

How do YOU handle NuGet in YOUR organization? Do you have a NuGet server, and if so, which one?


Sponsor: Big thanks to RedGate and my friends on ANTS for sponsoring the feed this week!

How can you find & fix your slowest .NET code? Boost the performance of your .NET application with the ANTS Performance Profiler. Find your bottleneck fast with performance data for code & queries. Try it free



© 2016 Scott Hanselman. All rights reserved.
     

Give yourself permission to have work-life balance

$
0
0
Stock photos by #WOCTechChat used with Attribution

I was having a chat with a new friend today and we were exchanging stories about being working parents. I struggle with kids' schedules, days off school I failed to plan for, unexpected things (cars break down, kids get sick, life happens) while simultaneously trying to "do my job."

I put do my job there in quotes because sometimes it is in quotes. Sometimes everything is great and we're firing on all cylinders, while other times we're barely keeping our heads above water. My friend indicated that she struggled with all these things and more but she expressed surprise that *I* did. We all do and we shouldn't be afraid to tell people that. My life isn't my job. At least, my goal is that my life isn't my job.

Why are you in the race?

We talked a while and we decided that our lives and our careers are a marathon, not a giant sprint. Burning out early helps no one. WHY are we running? What are we running towards? Are you trying to get promoted, a better title, more money for your family, an early retirement, good healthcare? Ask yourself these questions so you at least know and you're conscious about your motivations. Sometimes we forget WHY we work.

Saying no is so powerful and it isn't something you can easily learn and just stick with - you have to remind yourself it's OK to to say no every day. I know what MY goals are and why I'm in this industry. I have the conscious ability to prioritize and allocate my time. I start every week thinking about priorities, and I look back on my week and ask myself "how did that go?" Then I optimized for the next week and try again.

Sometimes Raw Effort doesn't translate to Huge Effect.

She needed to give herself permission to NOT give work 100%. Maybe 80% it OK. Heck, maybe 40%. The trick was to be conscious about it, rather than trying to give 100% twice.

Yes, there are consequences. Perhaps you won't get promoted. Perhaps your boss will say you're not giving 110%. But you'll avoid burnout and be happier and perhaps accomplish more over the long haul than the short. 

Work Life

Look, I realize that I'm privileged here. There's a whole knapsack of privilege to unpack, but if you're working in tech you likely have some flexibility. I'm proposing that you at least pause a moment and consider it...consider using it. Consider where your work-life balance slider bar is set and see what you can say no to, and try saying yes to yourself.

I love this quote by Christopher Hawkins that I've modified by making a blank space for YOU to fill out:

"If it’s not helping me to _____ _____, if it’s not improving my life in some way, it’s mental clutter and it's out." - Christopher Hawkins

The Red Queen's Race

Are you running because everyone around you is running? You don't always need to compare yourself to other people. This is another place where giving yourself permission is important.

"Well, in our country," said Alice, still panting a little, "you'd generally get to somewhere else—if you run very fast for a long time, as we've been doing."

"A slow sort of country!" said the Queen. "Now, here, you see, it takes all the running you can do, to keep in the same place. If you want to get somewhere else, you must run at least twice as fast as that!" - Red Queen's Race

There's lots of people I admire, but I'm not willing to move to LA to become Ryan Reynolds (he stole my career!) and I'm not willing to work as hard as Mark Russinovich (he stole my hair!) so I'm going to focus on being the best me I can be.

What are you doing to balance and avoid burnout?

* Stock photo by #WOCTechChat used with Attribution


Sponsor: Big thanks to RedGate and my friends on ANTS for sponsoring the feed this week! How can you find & fix your slowest .NET code? Boost the performance of your .NET application with the ANTS Performance Profiler. Find your bottleneck fast with performance data for code & queries. Try it free



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


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>