Skip to content

Instantly share code, notes, and snippets.

@Kimserey
Kimserey / gist:567330d3fc9cf91d75a3
Created July 6, 2015 04:19
Simple file upload directive in angularjs
(function () {
'use strict';
angular
.module('app')
.directive('myPhoto', myPhoto);
function myPhoto() {
var directive = {
@Kimserey
Kimserey / Websharper_AjaxCallToRestApi.fs
Last active August 29, 2015 14:27
Snippet Websharper - UI.Next using Ajax call to test REST API
namespace UINextAjax
open System
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
[<JavaScript>]
@Kimserey
Kimserey / Websharper_ChangeOfPages_SPA
Last active August 29, 2015 14:27
Simplistic implementation of SPA by changing page based on a Page reactive variable. Websharper blog post, Structuring Non-Linear Sites: http://websharper.com/blog-entry/3965/structuring-web-applications-with-websharper-ui-next
namespace UINextRouterTest
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
[<JavaScript>]
@Kimserey
Kimserey / Client.fs
Last active August 29, 2015 14:27
Websharper Router test
namespace UINextRouterTest
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
[<JavaScript>]
namespace UINextRouterTest
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
[<JavaScript>]
@Kimserey
Kimserey / BootstrapUI.fs
Last active September 14, 2017 14:19
SPA UI.Next Bootstrap
[<JavaScript>]
module BootstrapUI =
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
module Button =
type private ButtonColor =
| Default
| Primary
@Kimserey
Kimserey / Run.cmd
Last active September 30, 2015 22:09
Sqlite backup script
@echo off
cls
C:\"Program Files (x86)"\"Microsoft SDKs"\F#\4.0\Framework\v4.0\Fsi.exe .\script.fsx %1 %2 %3
@Kimserey
Kimserey / domain.fs
Last active October 1, 2015 22:14
Compile a script.fsx and get out a result from a console app fsharp. FSharp.Core.sigdata / FSharp.Core.optdata must be added to the project. Domain is in a separate library project, script.fsx and Program project reference the Domain library.
module Domain.Core
type Breed =
| Papillon
| Corgy
type Dog =
{ breed : Breed
name : string }
override x.ToString() =
@Kimserey
Kimserey / client.fs
Created October 20, 2015 08:49
Drag and drop sortable with html5 sortable
namespace DragnDropUInNext
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
open WebSharper.UI.Next.Html
open WebSharper.JQueryUI
@Kimserey
Kimserey / macro.fs
Last active December 16, 2015 03:09
W# Macro to get a config object constructed before JS built. The macro can then be used to access the config from the W# JavaScript annotated code. The advantage is that we have full flexibility in getConfig as it is before JS compilation.
type private ConfigMacro () =
interface M.IMacro with
member this.Translate(q, tr) =
match q with
| Q.CallOrCallModule (_, []) ->
let rec convert (obj: obj) =
match obj.GetType() with
| ty when ty.IsGenericType && ty.GetGenericTypeDefinition() = typedefof<list<_>> ->
C.NewArray <| (obj :?> seq<_> |> List.ofSeq |> List.map convert)
| ty when ty.IsPrimitive || ty = typeof<string> -> !~ (C.String (string obj))