Skip to content

Instantly share code, notes, and snippets.

View haf's full-sized avatar
💹
currently succeeding...

Henrik Feldt haf

💹
currently succeeding...
View GitHub Profile
@haf
haf / gist:5629584
Last active January 23, 2019 20:59
Finding the private key of a Windows certificate from PowerShell/C#.
namespace PKI
{
class Results : IEquatable<Results>
{
internal static readonly Results NotFound = new Results
{
Directory = "",
KeyName = ""
};
@haf
haf / gist:5503331
Last active December 16, 2015 21:59
Edge cases GetEventStore API

Some examples of edge cases that have to be watched out for in GetEventStore, starting with the read API. Here's the F#-API type for ReadStreamEventsForwardAsync:

  /// <see cref="EventStore.ClientAPI.StreamEventsSlice" />
  type StreamEventsSlice =
    | NotFound of StreamId
    | Deleted of StreamId
    | Success of StreamSlice
  /// Convert a <see cref="EventStore.ClientAPI.StreamEventsSlice" /> to a
  /// ConnectionApi.EventsSlice.
@haf
haf / gist:5503321
Created May 2, 2013 16:16
Edge cases GetEventStore API

Some examples of edge cases that have to be watched out for in GetEventStore, starting with the read API. Here's the F#-API type for ReadStreamEventsForwardAsync:

  /// <see cref="EventStore.ClientAPI.StreamEventsSlice" />
  type StreamEventsSlice =
    | NotFound
    | Deleted
    | Success of StreamSlice
    /// Convert a <see cref="EventStore.ClientAPI.StreamEventsSlice" /> to a
    /// ConnectionApi.EventsSlice.
@haf
haf / gist:5467834
Created April 26, 2013 14:44
Nancy Testing crashes
System.InvalidOperationException
Something went wrong when trying to satisfy one of the dependencies during composition, make sure that you've registered all new dependencies in the container and inspect the innerexception for more details.
at Nancy.Bootstrapper.NancyBootstrapperBase`1.SafeGetNancyEngineInstance()
at Nancy.Bootstrapper.NancyBootstrapperBase`1.GetEngine()
at Nancy.Testing.Browser..ctor(INancyBootstrapper bootstrapper)
at Specs.When_binding.<.ctor>b__4() in ModelBinding_Specs.cs: line 105
Nancy.TinyIoc.TinyIoCResolutionException
Unable to resolve type: Nancy.NancyEngine
at Nancy.TinyIoc.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
at Nancy.TinyIoc.TinyIoCContainer.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)

@Lev I have considered that. It looks to me like a functional reactive programming patterns where you create projections/behaviours that you can compose together. Ambient monads, such as the transaction demonstrated in the example should be modelled to contain the functors (the computations that are the projections/behaviours - i.e. the binds (:: T x T -> T) that let the data flow through a pipeline inside a context) --> http://stackoverflow.com/questions/3870088/a-monad-is-just-a-monoid-in-the-category-of-endofunctors-whats-the-problem.

The problem being C# then: there's no way to contain computations statically, like what you can achieve with monads. You can do it dynamically using disposable observables though. I belive more in F#'s computation workflows in this case, giving access to a CLR interface that your behaviours (projections producing value) need to implement, that are then fed back into F# and the projection framework.

Once a framework for producing, joining and consuming (reacting to) values h

@haf
haf / gist:5301339
Last active December 15, 2015 18:09
$ vagrant provision
[default] Running provisioner: VagrantPlugins::Puppet::Provisioner::Puppet...
Running Puppet with dev.jobAd.appserver.pp...
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: /Stage[main]/Riak::Appconfig/File[/var/log/riak]/group: group changed 'root' to 'riak'
Notice: /Stage[main]/Riak::Appconfig/File[/var/lib/riak]/group: group changed 'root' to 'riak'
Notice: /Stage[main]/Riak::Appconfig/File[/usr/lib/riak]/group: group changed 'root' to 'riak'
Error: Could not start Service[riak]: Execution of '/sbin/service riak start' returned 1:
Error: /Stage[main]/Riak/Service[riak]/ensure: change from stopped to running failed: Could not start Service[riak]: Execution of '/sbin/service riak start' returned 1:
Notice: /Stage[main]/Riak/Service[riak]: Triggered 'refresh' from 1 events
@haf
haf / gist:5186846
Last active December 15, 2015 02:19
F# 2.0 MD5
MD5 (vendor/FSharp.Core.dll) = cf4b5f8cf939563f08b834d7d84dde25
There are three versions of F#.
2.0. 3.0, the open source version. 3.0, the Visual Studio version. Wtf?
During compile time, there is F# assembly version 2.0. There is F# assembly
version 4.0 and F# assembly version 4.3. The assembly version 4.0 runs on
WinRT/.Net 4.5 and is F# 2.0. The assembly version 4.3 runs on WinRT/.Net 4.5
and is F# 3.0. Wtf?
Then there's GAC 2.0 that can contain the above F# 2.0. This GAC doesn't know
@haf
haf / Gemfile
Last active December 14, 2015 03:49
Getting Puppet 3.1 working on Windows, Ruby 1.9.3
source "http://rubygems.org"
gem 'puppet', '=3.1.1'
gem 'windows-pr', '=1.2.2'
gem 'windows-api', '=0.4.0'
gem 'win32console', '=1.3.2'
gem 'win32-taskscheduler', '=0.2.2'
gem 'win32-service', '=0.7.2'
gem 'win32-security', '=0.1.4'
gem 'win32-process', '=0.6.5'
gem 'win32-eventlog', '=0.5.3'
Hi,
I'm trying to make Hiera look at nginx::params::varname, where 'varname' is the name of the variable that I request. Example:
class nginx::params {
$varname = 456
}
define site($varname = hiera('varname')) {
file { $varname: