Skip to content

Instantly share code, notes, and snippets.

public abstract class StringValueObject<T> where T : StringValueObject<T>
{
public string Value { get; protected set; }
public static bool operator ==(StringValueObject<T> a, StringValueObject<T> b)
{
if (ReferenceEquals(a, b))
{
return true;
}
public struct Maybe<T> where T : class
{
public T Value { get; }
public bool HasValue => Value != null;
public bool HasNoValue => !HasValue;
private Maybe(T value)
{
@abenedykt
abenedykt / iisreset
Last active November 19, 2015 13:16
resetin remote iis :)
REM
REM if this does not work with a server, rcp server might be blocked with the firewal
REM so allow it on a firewall
REM
REM netsh advfirewall firewall add rule name="Remote IIS inetinfo" dir=in action=allow description="Remote IIS Service Managment" program="%systemroot%\System32\inetsrv\inetinfo.exe" enable=yes
REM
REM netsh advfirewall firewall add rule name="COM+ Remote Administration (All Programs)" dir=in action=allow description="" program="%windir%\system32\dllhost.exe" enable=yes localport=RPC protocol=tcp
iisreset zos-srv2
using System;
namespace Procent.DependencyInjection.app
{
public class UsersController
{
private readonly IApp _app;
public UsersController(IApp application)
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
@abenedykt
abenedykt / gist:fa141c9cd2bf3e2ea9ed
Created May 28, 2015 10:34
NSubstitute async eater :)
public static class NSubstituteHelper
{
public static void IgnoreAwaitForNSubstituteAssertion(this Task task)
{
}
}
@abenedykt
abenedykt / AutoNSubstituteAttribute
Last active January 31, 2018 10:17
AutoNSubstitute Attrubite to create objects with nsubstitute and populate propperties
public class AutoNSubstituteAttribute : AutoDataAttribute
{
public AutoNSubstituteAttribute()
: base(()=>new Fixture()
.Customize(new AutoPopulatedNSubstitutePropertiesCustomization())
)
{
}
}
@abenedykt
abenedykt / gist:d9e8371426e65590f4cf
Created July 4, 2014 12:49
converting string to function in c#
public static class Expressions
{
static string code = @"
public static class __CompiledExpr__
{{
public static {0} Run({1})
{{
return {2};
}}
@abenedykt
abenedykt / gist:69be1b0b9b3b055bdfeb
Last active August 29, 2015 14:03
"wisemans" reFUCKtroing
// version before refactoring
using (var key = Registry.CurrentUser.OpenSubKey(RegistryKey, true))
{
var obfuscator = new ViewNameObfuscator("whatever");
key.SetValue("password", obfuscator.Obfuscate(value));
key.Close();
}
// version after refactoring - the functionality remained the same - exacly the same
return ReadValueFromRegistry(PasswordKeyName, Deobfuscate);
If:
- you add and commit with the wrong email address in git, and
- your remote has a hook set up to prevent you from pushing with the bad address
Then you need to amend the author of your commit before push can succeed:
1. fix your email address in git config:
$ git config user.name "Your Name"