Skip to content

Instantly share code, notes, and snippets.

View btompkins's full-sized avatar

Brendan Tompkins btompkins

View GitHub Profile
var client = new HttpClient();
client.DefaultHeaders.Accept.Add("text/xml");
var resp = client.Get("http://contoso.com/contacts/1");
resp.Content.ReadAsXmlSerializable<Contact>();
public class Location
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
public class LocationProcessor : Processor<string, string, Location>
{
public LocationProcessor()
{
spawn-fcgi -s /var/run/munin/fastcgi-graph.sock -U www-data \
-u munin -g munin /usr/lib/cgi-bin/munin-cgi-graph
spawn-fcgi -s /var/run/munin/fastcgi-html.sock -U www-data \
-u munin -g munin /usr/lib/cgi-bin/munin-cgi-html
location ^~ /cgi-bin/munin-cgi-graph/ {
fastcgi_split_path_info ^(/cgi-bin/munin-cgi-graph)(.*);
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/munin/fastcgi-graph.sock;
include fastcgi_params;
}
location /munin/static/ {
alias /etc/munin/static/;
}
@btompkins
btompkins / gist:4392572
Last active December 10, 2015 06:08
Nancy Bootstrapper for using the NServiceBus' container.
using System;
using System.Collections.Generic;
using System.Linq;
using NServiceBus;
using NServiceBus.ObjectBuilder.Common;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Diagnostics;
public class NServiceBusContainerBootstrapper : NancyBootstrapperWithRequestContainerBase<IContainer>
namespace Nancy.Demo.Hosting.Self
{
using System;
using System.Diagnostics;
using Nancy.Hosting.Self;
class Program
{
static void Main()
using System;
using Nancy.Hosting.Self;
using Topshelf;
namespace Nancy.Demo.Hosting.TopShelf
{
public class NancySelfHost
{
private NancyHost _nancyHost;
@btompkins
btompkins / index.php
Last active December 11, 2015 05:08
When using a custom loop.php and a reverse front end cache like NGINX, you'll need to emit the Last-Modified header, this index.php file will do that, otherwise your front-end cache won't expire when a blog is updated.
<?php
$last_updated = $wpdb->get_var( "SELECT last_updated FROM " . $wpdb->blogs. " WHERE public = '1' order by
`last_updated` desc limit 1");
if(isset($last_updated)){
$post_mod_date=date("D, d M Y H:i:s",strtotime($last_updated));
header('Last-Modified: '.$post_mod_date.' GMT');
}
using Ducksboard;
using Ducksboard.Objects;
using log4net.Appender;
using log4net.Core;
namespace Logging.DucksboardLog4NetLogger
{
public class DucksboardAppender : AppenderSkeleton
{
private static DucksboardClient _ducksboardClient;
<log4net>
<appender name="DucksboardAppender" type="DucksboardLog4NetLogger.DucksboardAppender">
<apiKey value="[your api key]" />
<widgetId value="[your widget id]" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date | %-5level | %message~%newline" />
</layout>
</appender>
<logger name="[your logger name]">
<level value="ALL" />