This file contains hidden or 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.Collections; | |
using System.Data; | |
using Moq; | |
namespace Moq.DataExtensions { | |
public static class MockFactoryDataExtensions { | |
public static Mock<IDbCommand> CreateIDbCommand(this MockFactory factory) { | |
var command = factory.Create<IDbCommand>(); |
This file contains hidden or 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.Collections.Generic; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
namespace TypeUtil { | |
public static class TypeExtensions { | |
public static FastPropertyInfo<T> GetProperty<T>(this Type type, string name) { | |
return type.GetProperty<T>(name, BindingFlags.Default); | |
} |
This file contains hidden or 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
def proxy(proxied="instance"): | |
def real_proxy(cls): | |
def get_attribute(self, name): | |
try: | |
return object.__getattribute__(self, name) | |
except AttributeError: | |
if type("instance") == type(proxied): | |
return object.__getattribute__(getattr(self, proxied), name) | |
else: | |
return object.__getattribute__(getattr(self, "instance"), name) |
This file contains hidden or 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
#!/bin/bash | |
log="$(mktemp)" | |
email="[email protected]" | |
mount /media/Backup && | |
rsync -vax --delete --ignore-errors --log-file=$log /media/Data/ /media/Backup/ && | |
umount /media/Backup && | |
(cat $log | mail -s "[rsync] Mirror Data drive $(date)" $email) && | |
rm $log |
This file contains hidden or 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.Collections.Generic; | |
using System.Data; | |
using System.Linq; | |
using System.Reflection; | |
using Dapper; | |
using Microsoft.EntityFrameworkCore; | |
public static class DbContextExtensions { | |
public static IQueryable<object> Set(this DbContext context, Type type) { |
This file contains hidden or 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
function Archive-Logs { | |
[CmdLetBinding()] | |
PARAM ( | |
[string][parameter(Mandatory = $true)][ValidateNotNullOrEmpty()]$LogsPath, | |
[string][parameter(Mandatory = $true)][ValidateNotNullOrEmpty()]$ArchivesPath | |
) | |
BEGIN { | |
} | |
PROCESS { | |
$today = (Get-Date) |
This file contains hidden or 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 StringConverter { | |
public static T To<T>(this string value) { | |
if(String.IsNullOrEmpty(value)) { | |
return default(T); | |
} | |
try { | |
var convertibleValue = (IConvertible)value; | |
var conversionType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); | |
return (T)convertibleValue.ToType(conversionType, CultureInfo.CurrentCulture); |
This file contains hidden or 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
# This script runs our web-based tests, running IISExpress via TeamCity's | |
# dotCover, then runing the tests (also in dotCover) and then importing the | |
# test results and coverage results back into TeamCity. | |
# Note that some of the following is based on the comments by Tony Fabris on | |
# 20th Jan 2016 from here: https://youtrack.jetbrains.com/issue/DCVR-5921 | |
# Configuration. | |
# The path to IIS Express. | |
$IISExpressPath = "C:\Program Files (x86)\IIS Express\IISExpress.exe" |
This file contains hidden or 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 DependencyResolution { | |
public static void ConfigureServices(IContainer container = null, ServiceCollection services = null) { | |
container = container ?? new Container(); | |
services = services ?? new ServiceCollection(); | |
container.Populate(services); | |
var provider = container.GetInstance<IServiceProvider>(); | |
HttpRuntime.WebObjectActivator = new HttpRequestScopedServiceProvider(provider); | |
} |
This file contains hidden or 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 EnvironmentVariables { | |
public static void SetUp() { | |
var configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "Environment.config"); | |
if(File.Exists(configFile)) { | |
var lines = File.ReadAllLines(configFile); | |
foreach(var line in lines) { | |
var index = line.IndexOf("=", StringComparison.Ordinal); |
OlderNewer