Skip to content

Instantly share code, notes, and snippets.

View davepermen's full-sized avatar

David Spörri davepermen

View GitHub Profile
@davepermen
davepermen / Helpers
Created April 3, 2013 19:46
Static File Content Stuff
public class FileContent
{
NancyConventions conventions;
public FileContent(NancyConventions conventions)
{
this.conventions = conventions;
}
public string this[string requestFile]
this.get(/^\/([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])([\w\!\?-]+)?$/, function (context, year, month, day) {
sandbox.publish('statechange', '/events', { name: year + '-' + month + '-' + day });
});
@davepermen
davepermen / Main.cs
Created April 11, 2013 00:31 — forked from anonymous/Main.cs
Windows Phone 8 LiveTile Generator using NancyFx
using Nancy;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
using System.Web;
namespace Live_Tile_Generator
{
public class Main : NancyModule
@davepermen
davepermen / Demo.js
Last active December 16, 2015 08:08
Simple jquery less mini "sammyjs"
Path.setup(function () {
this.get('/yadda', function () {
document.querySelector('h1').innerHTML = "OMG";
});
this.get('/yaddaweeehhh', function () {
document.querySelector('h1').innerHTML = "<a href='/yaddaNEW'>NEW LINK!!!!</a>";
});
this.get('/yaddaNEW', function () {
document.querySelector('h1').innerHTML = "OMG!!";
});
@davepermen
davepermen / Example.js
Created April 17, 2013 16:32
More modular version of mini Sammyjs without jQuery, now with the Routing extracted and independent, for further usage outside of the window.history part.
Path.setup(new Route(function () {
this.get('/yadda', function () {
document.querySelector('h1').innerHTML = "OMG";
});
this.get('/yaddaweeehhh', function () {
document.querySelector('h1').innerHTML = "<a href='/yaddaNEW'>NEW LINK!!!!</a>";
});
this.get('/yaddaNEW', function () {
document.querySelector('h1').innerHTML = "OMG!!";
});
//davepermen
interface IFilterer
{
Expression<Func<Message, bool>> Filter(string Value);
}
static class Filterer
{
static public IFilterer Get(FilterParameterOperatorEnum op)
{
// your code, shortened
public class FilterFactory
{
public Expression<Func<Message, bool>> Filter(FilterGroupParameter filterGroupParameter)
{
var factory = FiltererFactoryFactory.Get(filterGroupParameter.Key);
return factory.Get(filterGroupParameter);
}
}
// your code, shortened
public class FilterFactory
{
public Expression<Func<Message, bool>> Filter(FilterGroupParameter filterGroupParameter)
{
var factory = FiltererFactoryFactory.Get(filterGroupParameter.Key);
return factory.Get(filterGroupParameter);
}
}
@davepermen
davepermen / gist:5758139
Created June 11, 2013 15:59
my routing thingy
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
</head>
<body>
<p></p>
<h1></h1>
@davepermen
davepermen / demo.js
Created June 14, 2013 13:57
Tiny Async Handler in JS
var get = function (path, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
if (this.status === 200) {
callback(this.responseText);
}
};
xhr.open('get', path);
xhr.send();
};