Skip to content

Instantly share code, notes, and snippets.

@NickCraver
NickCraver / Craver-Paradox.ps1
Last active April 20, 2022 03:05
My PowerShell PoshGit theme (used with Cmder)
#requires -Version 2 -Modules posh-git
# This is a tweaked version of https://github.com/JanJoris/oh-my-posh/blob/master/Themes/Paradox.psm1
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@sdieunidou
sdieunidou / rabbitmq.txt
Created October 22, 2015 19:51
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@kkozmic
kkozmic / AppSettingsAttribute.cs
Last active June 12, 2020 13:41
Strongly typed configuration using Castle DictionaryAdapter requires castle.core nuget package
[AttributeUsage(AttributeTargets.Interface,AllowMultiple = false)]
public class AppSettingsAttribute : KeyPrefixAttribute, IDictionaryPropertyGetter, IPropertyDescriptorInitializer
{
public AppSettingsAttribute(string keyPrefix) : base(keyPrefix)
{
}
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue,
PropertyDescriptor property, bool ifExists)
{
@mausch
mausch / gist:6774627
Created October 1, 2013 06:37
Applicative validation is simple.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
// As opposed to magic validation libraries that rely on reflection and attributes,
// applicative validation is pure, total, composable, type-safe, works with immutable types, and it's easy to implement.
public abstract class Result<T> {
private Result() { }
@PaulStovell
PaulStovell / Bootstrapper.cs
Created May 9, 2013 10:03
The Octopus Nancy error handling strategy
protected override void RequestStartup(ILifetimeScope requestContainer, IPipelines pipelines, NancyContext context)
{
pipelines.OnError.AddItemToEndOfPipeline((z, a) =>
{
log.Error("Unhandled error on request: " + context.Request.Url + " : " + a.Message, a);
return ErrorResponse.FromException(a);
});
base.RequestStartup(requestContainer, pipelines, context);
}
@miklund
miklund / gist:3838023
Created October 5, 2012 04:07
FAKE ExecProcess build target example
let fslex = @"packages\FSPowerPack.Community.2.1.3.1\Tools\fslex.exe"
let parserDir = @".\LiteMedia.Dsl\"
// FsParse
Target "FsYacc" (fun _ ->
let result =
ExecProcess (fun info ->
info.FileName <- fsyacc
info.Arguments <- parserDir + "parser.fsy --module Parser"
) (System.TimeSpan.FromMinutes 1.)
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bentruyman
bentruyman / Custom.css
Created August 17, 2011 00:30
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@felipeleusin
felipeleusin / EnsureHelper.cs
Created April 1, 2011 21:24
Delete Trigger to Ensure Unique Constraints
public static class EnsureHelper
{
private const string EnsureUniqueConstraint = "Ensure-Unique-Constraint";
public static IList<PropertyInfo> GetPropertiesFromMetadata(JObject metadata)
{
var clrType = metadata.Value<string>("Raven-Clr-Type");
if (clrType != null)
{
@ilkerde
ilkerde / gist:864508
Created March 10, 2011 17:26
What do you think about the type signature of this method ?!?
public IEnumerable<Answer> GetAll()
{
List<Answer> answers = GetAnswers();
return answers;
}