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 / 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);
}
@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 / 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 / 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 / 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.

@beyond-code-github
beyond-code-github / TeacherList.html
Last active August 29, 2015 14:27
Teachers list markup
<h1>List of teachers</h1>
<form action="api/teachers">
<input type="text" id="name" />
<input type="text" id="notes" />
<input type="submit" id="addNewButton" />
</form>
<table id="dataTableTarget">
</table>
@beyond-code-github
beyond-code-github / StudentList.html
Last active August 29, 2015 14:27
Students list markup
<h1>List of students</h1>
<form action="api/students">
<input type="text" id="name" />
<input type="text" id="notes" />
<input type="submit" id="addNewButton" />
</form>
<table id="dataTableTarget">
</table>
@beyond-code-github
beyond-code-github / list.html
Created August 12, 2015 06:59
Generic list markup
<h1>@Model.ListTitle</h1>
<form action="@Model.PostUrl">
<input type="text" id="name" />
<input type="text" id="notes" />
<input type="submit" id="addNewButton" value="Add" />
</form>
<table id="dataTableTarget">
</table>
@beyond-code-github
beyond-code-github / list-2.html
Created August 19, 2015 06:29
Generic list markup including added feature with toggle logic
<h1>@Model.ListTitle</h1>
<form action="@Model.PostUrl">
<input type="text" id="name" />
<input type="text" id="notes" />
<input type="submit" id="addButton" value="Add" />
</form>
@if (Model.RequiresBulkUpload) {
<form id="bulkUpload">
@beyond-code-github
beyond-code-github / teacherconfig.cs
Last active August 29, 2015 14:27
Example of teaher list config run amok
var teacherListConfig = new ListConfig()
{
ListTitle = "List of Teachers",
PostUrl = "api/teachers",
GetUrl = "api/teachers",
RequiresBulkUpload = true,
AllowSave = true,
ReadOnlyUnlessAdmin = false,
PageSize = 50,
ValidateNames = true,