Smart Home for Newbie

If you know nothing about smart home and you want to learn about it the easy way, I will tell you how:

Just book an appointment with Amazon Smart Home Consultation.

Go to: http://amazon.com/smart and click on “Smart Home Consultation”.  I was able to schedule an in home visit the next day.

When the guy showed up, he showed me some products.  Then I was able to bombard him with questions like cost, standard, use scenarios.

My opinions include:

  • Smart homes stuff are expensive.  If you think you can reduce your monthly bill (electricity, gas, etc), you need to be creative. 
  • Smart homes may fetch you a better home selling price if done right.
  • The current 3 major players are Google Home, Apple Home Kit, Amazon Alex.
  • The lack of a universal standard makes it hard to integrate every devices easily.
  • Smart homes offer you some minor convenience, turn things (light, garage door, door, etc) on/off
  • Smart home is cool.  You can control everything in your house using voice.  The light setting, sound system, TV are all fun to play with.
  • The foundation of smart home is a wireless network that covers your whole house.  So you will need a good home wifi router or a good mesh network like Google Wifi or Eero.
  • If you want voice commands, then you can buy Amazon Echo / Dot with Alexa or Google Home.
  • Then you can get smart lights, home security stuff, TV, sounds, plugs, thermostats.
  • Note that every device likes to come with their own hub. 

How to Remove Files/Folder Older than X days in Windows using Command Prompt

Problem:

Often, we need to clean up files and folders that are older than x number of days before they eat up all the disk space.  So we need a script/command to delete the old files/folder.

Solution:

   1: @echo off

   2: :: set folder path

   3: set target_path=C:\Users\xxxx\AppData\Local\Temp

   4:  

   5: :: set min age of files and folders to delete

   6: set max_days=7

   7:  

   8: :: remove files from %target_path%

   9: forfiles -p %target_path% -m *.* -d -%max_days% -c "cmd  /c del /q @path"

  10:  

  11: :: remove sub directories from %dump_path%

  12: forfiles -p %target_path% -d -%max_days% -c "cmd /c IF @isdir == TRUE rd /S /Q @path"

 

References:

https://www.howtogeek.com/131881/how-to-delete-files-older-than-x-days-on-windows/

https://elderec.org/2012/02/scripting-delete-files-and-folders-older-than-x-days/

Amazon Chime isn’t that Charming

I have been using GotoMeeting, Webex, Hangout, and Skype for group conferencing.  So when Amazon comes out with a video conferencing tool, I am excited to try…. until I see the pricing and features.

The pros include skipping of PIN and use of different devices (mobile / desktop) for the meeting.

 

Amazon Chime is available in three editions:

  • Amazon Chime Basic allows you make 1:1 voice and video calls, and to use chat and chat rooms, on all your devices
  • Amazon Chime Plus adds the ability for you to share your screen during meetings, and enables integration with your company directory
  • Amazon Chime Pro offers the full set of features for online meetings, including scheduling and hosting meetings, recording meetings, and personalized meeting URLs, for up to 100 people.

The basic edition should be FREE.  But it offers 1:1? no screen sharing?

Sorry, that kind of video conferencing solution may attract big corporation, but it is not charming any new budget users.

Dynamics CRM 2016 Installation within Hyper-V virtual machine

When I tried to install it, I kept getting SQL Server logical consistency I/O error.

The solution:

  1. Uninstall Dynamics CRM 2016. 
  2. Delete the MSCRM databases.
  3. Install Dynamics CRM 2016 again.  This time, there should be no logical consistency I/O errors.

Cause:

I think the logical consistency I/O errors are caused by the virtual hard disk being a dynamic growing one instead of a fixed one or a pass-through one.

In fact, it is better to create a fixed size virtual hard disk for SCSI controller.  It is better for SQL hard drive performance.

Asp.Net MVC Multiple types were found that match the controller named ‘xxxx’

Problem:

I received the following error after I created a new project with a different name NewProject (with the the codes) and deployed to the same web site.

 

Multiple types were found that match the controller named ‘xxxx’. This can happen if the route that services this request (‘{id}’) does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the ‘MapRoute’ method that takes a ‘namespaces’ parameter.
The request for ‘xxxx’ has found the following matching controllers:
OldProject.WebApp.Controllers.xxxxController
NewProject.WebApp.Controllers.xxxController

 

Note:

If you rename your web app project and deploy, you may get the same error.

Solution:

It occurred because OldProject.WebApp.dll files still exist in the deploy folder “bin”.  Once I delete those old project dll files, no more errors.

ASP.NET MVC Route–If {controller} does not exist, uses a different route

Often we have a default route like the following in RouteConfig.cs:

   1: routes.MapRoute(

   2:   name: "Default",

   3:   url: "{controller}/{action}/{id}",

   4:   defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

   5: );

If you don’t have anything route before and after this, then pretty much any url will match this default route.  For example, “http://www.xxxx.com/id888

Problem

However, even though the route matches, the controller may not exist and a 404 error result.  In other words, “id888” is not a controller.  Let’s say id888 is {id}.

Now you can handle the missing controller error in code.  The catchall route does not really apply because this is not an unmatched route problem.

Solution:

You can do something more flexible, like specifying an alternative route to use if the controller is missing.

   1: // using ICP.CustomRouting extension  MapReplaceableRoute() and AlternativeRoute

   2: // The route is replaceable in the sense that if the controller does not exist, it will use specified AlternativeRoute

   3: var defaultRoute = routes.MapReplaceableRoute(

   4:     name: "Default",

   5:     url: "{controller}/{action}/{id}",

   6:     defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

   7: );

   8:  

   9:  

  10: // must come before the Default Map Route

  11: var shortUrlRoute = routes.MapRoute(

  12:     name: "Short Url",

  13:     url: "{id}",

  14:     defaults: new { controller = "L", action = "Index" }

  15: );

  16:  

  17: // specify the alternative route to use if the matched route's controller does not exist

  18: defaultRoute.AlternativeRoute = shortUrlRoute;

In summary,

  1. Downloaded the source code project
  2. Referenced it in the web app project
  3. RouteConfig.cs: add “using ICP.CustomRouting;” and code like above.

Now my controller L action Index will handle the string “id888” argument.

Also, nuget routedebugger is a great way to troubleshoot MVC routes.

Reference:

Read Siyamand’s blog post for details and code.

http://siyamand.com/using-alternative-routes-how

https://routingextension.codeplex.com/SourceControl/latest

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/

ASP.NET MVC The provided anti-forgery token was meant for a different claims-based user …

Problem:

Steps:

  1. Navigate to Login page.
  2. Login as user A
  3. Press browser’s Back button to navigate to Login page ahead.
  4. Login as user B

“the provided anti-forgery token was meant for a different claims-based user” error.

 

Solution:

One simple solution that works for me is to disable the caching of the login page.

   1: //

   2: // GET: /Account/Login

   3: [AllowAnonymous]

   4: // disable caching on login page to avoid "the provided anti-forgery token was meant for a different claims-based user"

   5: [OutputCache(NoStore = true, Location = OutputCacheLocation.None)]

   6: public ActionResult Login(string returnUrl)

   7: {

 

Reference:

http://stackoverflow.com/questions/24376800/the-back-button-and-the-anti-forgery-token