Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / !Notes.md
Last active August 29, 2015 14:23
Issuing a Self-Signed certificate

Depends on using BouncyCastle nuget package for the certificate generation.

@dealproc
dealproc / downloader.js
Created June 23, 2015 05:32
Downloader for binary files.
// Would be best to store this in ~/Scripts/durandal/plugins for convenience.
// This is so that when you must download a file from the web, via WebAPI with an OAuth2 token, you can validate yourself to the Api.
// This has been tested with small-ish files, but has not been tested with larger files, like installers. Please offer contributions
// back for those items.
define(["durandal/system", "durandal/app"], function (system, app) {
var defaults = {
url: "", // to be provided by end user.
method: "GET",
mimeType: "application/octet-stream",
filename: "download.bin",
@dealproc
dealproc / CalculateVersion.ps1
Last active August 29, 2015 14:23
SemVer Script
# These are project build parameters in TeamCity
# Depending on the branch, we will use different major/minor versions
$majorMinorVersionMaster = "%system.MajorMinorVersion.Master%"
$majorMinorVersionDevelop = "%system.MajorMinorVersion.Develop%"
$assemblyVersion = ""
# TeamCity's auto-incrementing build counter; ensures each build is unique
$buildCounter = "%build.counter%"
# This gets the name of the current Git branch.
@dealproc
dealproc / xUnit.proj
Created June 17, 2015 08:42
xUnit run file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Test"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(SolutionDir)packages\xunit.runner.msbuild.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.runner.msbuild.dll"
TaskName="Xunit.Runner.MSBuild.xunit" />
<ItemGroup>
<TestAssemblies Include="**/*.Tests.dll;**/*.IntegrationTests.dll" Exclude="**/obj/**;**/*IntegrationTests*;" />
</ItemGroup>
<Target Name="Test">

I'm trying to figure out how to describe the issue of what everyone calls a CRUD application, and subsequently start to explain why a CRUD app isn't about CRUD, since those screens need validation involved in them more than most developers understand.

Let's look at the acronym, CRUD:

  • C - Create (Insert) values inside the database
  • R - Read (Select) values from the database
  • U - Update (Update :trollface:) values inside the database
  • D - Delete (Delete :trollface:) values from existence

This gives a 1-1 relationship between a users actions and what we do in the database. We're either inserting data (create/insert), displaying those values that we just created (read/select), updating values that exist (update), and when we no longer need the data, we're deleting the data (delete). The hard part with this notion is that in the real world, this is never the case. To support this theory, we should look at one of the most widely accepted CRUD applications that exist out there... a CRM

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using ServiceStack.Net30.Collections.Concurrent;
/// <summary>
/// Helper class redirects events to private Apply(event) method
using System;
using System.Reflection;
using CommonDomain;
using CommonDomain.Core;
using CommonDomain.Persistence;
using CommonDomain.Persistence.EventStore;
using NEventStore;
using NEventStore.Dispatcher;
@dealproc
dealproc / Deploy.ps1
Created March 2, 2015 08:19
Using Fluent Migrator with Octopus Deploy
if (!$MainDB) {
$MainDB = '...';
}
tools\migrate.exe --task migrate --connection "$MainDB" --provider "SqlServer2012" --assembly "lib\net45\Adapt.Gift.DatabaseScripts.dll" --tps
@dealproc
dealproc / Class1.cs
Last active August 29, 2015 14:15
Setting a member without the "null reference" spam
using System;
using System.Linq.Expressions;
using System.Reflection;
using Xunit;
namespace ReflectedConstructor {
public static class MemberExpressions {
public static MemberInfo GetMemberInfo(this Expression expression) {
var lambda = (LambdaExpression)expression;
MemberExpression memberExpression;
namespace {Product}.Infrastructure.Framework {
using FluentValidation;
using FluentValidation.Results;
using System;
using System.Text;
public static class ValidationHelper {
public static ValidationResult Validate<T, K>(K entity)
where T : IValidator<K>, new()
where K : class {
IValidator<K> __Validator = new T();