Skip to content

Instantly share code, notes, and snippets.

@mhinze
mhinze / subroute-slack.cs
Last active Jun 6, 2016
slack subroute.io
View subroute-slack.cs
using System;
using System.Net;
using Subroute.Common;
using System.Configuration;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
// Slack webhook example
namespace Subroute.Container
{
@mhinze
mhinze / README.txt
Created Mar 17, 2016 — forked from mattweber/README.txt
ElasticSearch Multi-Select Faceting Example
View README.txt
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh).
@mhinze
mhinze / Disable-NServiceBusSetupCheck.ps1
Created Sep 16, 2014
Solution Script for disabling nservicebus check when loading sln in visual studio
View Disable-NServiceBusSetupCheck.ps1
function global:Disable-NServiceBusSetupCheck()
{
#default to current dir when debugging
if(!$solutionScriptsContainer){
$solutionScriptsContainer = "./"
}
$packagesFolder = Join-Path $solutionScriptsContainer "..\packages" -Resolve
Push-Location $packagesFolder
@mhinze
mhinze / ElasticSearchIntegrationTestSetupFixture.cs
Created Apr 10, 2014
Integration testing elasticsearch take 1
View ElasticSearchIntegrationTestSetupFixture.cs
using System;
using NUnit.Framework;
using Search.QueryUnderstanding.Api.Application;
[SetUpFixture]
public class ElasticSearchIntegrationTestSetupFixture
{
private readonly ElasticSearchTestClient client = new ElasticSearchTestClient(new ElasticSearchConfiguration());
private readonly ElasticSearchTestContext context = new ElasticSearchTestContext();
@mhinze
mhinze / DatabaseDeleter.cs
Last active Aug 29, 2015
Database deleter (EF)
View DatabaseDeleter.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
public class DatabaseDeleter
{
static readonly string[] _ignoredTables =
{
"sysdiagrams",
@mhinze
mhinze / EntityFrameworkExtensions.cs
Created Jan 8, 2014
A useful little EF extension method
View EntityFrameworkExtensions.cs
using System;
using System.Data.Entity;
public static class EntityFrameworkExtensions
{
/// <summary>
/// Given an id, creates a reference to an existing (persisted) *unchanged* entity
/// </summary>
/// <typeparam name="TEntity">Entity CLR type</typeparam>
/// <param name="db">DbContext</param>
@mhinze
mhinze / BaseController.cs
Created Nov 19, 2013
BaseController.cs with Async
View BaseController.cs
using System.Threading.Tasks;
using System.Web.Mvc;
using JetBrains.Annotations;
using ShortBus;
public abstract class BaseController : Controller
{
public IMediator Mediator { get; set; }
protected Response<TResult> Query<TResult>(IQuery<TResult> query)
@mhinze
mhinze / BaseController.cs
Last active Dec 27, 2015
Sample ShortBus BaseController
View BaseController.cs
using System.Web.Mvc;
using JetBrains.Annotations;
using ShortBus;
public abstract class BaseController : Controller
{
public IMediator Mediator { get; set; }
protected Response<TResult> Query<TResult>(IQuery<TResult> query)
{
@mhinze
mhinze / PropsShouldMatch.cs
Created Sep 30, 2013
All properties should match assertion based on Rhino.Mocks AllPropertiesMatchConstraint
View PropsShouldMatch.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public static class ShouldExtensions
{
/// <summary>
@mhinze
mhinze / Delete-BinObj.ps1
Last active Dec 23, 2015
Delete-BinObj.ps1
View Delete-BinObj.ps1
function global:Delete-BinObj()
{
$path = join-path $solutionScriptsContainer '..' -resolve
Get-ChildItem $path -include bin,obj -recurse -Force | remove-item -force -recurse
}