Skip to content

Instantly share code, notes, and snippets.

View davepcallan's full-sized avatar

Dave Callan davepcallan

View GitHub Profile
@davepcallan
davepcallan / FindSparseColumnCandidates.sql
Created May 11, 2024 10:24
SQL Server SQL script to find sparse column candidates
USE TestDB
GO
DECLARE @DatabaseName VARCHAR(100)
DECLARE @SchemaName VARCHAR(100)
DECLARE @TableName VARCHAR(100)
DECLARE @ColumnName VARCHAR(100)
DECLARE @FullyQualifiedTableName VARCHAR(500)
--Create Temp Table to Save Results
@davepcallan
davepcallan / AddColumnIfNotExists.sql
Created May 7, 2024 16:20
Add created_date column to all tables which don't have it already in SQL Server
SELECT 'ALTER TABLE ' + QUOTENAME(ss.name) + '.' + QUOTENAME(st.name) + ' ADD created_date DATETIME NULL;'
FROM sys.tables st
INNER JOIN sys.schemas ss on st.[schema_id] = ss.[schema_id]
WHERE st.is_ms_shipped = 0
AND NOT EXISTS (
SELECT 1
FROM sys.columns sc
WHERE sc.[object_id] = st.[object_id]
AND sc.name = 'created_date'
)
@davepcallan
davepcallan / userInfo.graphql
Created April 25, 2024 15:30
Example query of how to get user information from the GitHub graphql API
{
rateLimit {
limit
remaining
used
resetAt
}
user(login: "davepcallan") {
name
bio
@davepcallan
davepcallan / ExceptionHandlingDotnet9.cs
Created April 11, 2024 18:56
Exception Handling .NET 9 v .NET 8
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Environments;
namespace ExceptionBenchmark
{
[Config(typeof(Config))]
@davepcallan
davepcallan / SQLServerTruncateRollbackExample.sql
Created April 5, 2024 16:43
Sample SQL which shows rollback IS possible in SQL Server
-- Create Test Table
CREATE TABLE TruncateTest (ID INT)
INSERT INTO TruncateTest (ID)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
GO
-- Check the data before truncate
@davepcallan
davepcallan / rateLimit.graphql
Created March 12, 2024 00:34
How to get remaining and used limits on GitHub GraphQL API
{
rateLimit {
limit
remaining
used
resetAt
}
repository(owner: "dotnet", name: "runtime") {
pullRequests(states: MERGED, first: 50, orderBy: {field: CREATED_AT, direction: DESC}) {
edges {
@davepcallan
davepcallan / Example.md
Last active March 13, 2024 08:09
Get Merged PRs from dotnet/runtime using GitHub GraphQL API

image

@davepcallan
davepcallan / PRsByUser.graphql
Created March 11, 2024 22:05
Search for PRs in dotnet/runtime by a particular user
{
search(query: "repo:dotnet/runtime is:pr author:stephentoub", type: ISSUE, first: 100) {
edges {
node {
... on PullRequest {
title
url
number
createdAt
state
@davepcallan
davepcallan / MergedPRsInDotnetRuntime.graphql
Created March 11, 2024 21:55
GitHub GraphQL query to get last 100 (by created date) Merged Pull Requests in Dotnet runtime repo
{
repository(owner: "dotnet", name: "runtime") {
pullRequests(states: MERGED, first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {
edges {
node {
title
url
number
mergedAt
reviewDecision
@davepcallan
davepcallan / ChatGPTAPIExample.cs
Created March 7, 2024 13:02
Simple example of integrating with ChatGPT API from .NET
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Text;
using System.Text.Json;
namespace Samples;
public class ChatGPTAPIExample(ILogger<ChatGPTAPIExample> logger, IConfiguration configuration)
{
private string Prompt = "Please explain the following code :";