Changing password requirements in Linux Subsystem for Windows (or Bash on Ubuntu on Windows)

While I understand the reasoning, it’s a bit annoying needing to set a secondary password in the Bash on Ubuntu on Windows instance. If you’re on a domain joined computer, or occasionally update your password like you should, there’s a reasonable chance that the password you use for Bash is different than the one you use for general access to your PC. In fact, it’s probably likely.

Since I have a number of Windows boxes I frequently use, I wanted to create a password that while different from machine to machine, would be easy to remember (and not the same from machine to machine). However, the password I’d wanted to use didn’t always meet the default password requirements.

So, here’s what I did. From the Bash prompt, I first tried to change the password to see if my new password met the complexity and length requirements. If your password works, there’s no more to do!

$ passwd

Results:

(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
You must choose a longer password

OK. So, I needed to change the requirements. I used the editor nano.

$ cd /etc/pam.d/
$ sudo nano common-password

To save the file, use CTRL+O to write out changes, hit ENTER, then CTRL+X to Exit.

Look for the line:

password        [success=1 default=ignore]    obscure  pam_unix.so sha512

And replace it with (I removed obscure and added minlen=1):

password        [success=1 default=ignore]      pam_unix.so sha512 minlen=1

Now, try changing the password again using passwd.

$ passwd
Changing password for aaron.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Done.

Hopefully I’ll remember to look here the next time I set up Windows and Bash on Ubuntu on Windows (gee, that’s a mouthful!). And more importantly, I won’t encounter this experience again:

$ sudo apt-get update
[sudo] password for aaron:
Sorry, try again.
[sudo] password for aaron:
Sorry, try again.
[sudo] password for aaron:
Sorry, try again.
sudo: 3 incorrect password attempts

Ecobee’s ecobee3 Thermostat

We had 3 Nest thermostats for several years handling our 3 zone home HVAC system.

With no significant innovations since we purchased the first generation, I wanted to try something different (I’d also tried 2 Nest Protects at the same time, and they were awful in our house. False alarms. False. Alarms. And the fact that they weren’t interconnected with the other 6 smoke detectors made the over-all safety of the occupants of the house a bit less certain).

So, more than a year ago, I switched all of our thermostats to The ecobee3 smart thermostat.

One thing that the zone system didn’t do well was handle temperature differentials between various rooms in our house in a single zone. That meant that one room could be cool while another was warm for example. The ecobee3 can work with room sensors.

2016-11-18_19-36-24

2016-11-18_19-31-18Using the Follow Me mode, I can configure one zone to average the temperatures between the various sensors. This helps balance the temperature in ways that the Nest could not.

For example, right now, I’m sitting in my Office/den and the sensor reports the room temperature as 68F and occupied (which makes sense as the sensor is sitting in front of me on my desk).

2016-11-18_19-27-55

The Follow Me feature really makes the rooms, on average, more comfortable than the Nest.

2016-11-18_19-49-39

Each sensor is powered by the common button battery 2032. The batteries are supposed to last quite a while (more than a year), but I’ve had them last only 8 months.

Each thermostat has a page where you can get a quick overview of the specific details for the thermostat (and some of the household settings).

2016-11-18_19-37-07

It’s really simple to add a vacation so that the system can, without guesswork, switch to a mode that should save you some money (turning back the heating for example).

2016-11-18_19-42-27

There are a number of graphs and charts …, I don’t look at them very often, but they’re there for the curious.

2016-11-18_19-45-05

In the example above, which is the System Monitor, the orange line (in the middle) is highlighting the desired temperature in the basement. In the morning, before we use the room we’ve got some exercise equipment in, we like to make sure the temperature is at least 63F. So, there’s a brief window in the schedule where I’ve set the temperature. Then, it resumes back to normal.

As you can see, the line that goes down dramatically is the outside temperature. It was really warm in the morning and now is headed to a much colder, Northern Hemisphere cold wintry direction. Sad smile🙁

I’ve adjusted the temperatures of the floors to closely match our typical patterns and needs:

2016-11-18_19-48-29

You can also enable the Smart Home/Away feature:

2016-11-18_19-49-39

It says:

If your ecobee detects occupancy during a scheduled Away period, or detects no occupancy during a scheduled Home period, it will automatically override the schedule to maximize comfort and savings.

I’ve got that disabled because in a multi-zone house, it activates the “Home” activity settings, which I often don’t want (mostly because of how we use our house). But, for others, I could totally see it being a useful feature.

Like the nest (and some other smart thermostats), the ecobee3 learns how your HVAC system performs in various weather conditions and will adjust it’s schedule to minimize the amount of time your HVAC needs to run. That translates to: money saved. It also means that if you want the temperature to be a perfect 70F when you get home at 6pm every evening during the winter months, it will be. The furnace will have generally run the minimum amount of time necessary. You don’t need to program a “dumb” thermostat like model where you program 70F at 4:30pm and then hope that by 6pm the house will be warmed to where you want it.

2016-11-18_19-53-37

Other nice features:

  • You can use Apple HomeKit to control the thermostat, or the Amazon Echo (Alexa!).
  • It has the current weather available a single tap away.
  • The mobile app is the web app basically (but within a native app shell). So, it looks and behaves like the web version.

The few times I’ve needed a little support (like one of the sensors started to report it was “missing” frequently), ecobee responded very quickly to my support request. It was very “human” and I felt like someone on the other end actually cared. In the case of the misbehaving sensor, they sent me a new one at no-charge.

Here are the few features I’d like to see:

  • A slightly less sensitive way of manually adjusting the temperature. I don’t do it frequently, but when I do, I sometimes have trouble getting the temperature I want.
  • A nice looking wall plate to cover the space left by the traditional programmable thermostat these replaced.
  • The web app asks me to sign in way too frequently. Seriously. Remember Me should actually Remember me.

Overall, I’d recommend the ecobee3 over the Nest, especially if you want a better balanced temperature in your house rather than just the temperature at the thermostat’s location.

Tree walking and display console app in Go

I hadn’t done anything at all interesting in Go. And some might say, I still haven’t. However, I wanted to do something that I’d find occasionally useful.

On Linux, this is already available, but the the Windows version is lacking. I wanted a tiny console app that would display a tree of the directory and file structure.

So, that’s what I built. Smile

It’s one small file with one external library dependency.

I did notice that the Go packages for directory scanning like ReadDir suffer from a common issue when using the traditional Win32 APIs: they do not adequately handle file paths longer than about 250 characters. When you have NodeJS source code on your system with lots of deeply nested paths, many Windows programs fail miserably when doing file/folder management operations (Windows Explorer, I’m looking at YOU). Using the one “easy” trick of prepending the path with \\?\, you can use the APIs like ReadDir reasonably reliably. Whereas in earlier versions of my tree app it would crash, it now can handle deeply nested directory structures.

image

go get github.com/fatih/color

Customize the External VS Code Console

I have Visual Studio 2015 installed and when I launch a command prompt on Windows, it’s generally the Visual Studio 2015 Developer Command prompt (in fact, I have it pinned to my Windows 10 task bar).

image

On Windows, using Visual Studio Code 1.7+, pressing SHIFT+CTRL+C opens a Windows Command prompt from the root directory of your opened folder. It’s super useful.

I wanted the Developer Command prompt to open instead of a standard command prompt.

To change that, open the User Settings:

image

Add the following:

"terminal.external.windowsExec": "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat"

Of course, you can use other batch or command files to customize the prompt. I just wanted all of the standard developer tools I have installed to be available.

MobX and TypeScript Experiement

I wanted to give MobX a try, in particular from TypeScript.

Here’s my first attempt. I liberally used the documentation example found within createTransformer as my guide.


import "core-js";
import { observable, autorun, createTransformer } from "mobx";

/*
 The store that holds our domain: boxes and arrows
*/

class Store implements Storable {
 @observable public boxes: Box[];
 @observable public arrows: Arrow[];
 @observable public selection: any;

 constructor(init: Storable = {}) {
     this.boxes = init.boxes || [];
     this.arrows = init.arrows || [];
     this.selection = init.selection;
 }
}

interface Storable {
    boxes?: any[];
    arrows?: Arrow[];
    selection?: any;
}

interface Box {
 id: string;
 caption?: string;
}

interface Arrow {
    id: string;
    to?: Box;
    from?: Box;
}

const serializeState = createTransformer<Store, Store>(store => {
 return new Store({
     boxes: store.boxes.map(serializeBox),
     arrows: store.arrows.map(serializeArrow),
     selection: store.selection ? store.selection.id : null
 });
});

// copy using Object.assign (as this is just a simple JS object anyway)
const serializeBox = createTransformer<Box, Box>(box => Object.assign({}, box));

const serializeArrow = createTransformer<Arrow, Arrow>(arrow => {
 // or can copy manually...
 console.log("serializeArrow");  // this is only called 3 times!
 return {
     id: arrow.id,
     to: arrow.to,
     from: arrow.from
 };
});

const store = new Store();
const states: Storable[] = [];

autorun(() => {
 // this could be used to create an undo buffer, or whatever
 // probably wouldn't want infinite growth ... 🙂 
 states.push(serializeState(store));
});

const b1 = { id: "b1", caption: "Box 1" };
const b2 = { id: "b2", caption: "Box 2" };
const b3 = { id: "b3", caption: "Box 3" };
store.boxes.push(b1);
store.boxes.push(b2);
store.boxes.push(b3);

store.arrows.push({ id: "a1", from: b1, to: b2 });
store.arrows.push({ id: "a2", from: b1, to: b3 });
store.arrows.push({ id: "a3", from: b2, to: b3 });
b1.caption = "Box 1 - Edited";

// Should be 8
console.log(states.length);

b1.caption = "Box 1 - Final";

// Should be 9
console.log(states.length);

To make that work:


npm install --S mobx reflect-metadata
npm install --D @types/core-js

Sweet that MobX includes a TypeScript declarations file. 🙂

The things of interest here is that MobX assists in maintaining a stack of the object graph’s state, something that could be used for example in an undo buffer or comprehensive log system.

In this example, that’s done by using the MobX autorun functionality. When any of the dependencies of autorun changes, the function executes. In the example above, it makes a clone of the current store, using the createTransformer function, which turns a function into a reactive and memoizing function. Through memoization, it only transforms portions of the objects that have changed, not everything, every time. That doesn’t mean that you won’t want to limit the growth of the states, but you shouldn’t worry that a large complex object structure is being built with every change.

As TypeScript doesn’t support the object spread operator (which is convenient for making a clone of an object), I’ve used Object.assign instead (which may require a polyfill depending on the environment in which you use this code).