Skip to content

Instantly share code, notes, and snippets.

View thefringeninja's full-sized avatar
🍿

João Bragança thefringeninja

🍿
View GitHub Profile
@thefringeninja
thefringeninja / plz.cs
Last active August 29, 2015 14:14
¯\_(ツ)_/¯
public static class RavenDocumentStore
{
static RavenDocumentStore()
{
using (Create())
{ }
}
private static Type FindAssemblyLoaderType<T>()
{
return (from type in typeof(T).Assembly.GetTypes()
public interface IHttpMessageSerializer
{
void Serialize(HttpResponseMessage response, Stream stream);
void Serialize(HttpRequestMessage request, Stream stream);
HttpResponseMessage DeserializeToResponse(Stream stream);
HttpRequestMessage DeserializeToRequest(Stream stream);
}
public class MessageContentHttpMessageSerializer : IHttpMessageSerializer
@thefringeninja
thefringeninja / gist:1110215
Created July 27, 2011 19:50
Sample log4* configuation
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="csg-rolling-file"
type="log4net.Appender.RollingFileAppender">
<file value="logs/csg-log" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value=".yyyyMMdd" />
<maxSizeRollBackups value="10" />
@thefringeninja
thefringeninja / Program.cs
Created April 13, 2012 07:01
Simple.Testing Doc Generator Pretty Print Enumerables
class Program
{
static void Main(string[] args)
{
SimpleRunner.RunAllInAssembly(typeof(Program).Assembly).ForEach(PrintSpec);
}
private static string NicePrint(object target)
{
if (target == null)
{
public abstract class RavenSingleProjectionSpecification<TViewModel>
: QuerySpecification<List<Event>, TViewModel>
{
public List<Event> Given = new List<Event>();
public RavenRelativeUri Key;
public RavenSingleProjectionSpecification()
{
var store = new EmbeddableDocumentStore
{
@thefringeninja
thefringeninja / gist:3185489
Created July 27, 2012 00:48
RabbitQueueBuilder Extension Method for Taking a URI
/*
AppHarbor/CloudAMQP supplies the CloudAMQP RabbitMQ info as a Uri in AppSettings;
this adds support for that.
most of this code is from the rabbitmq-dotnet-client.
*/
public static class RabbitExtensions
{
private static string UriDecode(string uri)
{
@thefringeninja
thefringeninja / gist:3297884
Created August 8, 2012 19:26
Raven + Nancy Pipeline
public static class RavenPipelineExtensions
{
public static void EnableRaven(this IPipelines pipelines, IDictionary<string, IDocumentStore> documentStores,
string ravenSessionKey)
{
documentStores.Keys.ForEach(
database =>
{
var key = ravenSessionKey + "." + database;
var documentStore = documentStores[database];
@thefringeninja
thefringeninja / CassetteFileAccessConfiguration.cs
Created August 10, 2012 01:20
Using Cassette.Nancy to reference image files
public class CassetteFileAccessConfiguration : IConfiguration<IFileAccessAuthorization>
{
#region IConfiguration<IFileAccessAuthorization> Members
public void Configure(IFileAccessAuthorization configurable)
{
configurable.AllowAccess(path => path.StartsWith("~/content/images"));
}
#endregion
<configuration>
<configSections>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor" />
</configSections>
<razor disableAutoIncludeModelNamespace="true">
<assemblies>
<add assembly="Cassette" />
<add assembly="Cassette.Nancy" />
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Nancy" />
@thefringeninja
thefringeninja / gist:3604430
Created September 2, 2012 20:50
New Relic + Nancy
using NewRelicAgent = NewRelic.Api.Agent.NewRelic; // protip: don't give class and namespace the same name. it's awkward.
public class NewRelicStartup : IStartup
{
private readonly IRouteResolver routeResolver;
public NewRelicStartup(IRouteResolver routeResolver)
{
this.routeResolver = routeResolver;
}