Skip to content

Instantly share code, notes, and snippets.

View sixeyed's full-sized avatar

Elton Stoneman sixeyed

View GitHub Profile
using Newtonsoft.Json.Linq;
using System;
using System.Configuration;
using System.Net;
using System.Runtime.Caching;
using System.Xml;
namespace Api.Core
{
/// <summary>
@sixeyed
sixeyed / SoakController.cs
Created July 23, 2014 15:42
SoakController - a simple WebAPI controller for remote-controlling a Kafka soak test
using KafkaNet;
using KafkaNet.Model;
using KafkaNet.Protocol;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
@sixeyed
sixeyed / GenerateMD5Hashes.linq
Last active August 29, 2015 14:05
MD5 hash distribution in C# - allocating to 1/200 for 0.5% splits
//LinqPad
File.Delete("c:\\md5-list.txt");
var hashes = new List<string>();
var bytes = new byte[16];
using (var rng = new RNGCryptoServiceProvider())
{
for (int i=0; i<500000; i++)
{
@sixeyed
sixeyed / DateTimeOffsetExtensions.cs
Created October 9, 2014 09:32
C# extension method to get HTTP formatted date-time string from DateTimeOffset
namespace System
{
/// <summary>
/// Extensions to <see cref="DateTimeOffset"/>
/// </summary>
public static class DateTimeOffsetExtensions
{
/// <summary>
/// Returns the localised date-time as GMT formatted for HTTP headers, e.g.
/// Thu, 09 Oct 2014 10:31:33 GMT
@sixeyed
sixeyed / Program.cs
Created February 19, 2015 16:04
Submitting HDInsight Storm Applications from Visual Studio - Gotcha!
TopologyBuilder topologyBuilder = new TopologyBuilder("MyEventProcessorRealTimeStorm");
@sixeyed
sixeyed / StubEventHubSpout.cs
Last active September 7, 2015 13:42
Simple stub for emitting Event Hub-style tuples to Storm context, for testing .NET Storm applications. Usage here: https://blog.sixeyed.com/a-stub-event-hub-spout-for-testing-storm-net/
using Microsoft.SCP;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace My.Storm.App.Tests
{
/// <summary>
/// Simple stub for emitting Event Hub-style tuples to Storm context.
/// </summary>
@sixeyed
sixeyed / SaveQuote_Full.cs
Last active December 21, 2015 04:09
Saving a quote with the Dynamics CRM SDK, using a service identity in a back-end process.
using System;
using System.Linq;
using System.ServiceModel.Description;
using x.y.z.ServiceAgents.DynamicsCrm.OrganizationService;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
namespace x.y.z.Services.Quotes
{
public static class SaveQuote
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Sixeyed.Framework
{
public class TaskBatcher : IDisposable
{
private int _batchSize;
private int _batchIndex = 0;
@sixeyed
sixeyed / CREATE-Database.sql
Created January 8, 2014 20:25
SQL Server CREATE scripts for the SQL Server versus MongoDB concurrency shoot-out: http://wblo.gs/eLB
USE [master]
GO
/****** Object: Database [Domain] Script Date: 08/01/2014 20:22:31 ******/
CREATE DATABASE [Domain]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Domain', FILENAME = N'C:\Databases\Domain.mdf' , SIZE = 32832KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Domain_log', FILENAME = N'C:\Databases\Domain_log.ldf' , SIZE = 152384KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
@sixeyed
sixeyed / DefaultBus.cs
Created January 17, 2014 08:38
Mutator for NServiceBus which compresses large messages (>1Kb)
using Sixeyed.NServiceBus.Mutators;
using log4net.Config;
using Microsoft.Practices.Unity;
using NServiceBus;
using NServiceBus.Features;
using nsb = NServiceBus;
namespace Sixeyed.NServiceBus
{
public static class DefaultBus