Skip to content

Instantly share code, notes, and snippets.

View jobjo's full-sized avatar

Joel Bjornson jobjo

  • London
View GitHub Profile
.myValidIcon
{
width : 20px;
height : 20px;
background-color: Green;
}
.myErrorIcon
{
width : 20px;
let options = new MapOptions(8, center, MapTypeId.ROADMAP)
let map = new Google.Maps.Map(mapElement.Body, options)
// Create the marker
let markerOption = new MarkerOptions(center)
markerOption.Map <- map
let marker = new Marker(markerOption)
// Function for setting mark the lat/long.
let setLatLong (latLong: LatLng) =
type UserInfo = { Name: string; Email : string}
module Server =
[<Rpc>]
let GetUsers () =
Db.GetUsers // Your db call
|> Seq.map (fun u ->
{
Name = u.Name
Formlet.Do {
let! x = Controls.RadioButtonGroup None [("item1","item1");("item2","item2");("item3","item3")]
return x
}
|> Formlet.Map Some
|> Formlet.InitWith None
|> Enhance.WithSubmitAndResetButtons
|> Enhance.WithFormContainer
open M
Foo ()
[<JavaScript>]
let InputDate () =
let inputId = NewId ()
Controls.InputDatepicker None
|> Formlet.MapElement (fun el -> Div [Attr.Id inputId] -< [el])
|>! OnAfterRender (fun el ->
JQuery.JQuery.Of("#" + inputId).Find("input").Val("").Ignore
)
type MyControl() =
inherit IntelliFactory.WebSharper.Web.Control ()
[<JavaScript>]
override this.Body =
let inpCtrl str =
Controls.Input str
|> Enhance.WithSubmitButton
|> Enhance.WithFormContainer
var createCounter = function() {
var x = 0;
return (
function () {
x = x + 1;
return x;
}
);
}
Formlet.Do {
let! n = Controls.Button "Add Tabs"
return!
List.init n (fun ix ->
("Tab " + string ix, Controls.Input "")
)
|> Controls.TabsChoose
}
@jobjo
jobjo / Aggregations.fs
Last active August 29, 2015 14:10
Aggregating elements in F#
open System
open System.Collections.Generic
// The problem I'm addressing is aggregating elements from a tree.
// In my particular scenario I'm interested in collecting all leaf nodes
// into an array. The fundamental problem is captured by the different versions
// of aggregate, listed below. The functions are merely simulating the branching
// and aggregation steps. I'm not concerned about the order of the elements.
// In the comments are the total times in milliseconds
// running the functions with n = 1e6. That is generating an array of roughly