Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / details.md
Last active August 29, 2015 14:22
Workshop - Lifestyles of the rich and frameworkless

Workshop - Lifestyles of the rich and frameworkless

Level: Intermediate

Tags: Javascript, Single page applications, HTML5, Webcomponents, Databinding, Routing, Dependency Injection

Abstract

Angular, Ember, Meteor, Backbone, the front-end framework space is a busy place indeed. You'd be forgiven for feeling a bit overwhelmed and unsure where to start, but more importantly you're likely to miss an important alternative: to ditch your frameworks altogether and go it alone. It's not for everyone, but this approach can be valuable and rewarding - not just for you but for your clients as well.

Pete is a software consultant and speaker based near London with almost 10 years of experience making web applications with ASP.net, specialising in API design and JavaScript browser-based applications. He's also a keen distributed systems enthusiast who enjoys helping clients solve their cloud-scale problems.

He is the author of Superscribe - an open source routing framework - and HTTP query library Linq to Querystring among others. Just recently he's embarked on a journey learning JVM and Scala, with a little Python thrown in to boot.

Pete is a software consultant, speaker & writer living near London, UK. With over 10 years of experience making web applications, he started off with C# and Javascript and nowadays likes to build distributed systems in Scala.

He enjoys running training courses and speaking at conferences. Sometimes he works on OSS, and one time he even finished something. He believes a microservice should be twice as large as half it's height.

@beyond-code-github
beyond-code-github / pipelining.fs
Last active August 29, 2015 14:11
Example of custom OWIN pipelines based on routing with Superscribe in F#
type RequireHttps(next: AppFunc) =
member this.Invoke(environment: IDictionary<string, obj>) : Task =
match environment.["owin.RequestScheme"].ToString() with
| "https" -> (next.Invoke(environment))
| other ->
environment.["owin.ResponseStatusCode"] <- 400 :> obj
environment.["owin.ResponseReasonPhrase"] <- "Connection was not secure" :> obj
Task.FromResult<obj>(null) :> Task
type RequireAuthentication(next: AppFunc) =
@beyond-code-github
beyond-code-github / composition.fs
Last active August 29, 2015 14:11
Example of composition with Superscribe in F#
type NameBeginningWith(letter) as this =
inherit GraphNode()
do
this.ActivationFunction <- fun data segment -> segment.StartsWith(letter)
this.ActionFunctions.Add(
"set_param_Name",
fun data segment -> data.Parameters?Add("Name", segment));
type Startup() =
@beyond-code-github
beyond-code-github / 1-packages.xml
Last active August 29, 2015 14:11
Hello world in Superscribe - F# style
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin.Hosting" version="3.0.0" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="Superscribe" version="0.4.4.15" targetFramework="net45" />
<package id="Superscribe.Owin" version="0.4.3.14" targetFramework="net45" />
</packages>
@beyond-code-github
beyond-code-github / Numerals.cs
Last active August 29, 2015 14:08
Converts numbers to roman numerals up to 3999
public static string From(int n){
var m="I,X,C,M,V,L,D".Split(',');var i=0;
Func<int,string>x=y=>new string(m[i++][0],y-48);
return(n+"").Reverse().Aggregate("",(r,c)=>(c<52?x(c):c==52?m[i]+m[4+i++]:c<57?m[i+4]+x(c-5):m[i]+m[1+i++])+r);
}
using Autofac;
using Xunit;
namespace LifetimeScope
{
public class Stackoverflow24762539
{
[Fact]
public void Repro()

Domain Driven Dilemmas

I'm fairly new to domain driven design and I've been scratching my head for a while over this issue.

Here are my domain rules

  • A Record entity has a document of key value pairs
  • We can update the document for a record by providing the updated key value pairs
  • When we update a document we must calculate some values according to some parsed expressions.
@beyond-code-github
beyond-code-github / test.markdown
Created March 18, 2014 14:47
Hello world requests/second

#Plain text, 10,000 req, 8 concurrent

  • Nancy - Nowin - 2642,2938,3435,2942,3216,4006 = 3204
  • Superscribe - Nowin - 4111,3767,3716,3350,3306,3742 = 3665
  • Nancy - System.Web - 3766,4042,3680,3944,4129,4065 = 3937
  • Superscribe - System.Web - 5724,5790,5506,4355,4293,5783 = 5241
  • Nancy - Helios - 5681,5817,5896,4407,4253,5854 = 5318
  • Superscribe - Helios - 6161,6788,6583,5685,4278,6872 = 6061
@beyond-code-github
beyond-code-github / changetracking.js
Created January 31, 2014 22:42
Change tracking implementation for knockout.js supporting complex objects
var getObjProperties = function (obj) {
var objProperties = [];
var val = ko.utils.unwrapObservable(obj);
if (val !== null && typeof val === 'object') {
for (var i in val) {
if (val.hasOwnProperty(i)) objProperties.push({ "name": i, "value": val[i] });
}
}