Skip to content

Instantly share code, notes, and snippets.

View danbarua's full-sized avatar

Dan Barua danbarua

  • GSK
  • United Kingdom
View GitHub Profile
@danbarua
danbarua / gist:6249022
Created August 16, 2013 11:04
Redis request logger for ServiceStack
using System;
using System.Collections.Generic;
using System.Linq;
using ServiceStack.Common.Web;
using ServiceStack.Redis;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.Providers;
using ServiceStack.ServiceInterface.ServiceModel;
using ServiceStack.ServiceModel;
@danbarua
danbarua / RedisTextSearchExtensions.cs
Created April 23, 2013 10:10
Simple text search with ServiceStack.Redis, based on Antirez's 'AutoComplete with Redis' post http://oldblog.antirez.com/post/autocomplete-with-redis.html Add POCOs to the index like this: client.AddToTextIndex(dto, x => x.Name, x => x.Address); and search like this: client.SearchText<TModel>("foo");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using ServiceStack.Common.Utils;
using ServiceStack.Redis;
using ServiceStack.Text;
namespace RedisSearch
{
@danbarua
danbarua / StyleCop.xml
Created October 6, 2015 10:17
Reshaper layout template used with StyleCop (not default StyleCop ordering rules)
<?xml version="1.0" encoding="utf-8"?>
<!-- Last updated 15.05.2012 -->
<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">
<!-- Do not reorder COM interfaces -->
<Pattern>
<Match>
<And Weight="2000">
<Kind Is="interface"/>
<Or>
using System.Collections.Generic;
using System.Linq;
using NHibernate.Criterion;
using ServiceStack.Common;
using ServiceStack.NH.Core.Domain;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.ServiceModel;
namespace ServiceStack.NH.Web.App_Start
{
public class CommandHandlersModule : NinjectModule
{
public override void Load()
{
this.Kernel.Bind(
x =>
x.FromAssembliesMatching("WordWatch.*")
.SelectAllClasses()
.InheritedFrom(typeof(ICommandHandler<>))
.BindAllInterfaces());
@danbarua
danbarua / gist:710e77de8dd5117d843c
Created June 18, 2015 16:10
spike inserting events to PGSQL using the new copy api in v3
if(expectedVersion == ExpectedVersion.NoStream)
{
using(var tx = _connection.BeginTransaction(IsolationLevel.Serializable))
{
int streamIdInternal = -1;
using(
var command =
new NpgsqlCommand(
"INSERT INTO streams(id, id_original) VALUES (:stream_id, :stream_id_original) RETURNING id_internal;")
)
@danbarua
danbarua / Test.cs
Last active August 29, 2015 14:21 — forked from jchannon/Test.cs
public class SomeFixture : IDisposable
{
private DockerClient client;
public SomeFixture()
{
Console.WriteLine("SomeFixture ctor: This should only be run once");
//Using https://github.com/ahmetalpbalkan/Docker.DotNet
public class Indexer
{
private Dictionary<string, List<string>> termToIds =
new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
private Dictionary<string, List<string>> idToTerms =
new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
public void Index(string docId, string text)
{
@danbarua
danbarua / Global.asax.cs
Created February 18, 2015 11:59
Use TeamCity credentials to auth with NuGet.Server
public class Global : System.Web.HttpApplication
{
private readonly string connectionString = ConfigurationManager.ConnectionStrings["teamCity"].ConnectionString;
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
@danbarua
danbarua / Create_Index.sql
Created November 28, 2014 12:07
Speed up NEventStore 3 projection rebuilds with this index
/****** Object: Index [IX_Commits_Ordered] Script Date: 11/28/2014 11:59:00 ******/
CREATE NONCLUSTERED INDEX [IX_Commits_Ordered] ON [dbo].[Commits]
(
[CommitSequence] ASC,
[StreamId] ASC,
[StreamRevision] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = OFF, ALLOW_PAGE_LOCKS = OFF) ON [PRIMARY]
GO