Skip to content

Instantly share code, notes, and snippets.

👻
(⊙_⊙;)

Timothy Addison taddison

👻
(⊙_⊙;)
Block or report user

Report or block taddison

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@taddison
taddison / Select.js
Created Dec 12, 2019
React select with styled components
View Select.js
import React from "react";
import styled from "styled-components";
const MinorSelect = styled.select`
appearance: none;
background-color: #edf2f7;
border: 0.0625rem solid grey;
border-radius: 0.5rem;
font-size: 1.5rem;
padding: 1rem;
View ssrsExtractDatasets.sql
USE ReportServer
go
drop table if exists #reports;
/* 2016 Reports */
WITH XMLNAMESPACES (
'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd
,'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily' as df
,DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition'
),reports
View appinsights-sql-check.cs
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DependencyCollector;
using Microsoft.ApplicationInsights.Extensibility;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@taddison
taddison / postToLogAnalytics.ps1
Created Aug 26, 2018
Post an object to Log Analytics with PowerShell
View postToLogAnalytics.ps1
# Adapted from https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-data-collector-api
Function Get-LogAnalyticsSignature {
[cmdletbinding()]
Param (
$customerId,
$sharedKey,
$date,
$contentLength,
$method,
$contentType,
@taddison
taddison / avroreader.cs
Created Aug 17, 2018
Read Avro EventHubs capture file (credit @Kadajski)
View avroreader.cs
using Microsoft.Hadoop.Avro.Container;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace AvroReader
{
public class AvroEventData
@taddison
taddison / RestartServiceUsingMemory.ps1
Created Jul 13, 2018
Restart a windows service using more memory than a given cutoff
View RestartServiceUsingMemory.ps1
#requires -RunAsAdministrator
$serviceName = "BITS"
$cutoffGB = 0.0001
$processId = (Get-WMIObject win32_service | where { $_.name -eq $serviceName}).ProcessID
$process = Get-Process -Id $processId
$workingSet = $process.WorkingSet64
$workingSetGB = $workingSet / 1GB
@taddison
taddison / find_describe_tag.ps1
Created Jul 5, 2018
Find the first tag value for a describe block in a pester test file
View find_describe_tag.ps1
$text = Get-Content .\src\SQLChecks\Tests\Databases.tests.ps1
$ast = [Management.Automation.Language.Parser]::ParseInput($text, [ref]$null, [ref]$null)
$ast.FindAll({
param($t)
$t -is [System.Management.Automation.Language.CommandAst] -and
$t.CommandElements[0].Value -eq "Describe"
}, $true) | ForEach-Object {
$_.CommandElements[3].Value
}
@taddison
taddison / ConfigureDBMailWithSendGrid.sql
Created Apr 23, 2018
Configure DBMail with SendGrid
View ConfigureDBMailWithSendGrid.sql
declare @mailFromDomain nvarchar(128) = N'@foo.com'
declare @username nvarchar(128) = 'apikey'
declare @password nvarchar(128) = 'SG.SECRETS';
declare @port int = 587;
declare @server nvarchar(128) = 'smtp.sendgrid.com'
declare @replyTo nvarchar(128) = 'donotreply' + @mailFromDomain;
declare @serverName nvarchar(128) = substring(@@servername,8,100);
declare @emailAddress nvarchar(128) = @serverName + @mailFromDomain;
declare @displayName nvarchar(128) = @serverName;
@taddison
taddison / removedbmailnondefault.sql
Last active Apr 24, 2018
Remove all non-default profiles + accounts from DBMail
View removedbmailnondefault.sql
declare @defaultProfileId int;
select @defaultProfileId = pp.profile_id
from dbo.sysmail_principalprofile as pp
where pp.principal_sid = 0x00 /* Guest */
and pp.is_default = 1
if @defaultProfileId is null
begin
;throw 50000, 'No default profile set', 1
return
@taddison
taddison / addappinsights.ps1
Created Apr 23, 2018
Add app insights perf counters
View addappinsights.ps1
$cred = Get-Credential -UserName "foo\admin"
$servers = @("server1","server2")
foreach($server in $servers)
{
Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock {
Add-LocalGroupMember -Group "Performance Monitor Users" -Member "foo\service1"
Add-LocalGroupMember -Group "Performance Monitor Users" -Member "foo\service2"
}
}
You can’t perform that action at this time.