Skip to content

Instantly share code, notes, and snippets.

View billinkc's full-sized avatar
💭
Presenting at #SQLSatOC

Bill Fellows billinkc

💭
Presenting at #SQLSatOC
  • Sterling Data Consulting
  • Kansas City, MO
View GitHub Profile
@billinkc
billinkc / DaveCochran.py
Created December 21, 2022 19:18
Debugging eval calls which I've never done
class foo:
name="string"
num=-1
math="string2"
def __init__(self,name,num,math):
self.name=name
self.num=num
self.math=math
@billinkc
billinkc / ForTJay.py
Last active February 24, 2022 21:08
Quick and dirty sample of how we go about automating google analytics pulls
# pip install google-api-python-client
# pip install oauth2client
# pip install pandas
from datetime import datetime, timedelta, date
from dateutil.rrule import rrule, DAILY
import apiclient
from oauth2client.service_account import ServiceAccountCredentials
import json
import pandas as pd
@billinkc
billinkc / SO_71128236.cs
Created February 16, 2022 16:56
Replaced the console/debug calls with FireInformation events as I never had the former show anywhere in the logs
public override void CreateNewOutputRows()
{
// added
bool fireAgain = false;
System.Net.ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
@billinkc
billinkc / InstallLogparser.ps1
Last active September 8, 2021 17:19
Assuming you wanted to grab the info from a SQL Server install log - specifically the Exit Code, here's some terrible PowerShell to do so
# Sample data of what Summary.txt looks like
<#
Overall summary:
Final result: Passed
Exit code (Decimal): 0
Start time: 2021-02-26 03:03:25
End time: 2021-02-26 03:04:36
Requested action: Patch
Instance DEV2019UTF8 overall summary:
@billinkc
billinkc / BadIdeaJeans_TemporalTableEdition.sql
Created August 18, 2021 22:59
Bad ideas for cheating with temporal tables
USE tempdb
IF EXISTS (SELECT * FROM sys.schemas AS S INNER JOIN sys.tables AS T ON T.schema_id = S.schema_id WHERE S.name = 'dbo' AND T.name = 'Employee')
BEGIN
BEGIN TRY
ALTER TABLE dbo.Employee
SET (SYSTEM_VERSIONING = OFF);
END TRY
BEGIN CATCH
-- I don't care if system versioning is on
@billinkc
billinkc / DelimitedLists.cs
Last active February 20, 2020 18:39
Code to accompany a blog post about building delimited lists in .net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Text;
public class Program
{
public static void Main()
{
@billinkc
billinkc / JsonShredder.biml
Created September 5, 2019 15:39
How to use a json metadata store with Biml
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#
// Given the following structure
///{
/// "packages": [
/// "p1",
/// "p2",
/// "p3"
/// ]
///}
@billinkc
billinkc / Rush.sql
Created May 21, 2019 19:25
Find non-alphanumerics in sql
IF OBJECT_ID('tempdb..#Numbers') IS NOT NULL
BEGIN
DROP TABLE #Numbers;
END
IF OBJECT_ID('tempdb..#rush') IS NOT NULL
BEGIN
DROP TABLE #rush;
END
@billinkc
billinkc / BoomGoesTheDynamite.sql
Last active November 29, 2018 18:15
Microsoft SQL Server 2014/2016/2017 index repro
IF NOT EXISTS
(
SELECT * FROM sys.partition_functions AS PF WHERE PF.name = 'PartitionRange'
)
BEGIN
CREATE PARTITION FUNCTION PartitionRange(bigint) AS RANGE RIGHT FOR VALUES (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
END
GO
IF NOT EXISTS
(
@billinkc
billinkc / TableViaQuery.biml
Created September 4, 2017 20:24
Given a query, generate the resulting Biml table
<#@ import namespace="System.Data" #>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#
Dictionary<string, string> namedQueries = new Dictionary<string,string>{{"Query 28", @"-- Drive level latency information (Query 28) (Drive Level Latency)
-- Based on code from Jimmy May
SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point],
CASE
WHEN num_of_reads = 0 THEN 0
ELSE (io_stall_read_ms/num_of_reads)
END AS [Read Latency],