Saturday, June 29, 2019

On Wednesday Graham Francois hosted an event called "State of FED in 2019" wherein FED stands for front end development.

Things said aloud: Stencil is made by the Ionic team and allows you to use "decorators" (which are really annotations) to in turn use TypeScript but serve it to people compiled as JavaScript. HipChat is a ghetto chat client. MUMPS is NoSQL and JSONesque. It is the Vue.js philosophy that a separation of concerns is not a separation of technologies and therefore we have what we have with Vue in which the JS, the HTML, and the CSS are all jammed into one file. A lot of people who did AngularJS who were put off by how different Angular 2 was switched to Vue instead. When should you use the Redux pattern in React or Angular for that matter? When cousins in a tree of components need the same data or when you are passing down data from atop in a tree of components is when. A lot of PowerBuilder devs can only do PowerBuilder. The Lawson ERP was bought out by Infor. Ruby Gems can get pulled into scope in such a way that you cannot tell which ones are being looped in by Ruby on Rails. The slashdotting of a web site entails a better trafficked web site lending links in, giving a bounce in traffic. That's the slashdot effect. The history of architecture was run through from the old school web sites to what you might think of as Web 2.0 with some AJAX (gmail was suggested to be the first example) in the DHTML (Dynamic Hypertext Markup Language) days to modern client-side MV* implementations. OAuth and Auth0 were namedropped as canned ways to do security in modern times to make development quicker. npm is now far and away the largest open source sharing platform approaching nine hundred thousand registered packages which dwarfs Maven in second place with a third of that footprint. There was a whole React versus Angular versus Vue conversation. React is easily the most popular of the three while Angular offers the least decision paralysis. The best ideas in all three spaces get adopted in the other places. It is easy to port a React app to React Native, you just swap out the anchor links (the a tag in HTML makes anchor links to "other pages" and hypertext by definition links topics into text so this is cornerstone to HTML) to something that plays nicely in the mobile space. ParseRoller and Rollup are rivals to Webpack in the packaging space. You may specify nth number of versions of JavaScript back when you compile with Webpack, bringing in polyfills selectively, creating only the fatness you need. Webpack has the concept of loaders and anyone can make a loader to transpile TypeScript to JavaScript or something. The optional chaining proposal, a stage three proposal from TC39, is like the safe navigation operator in C#. There are a series of steps that a proposal goes through to become a part of ECMAScript with the TC39 approach to things. In stage zero, it's just an idea. In stage one it has a backer and an outlined specific way it functions. Babel support comes in stage two and browser support in stage three while stage four is ready to go. Under the hood all modern JavaScript is really a bolt-on extension to JavaScript so this allows TC39 to extend its language incrementally with proposals. There is a Vue CLI like the Angular CLI. Next.JS for React and Nuxt.JS for Vue combine the basic scaffolding of a Hello World app with some basic isomorphic scaffolding server side à la Express and Node. I wrote in my notes that SoundJS for working with audio in JavaScript is killed.

From left to right above, Drew Barette, Colin Smith, and Zach Dahl each alternated in presenting while Graham Francois moderated. All four men work at sdg (Solution Design Group) a consultancy in Golden Valley, Minnesota (i.e. the twin cities) and sdg hosted the event. It wasn't just these four guys standalone however. There was quite a bit of audience participation and much of what is above comes from that. In particular, a white guy with dreadlocks named Jason taught me a great deal in the meet-and-mix before the main theatrics. There was a smorgasbord of sources for input. Colin Smith specifically spoke to trends at the end of the session. The most interesting things he mentioned were JamStack and Svelte. The Jam in JamStack is an acronym for JavaScript APIs and Markup and JamStack as an idea has to do with serving up static content with a JavaScript engine. Gatsby is an implementation of JamStack. Jekyll was referenced as something comparable though not technically JamStack as it does not use JavaScript to do what it does. Svelte will allow you to use web components without Angular, Vue, or React where they are getting trendy. Svelte will spit out a minimized HTML and JavaScript site rendered from your web components orchestrated independent of the larger frameworks and their fatness. Colin also put some emphasis on Headless CMS which as a term seems to be akin to serverless and pointed at a trend in talking to cloud functions such as Azure functions.

DiDi offers ridesharing.

Ola is another player in the rideshare space too like Uber and Lyft.

Friday, June 28, 2019

ROLLBACK; as a standalone command in T-SQL

SET IMPLICIT_TRANSACTIONS ON turns on implicit transactions and these can wrap two back to back inserts for example. ROLLBACK; can rollback a transaction or what you might think of as an implicit transaction. See: this

Thursday, June 27, 2019

Tiny text when composing an email in Office 16 Outlook?

At the "Format Text" tab in the ribbon across a new email message I must have accidentally clicked the "Zoom" button. If you change a setting here it is retained across every time you create a new email message going forward. Go back to this button to set the zoom back to 100%.

Wednesday, June 26, 2019

Get records from a stored procedure with the database-first approach to Entity Framework.

Sort of a variant on this, we have...

public async Task<IEnumerable<IBusinessUnit>> GetBusinessUnits()
{
   var entity = await this.DbSetBusinessUnit
         .FromSql("UI.GetBusinessUnit").ToListAsync();
   return _mapper.Map<List<BusinessUnit>, List<IBusinessUnit>>(entity);
}

Tuesday, June 25, 2019

Get records from a stored procedure with Dapper while handing in a user-defined table type as a variable.

using (IDbConnection db = new SqlConnection(connectionString))
{
   DataTable scope = new DataTable("scope");
   scope.Columns.Add(new DataColumn("BusinessUnitID", typeof(int)));
   var row = scope.NewRow();
   row["BusinessUnitID"] = 13;
   scope.Rows.Add(row);
   return db.Query<BusinessUnitRecord>("UI.GetBusinessUnit", new { BusinessUnitId =
         scope.AsTableValuedParameter("dbo.BusinessUnitIDs") }, commandType:
         CommandType.StoredProcedure);
}

 
 

In this example dbo.BusinessUnitIDs may be found under "User-Defined Table Types" under "Types" under "Programmability" under the database in the "Object Explorer" in SSMS. The old school way of doing what is above in C# while merely returning a dataset is:

using (IDbConnection db = new SqlConnection(connectionString))
{
   DataTable scope = new DataTable("scope");
   scope.Columns.Add(new DataColumn("BusinessUnitID", typeof(int)));
   var row = scope.NewRow();
   row["BusinessUnitID"] = 13;
   scope.Rows.Add(row);
   db.Open();
   return db.Query("UI.GetBusinessUnit", new { BusinessUnitId =
         scope.AsTableValuedParameter("dbo.BusinessUnitIDs") }, commandType:
         CommandType.StoredProcedure);
}

 
 

In closing, as a non sequitur, I offer this picture that I took in the Mall of America today. I guess you can see the reflection of my feet. That's kinda weak.

 
 

Addendum 7/30/2019: I just today goofed off with the old school way above and could not get it to work. Perhaps something like so is better. dataTable below is what it is above.

using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
   using(SqlCommand sqlCommand = new SqlCommand())
   {
      DataSet dataSet = new DataSet();
      using(SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
      {
         sqlCommand.CommandText = "UI.GetDivision";
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.Add(dataTable);
         sqlCommand.Connection = sqlConnection;
         sqlDataAdapter.SelectCommand = sqlCommand;
         sqlDataAdapter.Fill(dataSet);
      }
   }
}

Monday, June 24, 2019

Failed to generate SSPI context.

Well, this error really just means that you can't connect to the database. In my case it was because I fat-fingered the password for the user too many times. SSPI stands for Security Support Provider Interface, the interface to connect to the MSSQL database.

How do I backup my Power BI reports?

Well, they live in the cloud at Microsoft don't they? From the Power BI desktop you publish to an app workspace. Datasets are published to the cloud and a report is really tabs/pages off of a dataset. There is no way to version the datasets at Microsoft itself and thus if you want to do something like that, you'd better save some stuff locally. In Googling against this stuff it looks like you may save the whole of your desktop environment to a .pbix file and, also, a coworker told me that you may save the datasets off to some sort of file and then recreate them from whatever those files are. The traditional channel for exposing Power BI reports to others is through a Power BI application, however, you may loop in individual reports within an iFrame in a web application, for example an Angular application, too. There are service accounts in this space that users will be associated to via Active Directory and these govern who can see what.

Sunday, June 23, 2019

reveal.js

You may make a PowerPoint presentation with reveal.js I guess. It may be touch/swipe friendly.

yet more CSS frameworks

On page 321 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis Foundation and Pure are mentioned.

chaining promises

I found this example online:

new Promise(function(resolve, reject) {
 
   setTimeout(() => resolve(1), 1000);
// (*)
 
}).then(function(result) {
// (**)
 
   alert(result);
// 1
   return result * 2;
 
}).then(function(result) {
// (***)
 
   alert(result);
// 2
   return result * 2;
 
}).then(function(result) {
 
   alert(result);
// 4
   return result * 2;
 
});

Saturday, June 22, 2019

I saw Aaron Ackerman speak on hooks at the React Minneapolis Meetup on Thursday night.

Thanks to Object Partners for hosting. Before Aaron Ackerman spoke, I learned a few things in just mingling with another there. Apparently there is a smartphone app for meetup.com that allows you to search meetups by topic. He was also telling me about a server for Postgres at the Mac which kind of sounded like post-it-go in name, but likely what was meant was Postgres with Go. Material-UI is a UI framework for React as are React DnD (DnD for drag and drop) or maybe react-drag-and-drop and furthermore also thirdly react-beautiful-dnd. Aaron himself namedropped Genesis components as a forerunner to hooks, ESLint as a linter (a tool that flags errors both stylistic and much more literal errors), and Enzyme for testing React rendering while utilizing CodeSandbox (at codesandbox.io) for all of his presentation as the IDE. React version 16.8.0 and version 3 of the Create React App were the first places one could use hooks, but that said they are downwards compatible and you should be able to get them working in older stuff yet. Hooks are an opt-in and thus you may use them or not use them. The number of hooks used through a potential path through your app has to be consistent without regard to the path and you cannot nest hooks in if/then logic. As of 16.8.0 there are five built-in hooks and the whole of this talk entailed talking through them. useState was on exposition first and Aaron showed us a class component using setState and contrasted it with a functional component using useState which had half the lines of code. Both setState and useState were touched on somewhat in a training I had (I don't know React yet) as denoted here, and, as suggested here, the big difference between class and functional components in React is that the class components use the ES6 class keyword and extend Component imported from the 'react' base source while functional components are just functions. As best as I can tell both setState and useState are for altering what is in the store in the Redux shape of things. useContext is a solution to the problem of explicitly handing something down a tree of deeply nested components from top to bottom. Historically, context consumers and render props can create a pyramid of doom in these scenarios. No more! useReducer like useState takes in both state and an action and undertakes the sort of writes you might expect of reducers in the Redux pattern. The thing that is different here however is that useReducer is not putting stuff in the store. useReducer is sort of tucking stuff away in a component level store. useEffect is also Redux-flavored. This gives you a way to call out an API to get some data. It is meant for data fetching and will run when the component is mounted at the DOM. You may return a teardown function from useEffect to deal with what happens when the data actually returns. An oddity here is that useEffect runs synchronously (to avoid race conditions) so the teardown function is not a callback/promise. It made me think instead of the Dispose method on types which implement IDisposable in C# though it would tend to be used a bit differently obviously. ESLint will warn you when using the async keyword in useEffect. useRef is the last of the five. Refs are used in React to grab ahold of DOM elements and they have had a four phase history which I will detail while focusing on the bookends of history. Phase one in the early, early days was very jQueryesque. Aaron's example, as seen in the photo here, was:

import React from 'react';
import ReactDOM from 'react-dom';
 
class App extends React.Component {
   componentDidMount() {
      console.log(this.refs.container);
   }
 
   render() {
      return <div ref="container">hello</div>;
   }
}
 
let rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

 

 

Later, it was more in style to pass a function to a ref prop that runs when the component mounts. That is the second phase in our history, and the third has us using React.createRef(); At some point, we have to get into hooks and useRef correct? Yes, that is the last of the four approaches and the most modern way to go. Aaron offered up:

import React, { useRef } from 'react';
import ReactDOM from 'react-dom';
 
function TextInputWithFocusButton() {
   const inputEl = useRef(null);
   const onButtonClick = () => {
      
// 'current' points to the mounted text input element
      inputEl.current.focus();
   };
   return {
      <>
         <input ref={inputEl} type="text" />
         <button onClick={onButtonClick}>Focus the input</button>
      </>
   };
}
 
let rootElement = document.getElementById("root");
ReactDOM.render(<TextInputWithFocusButton />, rootElement);

 

 

Aaron's setState at a class component example:

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
 
class Counter extends Component {
   constructor(props) {
      super(props);
      this.state = { count: 0 };
   }
   render() {
      return {
         <div
            onClick={() => {
               this.setState({ count: this.state.count + 1 });
            }}
         >
            {this.state.count}
         </div>
      };
   }
}
 
let rootElement = document.getElementById("root");
ReactDOM.render(<Counter />, rootElement);

 

 

Aaron's useState at a functional component example:

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
 
let Counter = () => {
   let [count, setCount] = useState(0);
   return <div onClick={() => setCount(count + 1)}>{count}</div>
};
 
let rootElement = document.getElementById("root");
ReactDOM.render(<Counter />, rootElement);

Friday, June 21, 2019

With the "Split Editor Right" icon in Visual Studio Code 1.35.1 you can view two files side by side.

It's at the upper right corner and it looks like a window split down the middle. Pressing Ctrl and the backslash at once is the hotkey. It will put your current tab into a right-side split. Then you may just change tabs at the left-side split. Click on the three dots in a horizontal row at the upper right of the right-side split and pick "Close All" to get rid of the right-side split. Ctrl-K followed by Ctrl-W is the hotkey.

Thursday, June 20, 2019

The Azure/Octopus paradigm is making it too easy to add yet another gate where yet another approver has to sign off in my opinion.

There are a lot of chokepoints in this space. The art of always needing someone to approve a pull request for every commit leads to some hacky horseplay in which pull requests are just ceremonially approved without even a look over as everyone is frustrated with the overemphasis on process and numb to it. Also the ability to loop in another team for oversight for approvals in as granular a level as schema and permissions changes at a Visual Studio Database project but not, for example, stored procedure changes empowers just that leading to too many cooks in the kitchen and a slowness in getting anything done. You may make a Rube Goldberg machine to roll your code out with.

Wednesday, June 19, 2019

the lowercase letter a denotes AM and PM in Angular DatePipe's formatting and not the tt

The rest of the formatting so far is akin to what I am used to in C#. See this for more.

Keep a hunk of text from being something that you may highlight/select in HTML.

Jam this inline in the HTML tag wrapping the text:

style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none;
      user-select:none;-o-user-select:none;" unselectable="on"
      onselectstart="return false;" onmousedown="return false;"

A man-month is a hypothetical unit of work denoting the amount of work a man can theoretically do in a month's time.

This is fuzzy to being with and Fred Brooks argues in The Mythical Man Month, his book, that it is a myth that paths to success may be gauged with this junk metric in a helpful way. This is not the main takeaway from the book, but instead I mention it as I wondered today what the name meant.

IstanbulJS

...another JavaScript testing tool. See: this

Tuesday, June 18, 2019

The offset seems to be what I need in the HTML5 draggable API.

Instead of screenX, screenY, clientX, and clientY as suggested here, offsetX and offsetY will tell you how deep you are in the object in startDrag and how far you moved in endDrag. Moving up or left gets denoted by a negative number. This can be superior to simple X and Y values for where you are in the browser at both events and especially so if the items to be drug sit inside something scrollable. You can probably just use the endDrag value in lieu of some sort of mathematic calculation with startDrag and endDrag settings to figure out what's what.

Getsetters (well, auto-properties) at an interface will allow you to map records to the interface in an Entity Framework Database-first implementation like the interface was a POCO.

The getsetters (well, auto-properties) at the interface just look like the getsetters at a POCO without the leading accessibility modifier obviously as you can't have those in a C# interface. For an Entity Framework example see this.

Bring back the kind of Observable of an Array that you may carry into an Angular 7 component template and use with the async pipe from the HttpClient in the '@angular/common/http' npm package.

HttpHeaders is in '@angular/common/http' too:

public GetFoo():Observable<Array<Foo>> {
   let token:string = this.activeDirectoryContract.GetAccessToken();
   let header = new HttpHeaders().set('Authorization', 'Bearer ' + token);
   return this.httpClient.get<Array<Foo>>(environment.apiUrl + "foo",
         { headers: header });
}

Xtreme Performance System is what the XPS in Dell XPS stands for.

I have an XPS laptop from back in 2013 that is still my mainstay at my home.

Monday, June 17, 2019

Can't seem to use the ALTER keyword at a stored procedure in a Visual Studio database project?

You may see something like...

The statement is not recognized in this context.

 
 

...when you move your cursor over the keyword in Visual Studio 2019. The way this stuff works, you will just universally use CREATE for the file the denotes a stored procedure and also a table for that matter.

Friday, June 14, 2019

Instagram Filters

These are a staple of the app! You can put flowers around your face and stuff like that. You can make your photo look like an old 1970s photo with washed out colors. What's not to like? I made this screengrab off of Instagram while driving home from work yesterday. I was stopped in traffic. I promise. Also yesterday it was announced that Sarah Sanders will no longer be President Donald Trump's press secretary. I kind of look like her here with the frumpy frown on my face, huh? I just need a wig of long brown hair to complete my Halloween costume this year.

Set up the database-first approach to Entity Framework in a .NET Core application?

This isn't my code. It is a coworker's. I cannot guarantee that I'm not missing something. Into this Startup.cs let's loop in AutoMapper at the last line of the ConfigureServices method like so:

services.AddAutoMapper(typeof(Startup));

 
 

Next we are going to add the following two lines just inside of the ConfigureIoC method:

var connect = Configuration["MyConnectionString"];
services.AddDbContextPool<MyDbContext>(options => options.UseSqlServer(connect));

 
 

What is MyDbContext? Let's define that.

using Microsoft.EntityFrameworkCore;
using Trifecta.Infrastructure.Entities;
namespace Trifecta.Infrastructure.DBContext
{
   public class MyDbContext : DbContext
   {
      public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) { }
      
      public virtual DbSet<BusinessUnit> BusinessUnits { get; set; }
      public virtual DbSet<FileUpload> FileUploads { get; set; }
      
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
         modelBuilder.Entity<BusinessUnit>().ToTable("BusinessUnit");
         modelBuilder.Entity<FileUpload>().ToTable("FileUpload", "Other");
      }
   }
}

 
 

"Other" above shows off how to access a schema other than dbo. Use this stuff in a repository like so:

namespace Trifecta.Infrastructure.ExternalDependencies.Repositories
{
   public class BusinessUnitRepository : IBusinessUnitRepository
   {
      protected DbContext Context { get; private set; }
      protected IMapper _mapper { get; private set; }
      private DbSet<BusinessUnit> DbSetBusinessUnit{ get; set; }
      
      public BusinessUnitRepository(IMapper mapper, MyDbContext dbContext)
      {
         this.Context = dbContext;
         this._mapper = mapper;
      
         this.DbSetBusinessUnit = this.Context.Set<BusinessUnit>();
      }
      
      public async Task<IEnumerable<IBusinessUnit>> GetBusinessUnits(params object[]
            parameters)
      {
         var entity = await this.DbSetBusinessUnit.ToListAsync();
      
         return _mapper.Map<List<BusinessUnit>, List<IBusinessUnit>>(entity);
      }

 
 

How does something which takes IMapper at its signature find the AutoMapper.Profile for a map? It seems like magic to me? Maybe some service locator wackiness is going on within the AutoMapper library.

DACPAC

I guess the acronym stands for Data-tier Application Package. You may save an MSSQL database into a .dacpac file and another DBA may recreate the database from the file.

Thursday, June 13, 2019

Loop in NgRx effects at a module in an Angular 7 application.

In order for an effect to pick up on the action that triggers it being newed up, it has to be looped into scope at the module governoring the component where this.store.select and/or this.store.dispatch gets called. For this example we need this example:

import { NgModule } from '@angular/core';
import { BusinessUnitRecordsComponent } from '../components/business-unit
      -records.component';
import { BusinessUnitRecordsAuthenticatedComponent } from '../components/business
      -unit-records-authenticated.component';
import { BusinessUnitRecordsUnauthorizedComponent } from '../components/business
      -unit-records-unauthorized.component';
import { BusinessUnitRecordsRoutingModule } from './business-unit-records
      -routing.module';
import { BusinessUnitRecordsContract } from '../contracts/business-unit
      -records.contract';
import { BusinessUnitRecordsService } from '../services/business-unit-records.service';
import { LoggingContract } from '../contracts/logging.contract';
import { LoggingService } from '../services/logging.service';
import { HttpModule } from '@angular/http';
import { CommonModule} from '@angular/common';
import { JumbotronModule } from './jumbotron.module';
import { BusinessUnitRecordEffects } from '../state-management/effects/business-unit
      -record.effect';
import { EffectsModule } from '@ngrx/effects';
@NgModule({
   declarations: [
      BusinessUnitRecordsComponent,
      BusinessUnitRecordsAuthenticatedComponent,
      BusinessUnitRecordsUnauthorizedComponent
   ],
   imports: [
      BusinessUnitRecordsRoutingModule,
      CommonModule,
      HttpModule,
      JumbotronModule,
      EffectsModule.forRoot([
         BusinessUnitRecordEffects
      ]),
   ],
   providers: [
      BusinessUnitRecordEffects,
      { provide: BusinessUnitRecordsContract, useClass: BusinessUnitRecordsService },
      { provide: LoggingContract, useClass: LoggingService }
   ],
   bootstrap: [BusinessUnitRecordsComponent]
})
export class BusinessUnitRecordsModule { }

AutoMapper mappings up in the UI project!

Yes, this is a thing. I'm not in love with it but I've seen it in two different projects now. The reason you have to go there in an onion architecture setup is that you want to map from a type that is only in the infrastructure project to a type in the core project that doesn't know about the infrastructure's type. Don't do this. Put the type you want to hydrate from a database call in the core and if you have to map it some something else in the core you may keep the whole of the mapping in the core. If you are having core objects hydrate DTOs for the UI, why can't the DTOs also just be in the core? The original idea behind the onion architecture was to make the core as fat as possible. When stuff bleeds out to other layers I wince/cringe. Anything that is plain Jane C# should be a candidate for core citizenship and really only external dependencies, UI machinery, exposed UI endpoints, and unit tests should ever live in other layers.

HPC is high performance computing.

It's an aggregation of computer power from multiple sources.

Wednesday, June 12, 2019

Give a user a role in T-SQL!

EXECUTE sp_addrolemember @rolename = N'db_datareader',
      @membername = N'YIN\Yang';

Tuesday, June 11, 2019

.Condition in AutoMapper seems to both specify the field to map from while also denoting a condition for whether to map at all versus leaving the field-to-be null.

This had this example:

.ForMember(dest => dest.ItemQuantity, act => act.Condition(src => (src.Quantity > 0)))

The variable at the verb attribute at a .NET Core controller action could just be a further piece of the route!

This...

[HttpPut("{id}")]

 
 

...or this...

[HttpDelete]
[Route("{id}")]

 
 

...are legit, but you don't have to pass a variable in a forward slash seperated chunk of the route. You can just make the route one chunk longer like so:

[HttpGet("SomethingErOther")]

Make a triangle in CSS!

This has the following example.

.arrow-right {
   width: 0;
   height: 0;
   border-top: 60px solid transparent;
   border-bottom: 60px solid transparent;
   border-left: 60px solid green;
}

 
 

Basically you spec a left, right, top, or bottom border to give a color to. If you spec left or right you need a transparent border for the top and the bottom and if you specify top or bottom you need a transparent border for the left and the right.

Monday, June 10, 2019

The IIS web server is not installed on this computer. Use Programs and Features to turn on this Windows component.

Fix this with this and not by following the instruction suggested.

The lower right corner of Visual Studio 2019 will reveal the branch being used at Git.

If you have two shell windows open and one of them is old, this may help you determine which one to close.

Business Systems Analyst or BSA

He/she is like a technical BA.

If we an architecture of stored procedures, why not also introduce Database-first Entity Framework?

  1. Whenever a sproc is called for CRUD functionality it should be logged and we would have to roll our own logging if we are sidestepping the sprocs.
  2. When we face a security audit we would have to argue our case for why our database interactions are secure whilst instead the security of the sprocs would be unburdened from us and on the DBA's shoulders.
  3. A hodgepodge will be confusing.

reverse history search

I saw some mention of this on Twitter this morning. Instead of using the up arrow to go back through past commands at a shell there is, it would seem, a way to search the history. See this.

Sunday, June 9, 2019

I saw Mark Kalal speak on ML.NET at the Twin Cities .NET User Group on Thursday night.

Microsoft.ML is the NuGet package to get for a Visual Studio 2019 project, but independent of that the ML.NET Model Builder is a pretty good thing to download from here. Once you have it, you may right-click on a project in Visual Studio 2019 and pick "Add" and then "Machine Learning" from beneath the "Add" to loop in some of the wonders we are about to discuss. This was the second tech talk I had seen on machine learning after this one (touched on supervised learning which breaks into classification and regression) and naturally there was some overlap. I will try to focus on what was new in what is ahead. Unsupervised learning breaks into clustering (Have you seen the film Rangasthalam?) and association (Have you seen the films Rangasthalam and A Quiet Place both?) and Netflix uses this to profile you and make recommendations. Reinforcement learning gets into positive and negative reinforcement. For example, Arthur Samuel came up with the term machine learning in attempting to build the perfect checkers player who learned from experience. His actor would learn from positive and negative reinforcement. If you want to build something like conceptnet.io (helps computers understand the semantics of English words), or a spam filter for email, or something like Facebook's facial recognition, there are a few tools available to you. Keras, TensorFlow (supports Nvidia cards, GPUs, and also even TPUs or tensor processing units for hardware-specific to machine learning), Microsoft Cognitive Services, Weka in the Java space, MathWorks, Prophet, Python which has about 90% of the pie of what has been baked in the machine learning space, and, yes, ML.NET which is what we care about. Let us say, in a simple example, that we want to write a program that makes sense of images of fruits and categorizes them. Well, we could maybe tell an apple and a banana apart by matching on the color red for an apple and the color yellow for a banana, right? What if the apple is green and we have an unripe green banana in a different image though? Rules pick up exceptions, and more rules, and soon you have to try to have an algorithm. The good news is, that once data starts to pick up in volume the various algorithms you try tend to become equal in their ability to predict. I'm sure there are some exceptions to this case in that an algorithm probably needs to be "legit" but assuming that it is it will eventually take you to the same place all of the competent rivals do. Volume (think big data) is one of three traits of your inputs for your algorithms to put attention to with the others being velocity and variety. In the case of velocity be wary of shoving in data faster than you can process it. ONNX, which is pronounced like onyx and stands for open neural network exchange, is a file format standard for the machine learning space. 90% of all of the data that humanity has gathered digitally has been collected in the past two years, so the big data space is blossoming now. data.gov and data.worldbank.org are go-to spots. Some POCO code for a Fruit that was expositioned looked like so:

public class Fruit
{
   [LoadColumn(0)]
   public string Color { get; set; }
   
   [LoadColumn(1)]
   public string Size { get; set; }
   
   [LoadColumn(2)]
   public string Class { get; set; }
}

 
 

We will try to get a FruitPrediction for each Fruit and a FruitPrediction looks like this:

public class FruitPrediction
{
   [ColumnName("PredictedLabel")]
   public string Class;
}

 
 

The following code was showed off by Mark Kalal in an attempt to get predictions. I took pictures of it with my phone and some of it got cut off. This code was a procedural blob inside of a method in a C# console application.

MLContext mlContext;
string trainDataPath = "c:\\dev\\Data\\fruit.csv";
PredictionEngine<Fruit, FruitPrediction> predEngine;
ITransformer trainedModel;
IDataView trainingDataView;
 
mlContext = new MLContext();
 
trainingDataView = mlContext.Data.LoadFromTextFile<Fruit>(trainDataPath, hasHeader: true, separatorChar
...
 
var pipeline = mlContext.Transforms.Conversion.MapValueToKey(inputColumnName: "Class", outputColumnName
...
   .Append(mlContext.Transforms.Text.FeaturizeText(inputColumnName: "Color",
         outputColumnNa
...
   .Append(mlContext.Transforms.Text.FeaturizeText(inputColumnName: "Size",
         outputColumnNam
...
   .Append(mlContext.Transforms.Concatenate("Features", "ColorFeaturized",
         "SizeFeaturized"
...
 
var trainingPipeline = pipeline.Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordi
...
   .Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
 
trainedModel = trainingPipeline.Fit(trainingDataView);
 
Fruit singleIssue = new Fruit() { Color = "2", Size = "3" };
predEngine = trainedModel.CreatePredictionEngine<Fruit, FruitPrediction>(mlContext);
 
var prediction = predEngine.Predict(singleIssue);
Console.WriteLine("Prediction - Result: " + prediction.Class);

 
 

MLContext sounds alot like DBContext, huh? Ha ha. Microsoft names...

Friday, June 7, 2019

Genesis10 will train you for ten weeks to be a developer before placing you in a contract-to-direct role.

This is first consultancy that I've encountered that takes such a risk. This speaks heavily to the strength of the market. I can attest that every junior hand I run into looking for an entry level post isn't looking for long and that includes individuals who have no more than something like Prime Digital Academy under their belt. You will be paid to take the Dev10 program however instead of having to pay out to Prime. I'm sure there is some selective screening to determine what makes for a competent person who can/could code. If you don't want to ramp up freshmen talent perhaps Genesis10 can for you.

Thursday, June 6, 2019

How do I open a .csv file with a different delimiter, such as tabs instead of commas, in Excel?

Go to the "Data" ribbon and pick "Get Data" from the ribbon. Browse to your file from here. There will be a little wizard to walk through wherein you may change the delimiter. Very likely the appropriate delimiter will be defaulted to in this process.

Stadia

This is Google's Xbox. It is cloud-based.

Wednesday, June 5, 2019

How can I tell what the latest version number of an Azure DevOps project is without pulling the source code?

Well, really this is in Octopus, assuming you rollout with Octopus. Go to "Pipelines" in Azure DevOps. Pick the pipeline for the project and click "Edit" at the upper right. Then go to the "Variables" tab to figure out what the name of the Octopus project is. Get into the project in Octopus. Pick "Overview" at the left navigation at the project to see what the version number of the latest release is.

How may I get the User.Identity.Name that I am used to getting in a .NET Core controller from an ExceptionContext?

string name = context?.HttpContext?.User?.Identity?.Name;

If you follow my whole Middleware for logging and catching exceptions paradigm as suggested here you may want to log who the user at hand is as part of your record writing. This should help with that.

adal.js race condition

It is possible to have a token from adal.js in an Angular application but for User.Identity.Name in a .NET Core controller to be null. I don't yet understand how. It's best to wrap User.Identity.Name in a null check before using it on the C# side.

How may I tell if a user is in a group at a database in SSMS?

Well, if it is in any group it will show up in the "Users" under the database under "Security" at the Object Explorer. From there, right-click on a user and pick "Properties" and then visit the "Membership" link at the upper left of the dialog box that appears.

Tuesday, June 4, 2019

Devlicio.us was some exclusive, ritzy club for .NET talent like Los Techies.

I guess it died.

Increment or reset the version number in a Visual Studio 2019 SQL Server Database Project.

  1. right-click on the project in the Solution Explorer and pick "Properties"
  2. click on the "Project Settings" tab
  3. click on the "Properties..." button

The name of a server hosting a database in SSMS may also be referred to as the "instance name" too.

You see these in Object Explorer, right?

Set Auto-Complete for a pull request in Azure DevOps.

Click the big blue button at the upper right that says "Set Auto-Complete" as suggested here.

Use environment-specific variables in a Visual Studio 2019 SQL Server Database Project for breakouts for development, UAT, and production.

Maybe the same user shouldn't be the God user in all three environments. That's fair. Here is what to do:

  1. right-click on the project in the Solution Explorer and pick "Properties"
  2. click on the "SQLCMD Variables" tab
  3. Add a variable here with a default value. The variable name should be wrapped in parenthesis with a leading dollar sign like so:
    $(yournamehere)
    The convention of the leading dollar sign leading into a variable in parenthesis will be honored throughout your .sql files in the Visual Studio project even though in the strictest sense that really wouldn't mean anything elsewhere in T-SQL.
  4. How do I use a variable with a setting other than the default? you ask. Great question! Under the "_Publish" folder, right-click on one of the .xml files for the publish settings for a given environment and pick " Open With..." followed by "XML (Text) Editor" to see a swath of XML. You'll customize up the ending like so:
       </PropertyGroup>
       <ItemGroup>
          <SqlCmdVariable Include="yournamehere">
             <Value>TomJaeschke</Value>
          </SqlCmdVariable>
          <SqlCmdVariable Include="environment">
             <Value>TEST</Value>
          </SqlCmdVariable>
       </ItemGroup>
    </Project>

Update your status in Skype!

It's at that cartoon caption above your avatar at the main interface. An arrow from there points down at your avatar as if your avatar is saying something. Get it?

There is some RedGate Comparesque tooling in Visual Studio 2019 for working with SQL Server Database Projects.

  1. Under "Tools" pick "SQL Server" and under "SQL Server" pick "New Schema Comparison..." while you notice that "New Data Comparison..." is a thing too.
  2. Next you may pick a source and a target.
  3. Click the "Compare" button at the upper left to compare. You may compare an actual database to what is in your project to see if anyone manually added anything.
  4. Click the "Update" button at the upper left to push tables or sprocs or whatever from one place to another. You'll be able to check and uncheck checkboxes for what is in scope for a move over.

Google, the search engine, is banned in China.

Google Chrome, the browser, is not, but it may be a bit tricky (or at least trickier) getting Chrome to your users without Google the web site.

When don't I want relational data?

The people who would sing the praises of NoSQL will tell you that it is snappier than SQL, more performant. Certainly the joins in T-SQL are where the expense tends to lie in a given query, and solutions like SOLR (Searching On Lucene w/Replication, the replication part being a slave/master distributed server setup) are sidestepping the relational part of a relational database and offering you up one big flat table in the name of snappy search and I suppose there is a place for that in the NoSQL place too as suggested here, but when would I ever want an application to be end-to-end in NoSQL as opposed to just using NoSQL around the edges a little bit? When wouldn't I want relational data whatsoever? The interviewing process at @hand had one show off an application they authored. One of the guys they interviewed while I was there had an app in NoSQL and afterwards Bryan Harclerode criticized the guy for grabbing a bunch of objects in one "query" and then getting the keys for another object off of those objects and looking up the relating objects with the keys. When I asked him what that kid should have done with MongoDB instead the response was that you shouldn't use Mongo if you need relational data! When would I not be in this situation when baking out an application however? Even if I started out not needing it, what if I need it eventually? In a rolodex app in which people have addresses and it is possible for two people two have the same address would address just hang off of each person with dupes existing and would I always look for addresses through people as the front door? Always? Really? I've never been on a NoSQL project. In my job adventurers it just hasn't come up, not in a decade of NoSQL existence. People expect T-SQL of me. I can see why.

Monday, June 3, 2019

Edge versus Internet Explorer

There is not one or the other as I had thought as I confused the two. At Windows 10 you'll have both. IE will probably be better advertised with a desktop icon or an icon at the taskbar across the base of the screen. You may find Edge by typing "Edge" at the "Type here to search" however.

A div which is rotated in CSS will sit atop everything else without regard to any z-index settings.

At least in Google Chrome, this is so.

Saturday, June 1, 2019

The last thing I will say about the Norwegian Developers Conference is that Troy Hunt gave the keynote: Hack to the Future

Have I Been Pwned? is a website that allows you to check to see what websites wherein there was a data breach your password was used at. They know because a lot of the lists of the compromised are just published after the breaching. Ashley Madison is a classic example of how to embarrass someone along these lines. Some of this talk, which you probably have guessed by now was security-flavored, went into the history of passwords and some of the things that have gone wrong with them. Password complexity rules that are too complex really get in the way. Hackers know that you are replacing O or o with 0 and they can guess at your own common hacks to satisfy complexity requirements. Forcing users to change their password every few months also comes with some dysfunction. It creates a scenario in which users are just changing a number at the end of their password so that they may keep it in their head. The ugly alternative is to write down passwords that have really changed in order to "remember" them. What's worse? Instead companies should really ask individuals to change their passwords upon suspicion of compromise per Troy Hunt. An overabundance of faith is placed in https. Let's Encrypt now offers free SSL and its footprint is overtaking that of Comodo (now Sectigo) which had been the heavyweight in the space. Unfortunately, the Let's Encrypt freeness empowers https phishing sites. In an IDN (internationalized domain name) homograph attack one offers a domain name that looks like a legit one with just a character or two changed up along these lines. CREST (The Council of Registered Ethical Security Testers) certified industry professionals are good characters to pen test products to see what the vulnerabilities are. Some of the talk went into these guys just trying to do their jobs and some of the ridiculous pushback and vilification they get from the marketing departments of those they "embarrass" by pointing out holes. At the very end of the presentation Troy closed with a slide of a padlock with a screw visible on one side of it which could easily be undermined with a screwdriver. The public relations pushback to the obvious criticism was that the padlock was invincible to anyone without a screwdriver. That's a not technical example, but the technical examples can be just as bad with a bit of obfuscation too as average Joe is unlikely to know that the counterarguments are bogus. Some of the wacky products that were showed off were the Gator which was a smartwatch for parents to give kids that gave you the ability to phone call your child on the watch. The watch is hackable and it's not hard for anyone to call your child! The Nissan Leaf came with a smartphone app that allowed you to control the heater and air conditioner in your car. It also allowed hackers to control it too.

Embedded Power BI reports in an iFrame can misbehave in Internet Explorer.

It is happening in our application as we have two differing approaches to active directory as described here forcing users to log in the first time they see an iFrame within a Power BI report. It works great in Google Chrome and not so great in Internet Explorer. Something in the Internet Explorer setting is forcing the report beyond the bounds of the iFrame to take over the whole of the browser tab in sort of a redirect. Our pointman for the reports just tells me that Microsoft tells him not to use IE.

the absence of full stack development and what that means in terms of bottlenecks

What if you are only allowed to work on the Angular app that rides atop a ReST API and the ReST API isn't ready yet? You're going to be waiting around some, aren't you?

I saw Jonathan Mills speak at the Norwegian Developers Conference on functional style JavaScript.

Scala and Elm are real functional programming languages. MUMPS (Massachusetts General Hospital Utility Multi-Programming System) however is how Jonathan Mills got started. Terraform may be used with Kubernetes orchestrations to expose resources via a ReSTful API. It might be a mistake to go learn Blazor just like you learned Silverlight. JavaScript is the new normal. Let's embrace it, not rebel. Functions are first class citizens in functional programming. In a computer science sense, functional programming is a style of building a structure that treats computation as the evaluation of mathematical functions. For functional programming in JavaScript, avoid changing state and mutable data. Nothing is immutable in JavaScript. Even when you use Object.freeze() you are not really locking things down, however, we still gotta try. Why do we want immutablity as opposed to just changing things under the hood? Immutability curtails poisonous references to other things that can come back to bite you in all sorts of unforeseen, hard-to-troubleshoot ways and it forces you to decide what to do with the output. In currying in JavaScript something like so:

let sum = add(a,b);

 
 

Becomes:

let sum = add(a)(b);

 
 

It's split into a series of functions. Cockford's Law is "Once you understand Monads, you can no longer explain them to someone who does not..." What if I could wrap everything up in a protective case and then warp it with functions? That design pattern leads to The Identity Monad which is the simplest of all monads.

function Identity(value) {
   this.value = value;
}
 
var x = new Identity(5);
 
console.log(x.value);