Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mhinze
mhinze / subroute-slack.cs
Last active June 6, 2016 20:00
slack subroute.io
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 March 17, 2016 21:31 — forked from mattweber/README.txt
ElasticSearch Multi-Select Faceting Example
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 September 16, 2014 16:03
Solution Script for disabling nservicebus check when loading sln in visual studio
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 April 10, 2014 13:46
Integration testing elasticsearch take 1
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 August 29, 2015 13:58
Database deleter (EF)
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 January 8, 2014 16:03
A useful little EF extension method
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 November 19, 2013 19:43
BaseController.cs with Async
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 December 27, 2015 16:29
Sample ShortBus BaseController
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 September 30, 2013 18:15
All properties should match assertion based on Rhino.Mocks AllPropertiesMatchConstraint
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 December 23, 2015 19:59
Delete-BinObj.ps1
function global:Delete-BinObj()
{
$path = join-path $solutionScriptsContainer '..' -resolve
Get-ChildItem $path -include bin,obj -recurse -Force | remove-item -force -recurse
}