Skip to content

Instantly share code, notes, and snippets.

View dmannock's full-sized avatar

Dan Mannock dmannock

View GitHub Profile
@dmannock
dmannock / fsharp_csharp_object_comparison.fs
Last active January 28, 2020 13:36
F# vs C# simple object create, read, print
// store a value on an immutable object, read it and print out
// F# valid program
type A = { Simples: string }
let a = { Simples = "this is nice" }
a.Simples |> printfn "%s"
// C# also does this o.O
public class MoarBrackets {
public readonly string Value;
@dmannock
dmannock / meetup_manc-haskell-group_introduction_notes_2018-07-05.txt
Last active August 2, 2018 18:20
Notes from the MHG (Manchester Haskell Group) first meetup
manchester haskell group 2018-07-05 First meetup (Ziferblat meeting room)
very quick notes - maybe useful?
good turnout (10 out of 14)!
attendees (in order left-to-right round the table):
adrian
yunis (obvs organiser)
dan (me)
steven?
@dmannock
dmannock / keybase.md
Created March 17, 2018 11:53
Keybase Verify

Keybase proof

I hereby claim:

  • I am dmannock on github.
  • I am dmannock (https://keybase.io/dmannock) on keybase.
  • I have a public key ASCZ4EPZcBAccfUv4uT3ywVplpFmQbIMs8I_1uEWOE9lZgo

To claim this, I am signing this object:

@dmannock
dmannock / Bacon_pancakes_infinite_repeat_version.html
Last active February 27, 2016 18:22
Bacon_pancakes_infinite_repeat_version
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.58/Bacon.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bacon Pancakes js Bin</title>
</head>
<body>
<div id="containsBacon"></div>
private Type TypeGroup
{
get
{
if (Type.IsGenericType && !Type.IsGenericTypeDefinition)
return Type.GetGenericTypeDefinition();
return Type;
}
}
@dmannock
dmannock / callbackChainer.js
Created December 15, 2015 12:53
js callback choiner (waterfall)
function wrap(call, cb) {
var args = [];
for (var i=1; i < call.args.length; i++) {
args.push(call.args[i]);
}
var thiscb = cb;
return function() {
var argsLen = arguments.length;
public class DelegateAdjuster
{
public static Action<BaseT> CastArgument<BaseT, DerivedT>(Expression<Action<DerivedT>> source) where DerivedT : BaseT
{
if (typeof(DerivedT) == typeof(BaseT))
{
return (Action<BaseT>)((Delegate)source.Compile());
}
ParameterExpression sourceParameter = Expression.Parameter(typeof(BaseT), "source");
public class CommandThrottler
{
private static readonly Dictionary<Type, object> observables = new Dictionary<Type, object>();
public static readonly TimeSpan DefaultThrottle = TimeSpan.FromMilliseconds(500);
public static readonly TimeSpan SmallThrottle = TimeSpan.FromMilliseconds(200);
public static readonly TimeSpan LargeThrottle = TimeSpan.FromSeconds(1);
public static readonly TimeSpan None = TimeSpan.Zero;
private IServiceBus _bus;
public class ServiceProxy
{
public static TimeSpan Timeout { get; protected set; }
public ServiceProxy()
{
Timeout = TimeSpan.FromSeconds(10);
}
public static class DynamicHelpers
{
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(dynamic dyn)
{
Dictionary<TKey, TValue> output = new Dictionary<TKey, TValue>();
foreach (var kvp in dyn as IDictionary<TKey, object>)
{
output.Add(
(TKey)Convert.ChangeType(kvp.Key, typeof(TKey)),