Skip to content

Instantly share code, notes, and snippets.

@costr
costr / ExecutionTimeLogger.cs
Last active July 8, 2021 21:02
Execution time logging in C# with usings
using System;
using System.Diagnostics;
namespace Tools.Debugging
{
public class ExecutionTimeLogger : IDisposable
{
private readonly Stopwatch watch;
private readonly string _titleForWhatIsBeingTracked;
private readonly string _callingMethodName;
@tylerlange
tylerlange / gist:551578d52938dc38efa3147f3ae4ab7a
Created March 22, 2017 22:02
Visonic Door/Window Sensor SmartThings DTH
/**
* Tyco Door/Window Sensor
*
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Async Unit Test</Title>
<Author>Rusty Divine</Author>
<Description>Async Unit Test Template with 3 Parts</Description>
<HelpUrl>https://msdn.microsoft.com/en-us/library/ms165394.aspx</HelpUrl>
<SnippetTypes />
<Keywords />
private string RandomString
{
get
{
var path = String.Empty; // returns random string of 11 chars
for (int i = 0; i < 9; i++)
{
path += Path.GetRandomFileName();
}
return path.Replace(".", "");
@ngocvantran
ngocvantran / MoqExtensions.cs
Last active November 13, 2021 17:46
Extension methods to quickly ignore arguments without repeating It.IsAny<>()
using System;
using System.Linq.Expressions;
using Moq.Language.Flow;
namespace Moq
{
public static class MoqExtensions
{
public static ISetup<T, TResult> SetupIgnoreArgs<T, TResult>(this Mock<T> mock,
Expression<Func<T, TResult>> expression)
@joey-qc
joey-qc / TSQL-to-POCO
Created September 26, 2013 06:56
A simple TSQL script to quickly generate c# POCO classes from SQL Server tables and views. You may tweak the output as needed. Not all datatypes are represented but this should save a bunch of boilerplate coding. USAGE: Run this query against the database of your choice. The script will loop through tables, views and their respective columns. Re…
declare @tableName varchar(200)
declare @columnName varchar(200)
declare @nullable varchar(50)
declare @datatype varchar(50)
declare @maxlen int
declare @sType varchar(50)
declare @sProperty varchar(200)
DECLARE table_cursor CURSOR FOR