Skip to content

Instantly share code, notes, and snippets.

@chrismckelt
chrismckelt / DatabaseBackup.fs
Created December 23, 2014 10:14
DatabaseBackup.fs - backup all databases to a folder
#if INTERACTIVE
namespace Database
#endif
module DatabaseBackup
#if INTERACTIVE
=
#r "System.dll"
@chrismckelt
chrismckelt / DatabaseRestore.fs
Created December 23, 2014 10:15
DatabaseRestore.fs - restore backed up databases from a folder
#if INTERACTIVE
namespace Database
#endif
module DatabaseRestore
#if INTERACTIVE
=
#r "System.dll"
@chrismckelt
chrismckelt / RequiredBooleanAttribute
Created February 5, 2015 04:33
RequiredBooleanAttribute
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public class RequiredBooleanAttribute : ValidationAttribute
{
private readonly bool _validateValueIsThisResultBoolen;
public RequiredBooleanAttribute(bool validateValueIsThisResultBoolen)
{
_validateValueIsThisResultBoolen = validateValueIsThisResultBoolen;
}
@chrismckelt
chrismckelt / xunit_traits.cs
Last active August 29, 2015 14:18
xunit traits
using System;
using System.Linq;
namespace CodeDojo
{
public class Calculator
{
private string _junk = " ";
public void SetParseString(string junk)
@chrismckelt
chrismckelt / Hello.html
Created April 7, 2015 02:51
Hello.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Test HTML File -- Site A</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<h1>Site A</h1>
<h4 id="dnt"></h4>
@chrismckelt
chrismckelt / WebMinderFluentApiExamples.cs
Last active August 29, 2015 14:21
WebMinder Fluent API for IP Blocker & Url Availability Circuit Breaker
const string IPBLACKLIST = "Block SPAM IPS";
var ipRuleToPutInIocContainer = Create<IpAddressBlockerRule, IpAddressRequest>
.RuleSet()
.With(y => rule.RuleSetName = IPBLACKLIST)
.OnFailureAction(failedRequest => Redirect.To.GoAwayPage)
.Build();
//invoke via attribute [IpAddressBlockerRule(Rule=IPBLACKLIST)]
//or via DI ipBlocker.VerifyIpIsValid() ipBlocker.IncrementFailure()
@chrismckelt
chrismckelt / pr.md
Last active August 29, 2015 14:21 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "upstream"]
	url = https://github.com/chrismckelt/webminder.git
	fetch = +refs/heads/*:refs/remotes/upstream/*

Now add the line fetch = +refs/pull/*/head:refs/remotes/$$$$$$$$/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: $$$$ = origin or upstream

@chrismckelt
chrismckelt / DotNetBlog_To_WordPressConverter.linq
Created May 31, 2015 02:07
Dot Net Blog Engine to Word Press Converter
// need nuget WordPressSharp
internal class FileStore
{
public IList<Post> Posts { get; private set; }
public void ReadFiles()
{
const string folderPath = @"C:\temp\posts";
Posts = new List<Post>();
@chrismckelt
chrismckelt / RouteTestFixture.cs
Created June 1, 2015 09:48
.net - test to ensure routes do not change
[TestFixture]
public class RouteTestFixture
{
[Test]
public void Routes_should_not_change()
{
const string good = @"all existing routes go here (hint run the test first then copy output to here)";
var goodRoutes = good.Split(Convert.ToChar(";"));
@chrismckelt
chrismckelt / DisableBackButton.js
Created June 8, 2015 06:03
Disable back button
<script type="text/javascript">
var title = 'Loan Application Complete | Personal Loans Online';
history.pushState(null, null, title);
window.addEventListener('popstate', function(event) {
history.pushState(null, null, title);
});
</script>
<script type="text/javascript" language="javascript">