Skip to content

Instantly share code, notes, and snippets.

View srdjan's full-sized avatar

⊣˚∆˚⊢ srdjan

View GitHub Profile
@srdjan
srdjan / ddd.fsx
Created June 11, 2016 15:07 — forked from hodzanassredin/ddd.fsx
monadic ddd in fsharp
type Request<'i,'o,'k> = 'i * ('o -> 'k)
let bindRequest bind f (s,k) = s, fun v -> bind(k v,f)
type Id = int
type Entity<'e> = Entity of Id option * 'e
[<Measure>] type money
type User = {name : string; email : string; ballance : int<money>}
type Product = { name : string; quantity : int; price : int<money>}
type Email = {body:string; subject : string}
using System;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Abstractions.Logging;
using Raven.Bundles.Replication.Plugins;
using Raven.Json.Linq;
namespace RavenConflictResolverPlugin
{
public class LastInWinsReplicationConflictResolver
module BorrowABook =
type BookLoanProblem =
NotInCatalogue
| OutOnLoan
| InsufficientPermission
| Failed of string
type Book = Book
type BookModel = BookModel
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.0.49
Comment: https://keybase.io/crypto
wcFMA8NHQqEvqEzYAQ/+OjIJxVjUf1J6bbk7y6RBDrOTeKpryZYA7At4j9VT/3pr
bNrsir9UbnRz1JIE9NE+yHE/rSq/xRaolkXo9Rlh8OAj1FYhfHhti7Z7knKl6fJy
Ene3oo8HiJlFXmRSO0W9/nxyffNyL7RL2jgH4ITsArBm75/zkonstXzdO15yASb3
HWxPyb/kw68ixcUIW75n6MGgzmWwXyJov6gJalV6qq0s1eKNUe5VzCrgZr7oxeHL
G/KsFKq1tWMrqZx3B5OpcoFGX6DkjDj6pLvVrO0yIZ0XUcYgNE6ALeYD2LJZbFbl
kMEdCpscXwCTO1x/0lOat62im1qbN0f2g6RZUV4FpJEPD+Uxeu77h6tmLtooP4v1
@srdjan
srdjan / gist:4313558
Created December 16, 2012 21:58
let's start here... nicely written c# class...
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Simple.Data.Ado;
using Simple.Data.Ado.Schema;
namespace Simple.Data.SqlServer
{
@srdjan
srdjan / gist:4313546
Created December 16, 2012 21:56
little bit of noise removed from c#...
using System
using System.Collections.Generic
using System.Data
using System.Data.SqlClient
using System.Linq
using Simple.Data.Ado
using Simple.Data.Ado.Schema
namespace Simple.Data.SqlServer
class SqlSchemaProvider : ISchemaProvider
@srdjan
srdjan / gist:4297273
Created December 15, 2012 17:11
using Simple.Data from F# for fun and...
open Simple.Data
open Xunit
open Swensen.Unquote
open ImpromptuInterface.FSharp
[<Fact>]
let ``Simple.Data data provider test`` () =
Database.UseMockAdapter(new InMemoryAdapter())
let db = Database.Open()
db?Test?Insert(dynArg(1) ? Id, dynArg("Alice") ? Name)
@srdjan
srdjan / build.fsx
Created December 11, 2012 15:29
Simple FAKE CI script
#r @"../_tools/FAKE/FakeLib.dll"
#r @"../_tools/FAKE/MyFakeTasks.dll"
open Fake
open System.IO
open MyFakeTasks
let author = ["Srdjan Strbanovic"]
let release = @".\WinService\bin\release"
let debug = @".\WinService\bin\debug"
@srdjan
srdjan / AA.md
Created July 10, 2012 12:12 — forked from sadache/AA.md
Is socket.push(bytes) all what you need to program Realtime Web apps?

Is socket.push(bytes) all what you need to program Realtime Web apps?

One of the goals of Play2 architecture is to provide a programming model for what is called Realtime Web Applications.

Realtime Web Applications

Realtime Web Applications are applications making use of Websockets, Server Sent Events, Comet or other protocols offering/simulating an open socket between the browser and the server for continuous communication. Basically, these applications offer to users delivery of information as it is published without having the user periodically pinging the service.

There are quite a few web frameworks that target the development of this type of applications. Mostly, however, the solution is by providing an API that allows developers to push/receive messages from/to an open channel, something like:

class Entity extends Batman.Model
@field: (name, options) ->
@fields ?= {}
@fields[name] = options || {}
constructor: (attributes) ->
@attributes = {}
for name, options of @constructor.fields
@attributes['encode'] = true