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 / PartialFileResponse.cs
Created November 10, 2014 08:22
206 Partial Content responses for Nancy
namespace Infrastructure
{
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using Nancy;
using Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using ServiceStack.Net30.Collections.Concurrent;
/// <summary>
@danbarua
danbarua / gist:3528413
Created August 30, 2012 13:21
RabbitMQ reliable consumer pattern
while (_isRunning)
{
try
{
if (channel == null || consumer == null)
{
try
{
_connection = factory.CreateConnection();
channel = _connection.CreateModel();
@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;
@danbarua
danbarua / gist:5356062
Last active November 23, 2016 06:22 — forked from HasAndries/gist:3135128
AngularJs directive for Bootstrap datepicker
angular.module('bDatepicker', []).
directive('bDatepicker', function(){
return {
require: '?ngModel',
restrict: 'A',
link: function ($scope, element, attrs, controller) {
var updateModel, onblur;
if (controller != null) {
#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 / gist:6520603
Created September 11, 2013 08:05
Custom version of EasyNetQ's AutoSubscriber
namespace Foo.Common.Messaging.EasyNetQ
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;