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 / UncAccess.cs
Created January 18, 2017 16:47
Access
/// <summary>
/// Helper methods for mounting a UNC network share
/// </summary>
public class UncAccess
{
/// <summary>The domain.</summary>
private string domain;
/// <summary>The last error.</summary>
private int lastError;
#add the repositories
sudo apt-get update && sudo apt-get install -y curl
curl http://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | sudo apt-key add -
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" | sudo tee /etc/apt/sources.list.d/freeswitch.list
sudo apt-get update
# install dependencies
sudo apt-get install -y git build-essential libyuv-dev libvpx2-dev liblua5.2-dev libvpx2-dev libvpx2 zlib1g-dev libspeex1 libopus-dev libsndfile-dev autoconf automake devscripts gawk g++ git-core 'libjpeg-dev|libjpeg62-turbo-dev' libncurses5-dev 'libtool-bin|libtool' make python-dev pkg-config libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-devlibspeex-dev libspeexdsp-dev libedit-dev libpq-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libldns-dev bison
@danbarua
danbarua / gist:7664d4b7bf77286ff832
Last active March 19, 2016 12:50
Upload file with form data
using (var content = new MultipartFormDataContent())
{
//hackety hack hack hack
//this will throw if object has complex/nested properties
var messageAsKeyValuePairs = JsonConvert.DeserializeObject<IDictionary<string, string>>(JsonConvert.SerializeObject(message));
foreach (var kvp in messageAsKeyValuePairs.Where(kvp => kvp.Value != null))
{
content.Add(new StringContent(kvp.Value), kvp.Key);
}
@danbarua
danbarua / Files.txt
Last active March 16, 2016 17:05
Digits to Speech Kata
# Given a Directory with the following files
# Implement Digits.ToFileString(input) where input is a positive integer
# Such that it outputs a "!" delimited list of file names to play
# in order to read out the number
0.wav
1.wav
10.wav
11.wav
12.wav
@danbarua
danbarua / IOC.cs
Created February 3, 2016 12:23
IOC Kata
namespace IOCContainer.Tests
{
using System;
using System.Collections.Generic;
using System.Linq;
using Shouldly;
using Xunit;
@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>
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using ServiceStack.Net30.Collections.Concurrent;
/// <summary>