Skip to content

Instantly share code, notes, and snippets.

View codeprogression's full-sized avatar

Richard Cirerol codeprogression

View GitHub Profile
@codeprogression
codeprogression / ContentNegotiationPipelineItem.cs
Created February 28, 2012 12:17
Nancy pipeline handler for content negotiation
public class ContentNegotiationPipelineItem : PipelineItem<Action<NancyContext>>
{
public ContentNegotiationPipelineItem()
: base("Content Negotiation", action)
{
}
static readonly Action<NancyContext> action = ctx =>
{
@codeprogression
codeprogression / CustomFormatterExtensions.cs
Created March 1, 2012 18:46
A NancyFx IResponseFormatter extension to do content-negotiation
using System;
using System.Linq;
using Nancy.ViewEngines;
namespace Nancy
{
public static class CustomFormatterExtensions
{
public static Response AsNegotiated<TModel>(this IResponseFormatter formatter, TModel model, HttpStatusCode statusCode = HttpStatusCode.OK, Tuple<Func<Response>, string> defaultResponse = null)
{
@codeprogression
codeprogression / chrome.tools.css
Created April 10, 2012 01:23
Chrome tools font size
/* larger font size */
body.platform-mac.platform-mac-snowleopard .monospace,
body.platform-mac.platform-mac-snowleopard .source-code,
body.platform-windows .monospace, body.platform-windows .source-code ,
body.platform-linux .monospace, body.platform-linux .source-code {
font-size: 20px !important;
}
@codeprogression
codeprogression / Repository
Created June 2, 2012 15:56
In memory place repository
public class Repository
{
private static readonly IList<Place> Places = new List<Place>
{
new Place(0, "Pastini Pastaria", "Lunch", "Dinner", "Pasta", "Beer", "Wine"),
new Place(1, "Deschutes Brewery", "Lunch", "Dinner", "Pasta", "Beer", "Wine"),
new Place(2, "Stumptown Coffee", "Breakfast", "Coffee"),
new Place(3, "Voodoo Doughnuts", "Breakfast", "Coffee"),
new Place(4, "J Cafe", "Breakfast", "Lunch", "Coffee"),
};
@codeprogression
codeprogression / OAuth2AuthenticationClient.cs
Created June 22, 2012 21:45
OAuth2 Authentication (Consumer) for NancyFX
public class OAuth2AuthenticationClient
{
public static void Enable(IPipelines pipelines, OAuth2AuthenticationClientConfiguration clientConfiguration)
{
if (!clientConfiguration.IsValid)
throw new OAuth2AuthenticationClientConfiguration.InvalidConfigurationException();
pipelines.BeforeRequest.AddItemToStartOfPipeline(GetLoadAuthenticationHook(clientConfiguration));
pipelines.AfterRequest.AddItemToEndOfPipeline(GetRedirectToProviderHook(clientConfiguration));
}
@codeprogression
codeprogression / authspike.cs
Created June 25, 2012 21:16
Playing with Nancy.Auth
public static class Auth
{
public static AuthenticationProviderConfiguration Configuration;
public static void Enable(IPipelines pipelines, AuthenticationProviderConfiguration configuration)
{
pipelines.AfterRequest.AddItemToEndOfPipeline(ctx=>
{
if (ctx.Response.StatusCode==HttpStatusCode.Unauthorized)
{
@codeprogression
codeprogression / gist:3503535
Created August 28, 2012 20:03
Sample HTML page with Twitter's Bootstrap, Ryan Fait's Sticky Footer, and a full-width footer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="Martin Bean" />
<title>Twitter&rsquo;s Bootstrap with Ryan Fait&rsquo;s Sticky Footer</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style>
html, body {
height: 100%;
@codeprogression
codeprogression / removebranch
Last active October 11, 2015 11:58
Removing local and remote branches (for origin remote, while excluding upstream remote)
# To delete all merged local branches (excluding non-origin remotes)
git branch --merged master | grep -v 'master$' | xargs git branch -d
# To delete all merged remote branches (excluding non-origin remotes)
git branch -r --merged master | grep 'origin' | sed 's/ *origin\///' | grep -v 'master$' | xargs -i% git push origin :%
# To remove orphaned remote branch references
git remote | xargs -I% git remote prune %
@codeprogression
codeprogression / myspec.spec.js
Created December 6, 2012 18:34
Jasmine runner for multiple specs (AMD)
define(['path/to/source', 'jasmine', 'jasmine-ajax'], function (source, jasmine) {
describe('spec description', function(){
// Add specs here
};
});
@codeprogression
codeprogression / specrunner.html
Created December 6, 2012 18:39
Jasmine runner for multiple specs (non-AMD)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
<script type="text/javascript" src="../vendor/jquery.js" ></script>
<script type="text/javascript" src="../vendor/require.js" ></script>
<script type="text/javascript" src="lib/jasmine.js" ></script>