Tuesday, January 16, 2018

Reset a mydatepicker control from an Angular 4 application.

  1. Make a local reference for the control in your template and then map it to an ElementRef in your corresponding component with the ViewChild trick so that if #myDay were your local reference (put this inline inside of the my-date-picker tag) then in turn @ViewChild('myDay') myDay: ElementRef; would go somewhere inside of component itself to ensure the mapping of the control to a manhandlable variable that you may... manhandle.
  2. Figure out how you want to reset the control, perhaps upon the click of a button, and then make a method in your component for the act, you will first need this line of code.
    this.myDay.selectionDayTxt = "";
    This wipes the obvious visual setting. WebStorm 2017.1 puts a squiggly red line under this line of code indicating that it can't compile. The way around this is to make the ElementRef an any instead.
  3. Immediately following the line of code in step two above you will want to run the lines of code you run at your template in the dateChanged event for the mydatepicker which in this example are like:
    this.someDate = new Date(1753,0,1);
    this.doSomething();

Monday, January 15, 2018

pattern matching in C# 7.0

This is something else that is sevenesque. You can do some tricks with the is keyword that you might expect of the == operator as suggested here. An example:

if (o is "o") {

Tuples in C# 7.0 look kinda interesting.

Per this you may have something like this wherein (string, string) is a ValueTuple of string, string.

public (string, string) LookupName(long id)
{
   return ("John", "Doe");
}

 
 

The input variable for id obviously does nothing, right? Anyhow, an example of an assignment from the same blog posting is:

ValueTuple<string, string> c = LookupName(0);

 
 

A ValueTuple is mutable! Also, an assignment, not to a tuple, but to two variables would look like so and this trick is referred to as deconstruction.

(string first, string last) = LookupName(0);

Friday, January 12, 2018

ON DELETE CASCADE

Put this in a foreign key in T-SQL. It will allow for deleting a key that other records are dependent upon. The dependent records just get the axe too. Anarchy! This kinda goes in the place of more mundane ends to foreign keys like:

ON UPDATE NO ACTION ON DELETE NO ACTION

NUMERIC datatypes in T-SQL for unsigned numbers

A find Pinal Dave's blog some when I Google and this post in particular says: I can use NUMERIC(20) datatype for 64-bit unsigned integer value, NUMERIC(10) datatype for 32-bit unsigned integer value and NUMERIC(5) datatype for 16-bit unsigned integer value. An unsigned numeric type starts at zero and counts upwards until its cap such as uint in C# while a signed numeric types like int in both C# and T-SQL and what is Int64 in C# but bigint in T-SQL instead have a range straddling zero with half of the capacity allowing you to count downwards into negative numbers. The u in uint must stand for unsigned I guess.

a ghetto "getting started" with Bootstrap 4

Let's set up some tabs as suggested here and as I inappropriately suggest are "ARIA tabs" here like so:

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>Whatever</title>
      <link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen" />
      <link rel="stylesheet" type="text/css" href="css/bootstrap-grid.css" media="screen" />
      <link rel="stylesheet" type="text/css" href="css/bootstrap-reboot.css"
            media="screen" />
      <script src="js/utils.js" type="text/javascript"></script>
      <script src="js/tether.js" type="text/javascript"></script>
      <script src="js/jquery-3.2.1.js" type="text/javascript"></script>
      <script src="js/bootstrap.js" type="text/javascript"></script>
   </head>
   <body>
      <ul class="nav nav-tabs pull-xs-left" id="mainTabs" role="tablist">
         <li class="nav-item">
            <a id="foo-tab" data-toggle="tab" href="#foo" role="tab" aria-controls="foo"
                  aria-expanded="true" class="nav-link active">Foo</a>
         </li>
         <li class="nav-item">
            <a id="bar-tab" data-toggle="tab" href="#bar" role="tab" aria-controls="bar"
                  aria-expanded="true" class="nav-link">Bar</a>
         </li>
         <li class="nav-item">
            <a id="baz-tab" data-toggle="tab" href="#baz" role="tab" aria-controls="baz"
                  aria-expanded="true" class="nav-link">Baz</a>
         </li>
         <li class="nav-item">
            <a id="qux-tab" data-toggle="tab" href="#qux" role="tab" aria-controls="qux"
                  aria-expanded="true" class="nav-link">Qux</a>
         </li>
      </ul>
      <div class="tab-content mb-lg">
         <div id="foo" role="tabpanel" aria-labelledby="foo-tab" aria-expanded="true"
               class="tab-pane active in clearfix">
            <div id="basic-content" class="container-fluid">
               OK, now he was close
            </div>
         </div>
         <div id="bar" role="tabpanel" aria-labelledby="bar-tab" aria-expanded="false"
               class="tab-pane">
            <div id="basic-content" class="container-fluid">
               Tried to domesticate you
            </div>
         </div>
         <div id="baz" role="tabpanel" aria-labelledby="baz-tab" aria-expanded="false"
               class="tab-pane">
            <div id="basic-content" class="container-fluid">
               But you're an animal
            </div>
         </div>
         <div id="qux" role="tabpanel" aria-labelledby="qux-tab" aria-expanded="false"
               class="tab-pane">
            <div id="basic-content" class="container-fluid">
               Baby, it's in your nature
            </div>
         </div>
      </div>
   </body>
</html>

 
 

We'll end up with something like this, and this is ghetto because I do not yet know how to make that tether error go away. The tabs work however.

 
 

Let's talk through how his was done. I made a folder and I made an index.html file in it with Notepad. Then I just ran the .html file locally without any server by just double-clicking upon it. If you did web development back in the 1990s you will recall that you can just do this with plane Jane .html files. Anyways, it order for the paths into "js" and "css" folders to lead to anything there must be "js" and "css" folders sitting side by side with our index.html file. Get these by downloading Bootstrap. You will end up with "js" and "css" folders and just set them in the same folder as your index.html file. I tried to get this to work without jQuery and tether but the errors that came up to the console suggested that I needed them, so I got them too. I recommend that you download jQuery and put its one file in the "js" folder and I recommend that you download tether and put its handful of files in the "js" folder as well. That should, in a minimalistic manner, get the stuff on exposition here working. Again, I don't yet know how to get rid of the somewhat harmless tether console error that says: Uncaught SyntaxError: Identifier 'getScrollParents' has already been declared

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on local machine.

Fix this error with this download. (basically you just need the driver)