Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
GuyHarwood / .deployment
Created July 30, 2015 18:21
sample azure .deployment file for web project
[config]
project = src/ui/ui.csproj
SCM_BUILD_ARGS=-p:Configuration=uat;PublishProfile=uatWeb
@GuyHarwood
GuyHarwood / dropdb.sql
Last active August 29, 2015 14:20
Kill Connections And Drop Database
ALTER DATABASE [dbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
DROP DATABASE [dbName]
GO
DROP LOGIN <loginName>
GO
/**
@GuyHarwood
GuyHarwood / sqlceConnection.config
Last active August 29, 2015 14:20
SQL Server CE Connection String for Entity Framework
<add name="MyContext" connectionString="Data Source=|DataDirectory|myDatabase.sdf" providerName="System.Data.SqlServerCe.4.0"/>
@GuyHarwood
GuyHarwood / VsKeyboardShortcuts.md
Last active February 24, 2016 15:44
VS Keyboard Shortcuts

Useful Keyboard Shortcuts

Open Shortcuts Preferences: Vs -> Tools -> Options -> Environment -> Keyboard

New Code File with [Alt+]

resharper_generate : [Alt +]

Tab Groups

Window.MovetoNextTabGroup: [Alt Cmd ->]

@GuyHarwood
GuyHarwood / SelfSignedCert.sh
Created August 8, 2014 09:04
Generate Self Signed Cert with OpenSSL
# Create a certificate authority
openssl genrsa -des3 -out ca.key 1024
openssl req -new -key ca.key -out ca.csr
openssl x509 -req -days 365 -in ca.csr -out ca.crt -signkey ca.key
# Create a server certificate
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
@GuyHarwood
GuyHarwood / log4net.cs
Created January 23, 2014 14:23
Log4net usage patterns
private readonly ILog log = LogManager.GetLogger(typeof (MyType));
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<log4net>
<root>
<priority value="INFO"/>
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="EventLogAppender" />
@GuyHarwood
GuyHarwood / validateMappings.cs
Created November 28, 2013 09:36
Validate all AutoMapper configurations in one test
[Test]
[Description("Seeks out all implementations of IMappingConfiguration and tests the configuration for missing member mappings")]
public void ValidateAllMappingConfigurations()
{
var webAssembly = typeof (HomeController).Assembly;
var allMappingConfigurations = from typ in webAssembly.GetTypes()
let interfaces = typ.GetInterfaces()
where interfaces.Contains(typeof (IMappingConfiguration))
select typ;
[TestFixture]
public class CustomHandleErrorAttributeTests
{
private CustomHandleErrorAttribute sut;
private ExceptionContext exceptionContext;
private readonly Mock<HttpRequestBase> mockRequest= new Mock<HttpRequestBase>();
private readonly Mock<HttpContextBase> mockContext = new Mock<HttpContextBase>();
private readonly Mock<HttpResponseBase> mockResponse = new Mock<HttpResponseBase>();
[SetUp]
@GuyHarwood
GuyHarwood / bs-modal.js
Created May 23, 2013 14:11
auto positioning modal for bootstrap
$('#my-modal').modal({
backdrop: true,
keyboard: true
}).css({
width: 'auto',
'margin-left': function () {
return -($(this).width() / 2);
}
});
@GuyHarwood
GuyHarwood / ParallesVmIpDns.md
Last active February 24, 2016 15:46
Map Parallels VM IP to DNS entry on OSX

sudo dscl localhost -create /Local/Default/Hosts/ridiculous.nonsense.monkeys IPAddress 192.168.0.1

Enter your password when asked, and you can now ping 192.168.0.1 with the name ridiculous.nonsense.monkeys

You can see the results of your work with:

dscl localhost -readall /Local/Default/Hosts

And to undo your handy-work: