Skip to content

Instantly share code, notes, and snippets.

View ChrisMoney's full-sized avatar

Chris Weathers ChrisMoney

  • Onevested
  • St. Louis, MO
View GitHub Profile
@ChrisMoney
ChrisMoney / PartitionDB.sql
Created March 14, 2025 00:02
Partition sql database code
--///////////////////////////////////////////////
-- TRIAGE
--/////////////////////////////////////////////
-- Check table sizes
SELECT t.name AS TableName, SUM(p.rows) AS RowCounts
FROM sys.tables AS t
INNER JOIN sys.partitions AS p ON t.object_id = p.object_id
WHERE p.index_id IN (0,1) -- Heap or Clustered Index
GROUP BY t.name
@ChrisMoney
ChrisMoney / jsCallController.js
Created February 11, 2025 14:21
Call .NET MVC Core Controller from JS Ajax plus store and display success message after page reload
MVC-Razor AJAX
// AJAX calls .NET MVC Core Controller
// Stores success message and fetches it to display once page is updated
function confirmTransferAction(event) {
// console.log("@Url.Action("UpdateAccountEmail", "CustomerProfiles")");
var id = document.getElementById('adminId').value;
var email = document.getElementById('newEmail').value;
@ChrisMoney
ChrisMoney / RenameProc.sql
Created December 2, 2024 17:45
Rename Stored Proc
USE [Database_Name] GO --
Check if the procedure exists before renaming
IF OBJECT_ID('dbo.AdminReportsStaples', 'P') IS NOT NULL
BEGIN
EXEC sp_rename 'dbo.AdminReportsStaples', 'AdminReportsRevenue'
END
ELSE
BEGIN
PRINT 'Procedure dbo.AdminReportsStaples does not exist.'
END
@ChrisMoney
ChrisMoney / pointer.cs
Created September 7, 2024 17:42
Replicating C Pointer in C#
// 1) 'ref'
// ref keyword means "pass by reference" - edits
// made in this function affect the actual variable
int someNum = 5;
AddOne(ref someNum);
// someNum now = 6
void AddOne(ref int i)
{
@ChrisMoney
ChrisMoney / gitCreds.git
Created July 16, 2024 12:33
Git Global Credential Configuration
Save the username and password globally:
git config --global user.name "fname lname"
git config --global user.email "[email protected]"
git config --global user.password "secret"
Get a specific setting,
git config --global --get user.name
git config --global --get user.email
git config --global --get user.password
@ChrisMoney
ChrisMoney / DBContext.cs
Created July 9, 2024 12:40
Entity Framework DBContext Injection occurs at application entry point, typically Main.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using AdamsTaxAPI.Data;
using AdamsTaxAPI.Data.MagentoServiceCalls;
using AdamsTaxAPI.Models;
using AdamsTaxAPI.Controllers;
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using Aczure.Extensions.AspNetCore.Configuration.Secrets;
using Reni.SshNet.Sftp;
@ChrisMoney
ChrisMoney / dapperParamList.cs
Last active June 25, 2024 14:54
Dapper Key Value Parameter List
var dapperParams = new List<KeyValuePair<object, object>>() {
new KeyValuePair<string, string>("FirstName", "Chris"),
new KeyValuePair<string, string>("LastName", "Money"),
new KeyValuePair<string, string>("Phone", "314-555-1212"),
new KeyValuePair<string, string>("SSN", "123-45-6789"),
new KeyValuePair<string, int>("Age", 21)
};
connection.Query<Person>(query, new {dapperParams});
@ChrisMoney
ChrisMoney / N-Tier.txt
Created June 25, 2024 14:37
N-Tier Design
UI: UI files driven by Factory methods
Helper: Wrapper methods that handle misc. functions
API: API calls envoked at the factory level
Factory/Business: Handles SQL Connections, santizes data before handing off to DAO
DAO: Handles requests to data warehouse and returns objects
@ChrisMoney
ChrisMoney / returnMultipleTypes.cs
Created June 17, 2024 13:36
Return two types C#
(string, string, string) LookupName(long id) // tuple return type
{
... // retrieve first, middle and last from data storage
return (first, middle, last); // tuple literal
}
@ChrisMoney
ChrisMoney / requestObject.js
Last active June 10, 2024 15:43
JS - Javascript HTTP Request Object
var xhr = new XMLHttpRequest;
xhr.open("GET", url);
xhr.send();
// ********************************
// Return Json object from server
// ********************************
var id = 1;
var req = new XMLHttpRequest();