Skip to content

Instantly share code, notes, and snippets.

View Mark-Broadhurst's full-sized avatar
🎯
Focusing

Mark Broadhurst Mark-Broadhurst

🎯
Focusing
  • Kantar WorldPanel
  • London, UK
View GitHub Profile
private static T RunSync<T>(Func<Task<T>> task)
{
var oldContext = SynchronizationContext.Current;
var synch = new ExclusiveSynchronizationContext();
SynchronizationContext.SetSynchronizationContext(synch);
T ret = default(T);
synch.Post(async _ =>
{
try
{
@Mark-Broadhurst
Mark-Broadhurst / build.ps1
Last active August 6, 2018 15:16
invokeBuild Script MSBuild 14.0
cls
Write-Host "Checking NuGet"
$nugetPath = "$env:LOCALAPPDATA\NuGet\NuGet.exe"
if (!(Get-Command NuGet -ErrorAction SilentlyContinue) -and !(Test-Path $nugetPath)) {
if(! (Test-Path "$env:LOCALAPPDATA\NuGet"))
{
Write-Host "Creating directory"
@Mark-Broadhurst
Mark-Broadhurst / 01_SayHello.fsx
Created November 11, 2016 17:52 — forked from akimboyko/01_SayHello.fsx
Samples from "Actor-based Concurrency with F# and Akka.NET" http://bit.ly/FSharpAkkaNET
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor
@Mark-Broadhurst
Mark-Broadhurst / PaketBootstrap.fsx
Last active August 12, 2016 08:43
Paket Bootstrapper
if not (File.Exists "paket.exe") then
let url = "https://github.com/fsprojects/Paket/releases/download/3.12.0/paket.bootstrapper.exe" in use wc = new System.Net.WebClient() in let tmp = Path.GetTempFileName() in wc.DownloadFile(url, tmp);
File.Move(tmp,"paket.bootstrapper.exe");
System.Diagnostics.Process.Start("paket.bootstrapper.exe") |> ignore;;
@Mark-Broadhurst
Mark-Broadhurst / Script.fsx
Last active August 9, 2016 15:15
FParsec Guid Parser
#r "../packages/FParsec.1.0.2/lib/net40-client/FParsecCS.dll"
#r "../packages/FParsec.1.0.2/lib/net40-client/FParsec.dll"
open FParsec
open System
let test p str =
match run p str with
| Success(result, _, _) -> printfn "Success: %A" result
| Failure(errorMsg, _, _) -> printfn "Failure: %s" errorMsg
@Mark-Broadhurst
Mark-Broadhurst / JsonErrorHandlerAttribute.cs
Last active August 29, 2015 14:21
ASP.NET MVC Json Error Handler Attribute
namespace CII.Mercury.CRM
{
#region Namespaces
using System.Net;
using System.Web.Mvc;
#endregion
public class JsonErrorHandlerAttribute : FilterAttribute, IExceptionFilter
@Mark-Broadhurst
Mark-Broadhurst / ThreadStaticMultiSession
Created March 11, 2014 15:45
Nhibernate Thread Static CurrentSessionContext that supports multiple ISessionFactory's
using System;
using System.Collections;
using NHibernate.Context;
using NHibernate.Engine;
public class ThreadStaticMultiSession : MapBasedSessionContext
{
[ThreadStatic]
private static IDictionary sessionFactories;
@Mark-Broadhurst
Mark-Broadhurst / StringToEnum.cs
Created February 25, 2014 13:14
NHibernate StringToEnum abstract class (Allows you to store an enum as a string)
#region Namespaces
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
#endregion
@Mark-Broadhurst
Mark-Broadhurst / MultiColDateTime.cs
Created February 25, 2014 13:11
NHibernate Multi-Column DateType (When day month and year are in different columns)
#region Namespaces
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
#endregion
@Mark-Broadhurst
Mark-Broadhurst / Program.cs
Last active March 9, 2020 21:37
Lucence Spatial Search 3.0.3
namespace LuceneExample
{
#region Namespaces
using System;
using System.Globalization;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Documents;
using Lucene.Net.Index;