This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var startYear = 2000; | |
var endYear = DateTime.UtcNow.Year; | |
var spookyYears = new List<(int year, int occurrences)>(); | |
for (var ixYear = startYear; ixYear <= endYear; ixYear++) | |
{ | |
var spookyDaysThisYear = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets | |
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>CreateMediatRClasses</Title> | |
<Author>Jon Sagara</Author> | |
<Description>Inserts Query, Command, and QueryHandler classes for MediatR</Description> | |
<Shortcut>mediator</Shortcut> | |
</Header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuickProfiler : IDisposable | |
{ | |
private readonly Stopwatch _sw = Stopwatch.StartNew(); | |
private readonly string _name; | |
public QuickProfiler(string name) | |
{ | |
_name = name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here are some example usages for unimportant jobs we have where crap happens occasionally: | |
/// <summary> | |
/// intended for database commands that might deadlock, but are just "nice to haves"; we don't care if they deadlock every now and then | |
/// and we DON'T want them to block execution of the rest of /daily or /hourly! this returns -1 if deadlocked, otherwise, returns | |
/// the # of rows that the SQL command affected | |
/// </summary> | |
private int ExecuteIgnoreDeadlocks(string sql, object param = null, bool logDeadlock = false) | |
{ | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets | |
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>AnyKeyQuit</Title> | |
<Author>Jon Sagara</Author> | |
<Description>Inserts a "Press any key to quit..." prompt</Description> | |
<Shortcut>quit</Shortcut> | |
</Header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Xml.Linq; | |
namespace OpmlStats.ConsoleApp | |
{ | |
class Program | |
{ | |
private const string OpmlFile = @"C:\Path\To\Your\OpmlFile.opml"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [master] | |
GO | |
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'tempdev', SIZE = 102400KB , FILEGROWTH = 102400KB ) | |
GO | |
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev2', FILENAME = N'D:\Path\To\Your\DATA\tempdb2.mdf' , SIZE = 102400KB , FILEGROWTH = 102400KB ) | |
GO | |
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev3', FILENAME = N'D:\Path\To\Your\DATA\tempdb3.mdf' , SIZE = 102400KB , FILEGROWTH = 102400KB ) | |
GO | |
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev4', FILENAME = N'D:\Path\To\Your\DATA\tempdb4.mdf' , SIZE = 102400KB , FILEGROWTH = 102400KB ) | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private const string SourceDirectory = @"D:\iPhoneMedia"; | |
private const string DestDirectory = @"D:\iPhoneMediaSorted"; | |
static void Main(string[] args) | |
{ | |
var sourceDir = new DirectoryInfo(SourceDirectory); | |
// Group by YYYYMM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hexNum = "0x000000000000E295"; | |
long result; | |
long.TryParse( | |
hexNum.Substring(2), | |
System.Globalization.NumberStyles.HexNumber | System.Globalization.NumberStyles.AllowHexSpecifier, | |
System.Globalization.CultureInfo.CurrentCulture, | |
out result | |
); | |
//result.Dump(); | |
var resultBytes = BitConverter.GetBytes(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class LinqExtensions | |
{ | |
public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, bool isAscending) | |
{ | |
return isAscending | |
? source.OrderBy(keySelector) | |
: source.OrderByDescending(keySelector); | |
} | |
public static IOrderedQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, bool isAscending) |