Saturday, June 13, 2020

Pagination in SQL Server (Thank you https://www.sqlshack.com/pagination-in-sql-server/)

Select TOP(100) LastName, FirstName FROM Person.Person ORDER BY LastName

DECLARE @PageNumber AS INT
DECLARE @RowsOfPage AS INT
DECLARE @SortingCol AS VARCHAR(100) ='FirstName'
DECLARE @SortType AS VARCHAR(100) = 'ASC'
SET @PageNumber=1
SET @RowsOfPage=50
SELECT LastName, FirstName FROM Person.Person
ORDER BY
CASE WHEN @SortingCol = 'Lastname' AND @SortType ='ASC' THEN LastName END ,
CASE WHEN @SortingCol = 'LastName' AND @SortType ='DESC' THEN LastName END DESC,
CASE WHEN @SortingCol = 'FirstName' AND @SortType ='ASC' THEN FirstName END ,
CASE WHEN @SortingCol = 'FirstName' AND @SortType ='DESC' THEN FirstName END DESC
OFFSET (@PageNumber-1)*@RowsOfPage ROWS
FETCH NEXT @RowsOfPage ROWS ONLY

SET @PageNumber=2
SET @RowsOfPage=50
SET @SortingCol ='LastName'
SET @SortType = 'ASC'
SELECT LastName, FirstName FROM Person.Person
ORDER BY
CASE WHEN @SortingCol = 'Lastname' AND @SortType ='ASC' THEN LastName END ,
CASE WHEN @SortingCol = 'LastName' AND @SortType ='DESC' THEN LastName END DESC,
CASE WHEN @SortingCol = 'FirstName' AND @SortType ='ASC' THEN FirstName END ,
CASE WHEN @SortingCol = 'FirstName' AND @SortType ='DESC' THEN FirstName END DESC
OFFSET (@PageNumber-1)*@RowsOfPage ROWS
FETCH NEXT @RowsOfPage ROWS ONLY

Sunday, April 26, 2020

Get Rid of Ants and other Insects and Win the War!!!

Ants (AGGGGGHHHH!!!) sugar ants,  carpenter ants, or fire ants.  At least I can identify fire ants because they are red or are they? Who knows what kind of ants.  Who cares, you just don't want them or other insects in your home.  PERIOD! 

As other homeowners know you have two choices hire an exterminator $$$$$ or do it yourself.  Well, I am here to tell you what is working for our home.

Disclaimer - Safety first, use a respirator, rubber gloves, and rubber boots.

1. Mix as instructed I did two full and an extra 1/2 squeezes to one gallon of water in a pump sprayer, fill slowly with water to get a good mix (stronger is better.  Then spray your entire home around doors, windows, foundation one foot up and two to three feet out -  

Bayer - 4031982 - Suspend SC -Insecticide - 16oz

https://amzn.to/3bYaDNG

2. Sprinkle every 4 feet around the entire perimeter of your home.

Niban Granular Insect Bait 

https://amzn.to/2YplKeA

3. Inside the house issue purchase 

Southern Homewares Pesticide Diatomaceous Earth Hand Bellows Powder Duster - Garden Powder Bulb Applicator - Great Against Bedbugs & Insects

https://amzn.to/3aXCJYb

4. Sprayer I purchased and use a sharping and mark it for safety:

Chapin 20000 1 Gallon Lawn, Sprayer

https://amzn.to/35pKnJv


REPEAT EVERY 2 MONTHS TO ENSURE MAINTAINED DEFENSE.

Sunday, December 29, 2019

Debug VS Code HTML5, CSS3 and JavaScript using npm http-server

Prerequisites tools needed:
  1. Windows 10
  2. VS Code - https://code.visualstudio.com/
  3. Node and NPM - https://www.npmjs.com/get-npm

Setup git Code repository:
  1. Setup folder for your project as for my preference I use
    C:\Users\moojjoo\Source\Repos\[SolutionFolder]
  2. I am a big advocate of git source control - https://git-scm.com/ and the great part is that it is packaged with VS Code so once you have your files setup be sure to
    1. git add .
    2. git commit -m 'Initial Commit'



// Using Terminal BASH run
npm install http-server -g
http-server ./


As a result you will get the url to run and debug your JavaScript 


// Once successfully running the code you can then create .vscode/lauch.json and 
// update the highlight code.  The great part with running npm http-server ./  
// All changes are updated and reflected in the browser
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, 
    // visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://127.0.0.1:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

Tuesday, December 17, 2019

Git exclude local developer files in exclude file

The current git workflow my development team uses and most other teams are following is to use the master branch as the default and BUILD and DEPLOY aka CI/CD branch. However, only the TEAM LEAD has the authorization rights to PULL into master. So developers create all branches from master and perform the git add [filename] or . and git commit -m 'User Story XYZ', then git push to remote and create a PULL REQUEST.
However, in this situation we have to ensure all developers have their own local configuration files and ensure they are not deployed. Better yet what happens if they were originally added and commited to the master branch? Hopefully this guide will help you.
The files in question are the .config files, which should not be ignored, but need to change per developer workstation.

WARNING --- YOU WILL HAVE ISSUES GOING BACK AND FORTH TO PREVIOUS BRANCHES THAT YOU CREATED BEFORE YOU PERFORM THESE STEPS

The key is to ensure you are on your master branch and run the following git commands.
 git checkout master

 git pull

 git status
You want to ensure you have a clean working tree...
2 Steps - If the files you want to ignore have never been added to the GIT local repository
  1. Add to the exclude file. If using windows open windows explorer and be sure to unhide hidden files and navigate to your repo location in windows we use:
    C:\Users\USERNAME\source\repos\SolutionName\.git\info\exclude
(Note: The exclude file needs to be open with a text editor of your choice Notepad or Notepad++)
The run
 git add 
  1. Add the files you need to ignore only as you do the .ignore file, but this is used for your personal developer workstation. Give the full path to the file.
    C:/Users/USERNAME/Source/Repos/SolutionName/{filename}

IF YOU ALREADY HAVE FILES THAT HAVE BEEN ADDED AND COMMITTED AS SHOWN BELOW FOLLOW THESE STEPS

ADD THE FILES To ---
 C:\Users\USERNAME\Source\repos\SolutionName\.git\info\exclude 
Following the same format as above: (Note exclude is a file you need to open with NotePad or NotePad++)
 C:/Users/USERNAME/Source/Repos/SolutionName/{filename}



git add  
git committed -m 'Committing my files to GIT index'

HOWEVER, GO BACK TO GIT AND RUN THE FOLLOWING IF THE FILES HAVE BEEN ADDED AND COMMITED BEFORE

git update-index --skip-worktree 
Reapeat as needed for the files you want to ignore.
Start branching and all should be good in the world. I will come back and provide an update based on this discovery work.
Happy GIT'ing........................
To validate you can run the following Git Command
 git ls-files -i --exclude-from=C:/Users/USERNAME/source/repos/SolutionName

Friday, September 20, 2019

Forgot your Wifi Password - Thank you Reddit

If you ever forget your WiFi password or you want to get your school WiFi password etc. Just type this command into the command line of a computer already connected to that WiFi: netsh wlan show profile WiFi-name key=clear

Wednesday, September 04, 2019

Automated test gives us greater confidence that the software is working as it should!

Tools needed for Visual Studio for proper testing with NUnit

1. NUnit3TestFramework (Core or .NET Framework)
2. NUnit3TestAdapter (Core or .NET Framework)
3. Microsoft.NET.Tests.SDK



Wednesday, August 21, 2019

MEAN - MongoDB, Express, Angular, NodeJS

MEAN Development

M - MongoDB - https://www.mongodb.com/
E -  Express - https://expressjs.com/
A - Angular - https://angular.io/
N - NodeJS - https://nodejs.org/en/

IDE of Choice - https://code.visualstudio.com/

Extensions of Choice for VS Code

- Angular Essentials
- Material Icon Theme

Open VSCODE

Ctrl + Shift + `  Opens Terminal Window

Be sure you have installed NodeJS and Angular

Command for Angular is npm install -g @angular/cli

Use the Terminal to Navigate to cd c:/Users/UserName/Source/Repos

Run

https://angular.io/cli/new  ng-new app-name


... More to come

Angular = Components and Components = Uncoupled and resuability

Always work from the ./src/app

Create new folders following the naming structure

+-app
 - app.component.css
 - app.component.html
 - app.component.ts
 - app.component.spec.ts
 - app.module.ts

For new components create new subfolders in the app folder

+-app
 |
 |
 +-my-dog
 - app.my-dog.component.css
 - app.my-dog.component.html
 - app.my-dog.component.ts
 - app.my-dog.component.spec.ts

Update the app.module.ts 


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { PostCreateComponent } from './posts/post-create/my-dog.component';

@NgModule({
declarations: [
AppComponent,
MyDog
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }