Skip to content

Instantly share code, notes, and snippets.

@DavidRogersDev
DavidRogersDev / BaseViewModel
Last active August 29, 2015 13:57
Base ViewModel - This sample base ViewModel class includes the various bits and pieces which all Viewmodels can leverage. It inherits from MVVMLight's ViewModelBase class.
using System;
using System.Linq.Expressions;
using System.Windows.Input;
using CameraDownload.Shared;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using NLog;
namespace CameraDownload.ViewModels
{
@DavidRogersDev
DavidRogersDev / Tracing.cs
Last active May 22, 2018 06:21
An excellent tracing class pulled from Brock Allen's supremely cool MembershipReboot project. Just replace the name of the trace-source on line 82 from MembershipReboot appropriately.
/*
* Copyright (c) Brock Allen. All rights reserved.
* see license.txt
*/
using System;
using System.Diagnostics;
namespace BrockAllen.MembershipReboot
{
@DavidRogersDev
DavidRogersDev / DatabaseSetup.cs
Last active August 29, 2015 14:01
A class for use in integration testing which creates and drops a database for every applicable test.
internal class DatabaseSetup
{
internal static string connStr = ConfigurationManager.ConnectionStrings["NameOfConnString"].ConnectionString;
private const string MasterSchema = "Master";
internal void InstallDatabase(string resourceName)
{
InstallDatabase(connStr, GetScript(resourceName));
}
@DavidRogersDev
DavidRogersDev / ExceptionAssert.cs
Created June 22, 2014 00:23
ExceptionAssert includes a Throws static method which is meant to replace the usage of the ExpectedException attribute as a more targeted way of testing for an exception.
public static class ExceptionAssert
{
public static void Throws<T>(Action code, string exceptionMessage = null, string message = null, params object[] args) where T : Exception
{
try
{
code.Invoke();
Assert.Fail("No exception was thrown by the code under test.");
}
@DavidRogersDev
DavidRogersDev / SturtLibrary
Created October 20, 2014 02:21
Fun gist showing how to use my SeleniumCore library in F#.
open KesselRun.SeleniumCore
open KesselRun.SeleniumCore.Enums
open KesselRun.SeleniumCore.Infrastructure
open KesselRun.SeleniumCore.TestDrivers
open KesselRun.SeleniumCore.Infrastructure.Factories
[<EntryPoint>]
let main argv =
let mutable driverOptions = new DriverOptions()
@DavidRogersDev
DavidRogersDev / BlobReader.cs
Created December 30, 2014 00:36
Quick and dirty program that reads the text of some blobs which were written as log output from a webjob.
class Program
{
private static string Name = "myContainer";
private static string Key =
"R5+BFCGHDJSghjkngfdjklggjfdkj+gvhdfkgfdjkgfdhjgHJGKFDGF==";
static void Main(string[] args)
{
var storageCredentials = new StorageCredentials(Name, Key);
var cloudStorageAccount = new CloudStorageAccount(storageCredentials, false);
@DavidRogersDev
DavidRogersDev / Get-Bing.ps1
Last active November 26, 2023 10:34
Powershell script which downloads the Bing image of the day.
$today = Get-Date
$todayFormatted = $today.Year.ToString() + "-" + $today.Month.ToString("D2") + "-" + $today.Day.ToString("D2")
$Market = "en-AU"
$Resolution = "1920x1200"
$ImageFileName = "wallpaper-" + $todayFormatted + ".jpg"
$DownloadDirectory = "$env:USERPROFILE\Pictures\Bing Wallpaper"
$BingImageFullPath = "$($DownloadDirectory)\$($ImageFileName)"
if ((Test-Path $DownloadDirectory) -ne $True) {
@DavidRogersDev
DavidRogersDev / ContextExtensions.cs
Created October 7, 2017 03:46
Extension method CreateViewDataDictionary to create a new ViewDataDictionary in ASP.NET Core
public static ViewDataDictionary<T> CreateViewDataDictionary<T>(this HttpContext httpContext, T model)
{
var modelMetadataProvider = httpContext.ApplicationServices.GetRequiredService<IModelMetadataProvider>();
return new ViewDataDictionary<T>(modelMetadataProvider, new ModelStateDictionary())
{
Model = model
};
}
@DavidRogersDev
DavidRogersDev / uninstallAll.ps1
Last active June 17, 2020 06:56
Uninstall all Nuget packages from a Project in a solution
Get-Package -ProjectName "YourProjectName" | Uninstall-Package -ProjectName "YourProjectName" -RemoveDependencies
## Add -Force flag on the end to overcome dependancy issues.
@DavidRogersDev
DavidRogersDev / ConcatenateSqlScripts.ps1
Created June 27, 2018 01:26
Concatenate all sql scripts in a directory into 1 script. I end every script file with a GO statement, which separates them in the consolidated script file.
$file = "consolidated-script.txt"
$filenew = "consolidated-script.sql"
cat *.sql | sc consolidated-script.txt
Rename-Item $file $filenew