Skip to content

Instantly share code, notes, and snippets.

Avatar

Protiguous Protiguous

View GitHub Profile
@Protiguous
Protiguous / ExpectedOutput.1-100.txt
Created Mar 31, 2021
FizzBuzz Expected Output, Lines 1 to 100
View ExpectedOutput.1-100.txt
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
@Protiguous
Protiguous / FormatBytes.sql
Last active Dec 19, 2020
SQL Server Function to format bytes into larger units like MB, GB, TB, etc..
View FormatBytes.sql
-- select [dbo].[FormatBytes]( 13241322.567567, 'bytes' );
-- select [dbo].[FormatBytes]( 132413225.567567, 'bytes' );
-- select [dbo].[FormatBytes]( 1324132255.567567, 'bytes' );
-- select [dbo].[FormatBytes]( 13241322551.567567, 'bytes' );
-- select [dbo].[FormatBytes]( 13241322.567567, 'mb' );
-- select [dbo].[FormatBytes]( 132413225.567567, 'gb' );
-- select [dbo].[FormatBytes]( 1324132255.567567, 'tb' );
-- select [dbo].[FormatBytes]( 13241322551.567567, 'zb' );
-- select [dbo].[FormatBytes]( 13241322551.567567, 'yb' );
-- select [dbo].[FormatBytes]( 132413225512.567567, 'yb' );
@Protiguous
Protiguous / ListExample.cs
Last active Aug 14, 2020
Example to show adding items to a list and removing certain items.
View ListExample.cs
//Verified to run under .NET 5.0 Console Application.
namespace ConsoleApp1 {
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
@Protiguous
Protiguous / ABetterClassDispose.cs
Last active Nov 7, 2020
A different way of disposing objects.
View ABetterClassDispose.cs
// Copyright © Protiguous. All Rights Reserved.
//
// This entire copyright notice and license must be retained and must be kept visible in any binaries, libraries, repositories, or source code (directly or derived) from our binaries, libraries, projects, solutions, or applications.
//
// All source code belongs to Protiguous@Protiguous.com unless otherwise specified or the original license has been overwritten by formatting. (We try to avoid it from happening, but it does accidentally happen.)
//
// Any unmodified portions of source code gleaned from other sources still retain their original license and our thanks goes to those Authors.
// If you find your code unattributed in this source code, please let us know so we can properly attribute you and include the proper license and/or copyright(s).
//
// If you want to use any of our code in a commercial project, you must contact Protiguous@Protiguous.com for permission, license, and a quote.
@Protiguous
Protiguous / Drop and Create Service Broker objects.sql
Last active Aug 16, 2020
Easy Create Objects for Service Broker (works in SQL Server 2019 Developer Edition)
View Drop and Create Service Broker objects.sql
-- Based from https://sqlperformance.com/2014/03/sql-performance/configuring-service-broker
USE [master]
GO
ALTER DATABASE [Test] SET ENABLE_BROKER WITH NO_WAIT
GO
USE [Test]
GO
@Protiguous
Protiguous / Draw BrentOzar.sql
Last active Nov 17, 2019 — forked from SQLAdrian/drawbrent.sql
Let's draw Brent
View Draw BrentOzar.sql
/*Adrian Sullivan - 2019/11/15 Fun with polygons.*/
/*Thanks to Michael J Swart for all the awesome work on color
https://michaeljswart.com/
*/
DECLARE @tt table(id int identity(0,1), label VARCHAR(50), gg GEOMETRY)
SET NOCOUNT ON
DECLARE @g geometry = 'POLYGON((-121.97087 37.372518,-121.97087 37.372518,-121.970863 37.372517,-121.970845 37.372515,-121.97087 37.372518))'
@Protiguous
Protiguous / FullDBBackup.ps1
Created Nov 9, 2019 — forked from AdamLJohnson/FullDBBackup.ps1
Powershell script to backup all SQL Databases on a server. Useful for SQL Express.
View FullDBBackup.ps1
$serverName = ".\SQLExpress"
$backupDirectory = "D:\backupSQL"
$daysToStoreDailyBackups = 7
$daysToStoreWeeklyBackups = 28
$monthsToStoreMonthlyBackups = 3
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
@Protiguous
Protiguous / awaitForms.cs
Created Apr 24, 2019
Having fun with awaiting on forms.
View awaitForms.cs
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
using Forms;
public static class Program {
[STAThread]
public static async Task Main() {