Skip to content

Instantly share code, notes, and snippets.

View johnazariah's full-sized avatar

John Azariah johnazariah

  • Microsoft Corporation
  • Brisbane, Queensland, Australia
  • 22:04 (UTC +10:00)
View GitHub Profile
[<AutoOpen>]
module SuccessOrFailure =
type SuccessOrFailure<'a> =
| Success of 'a
| Failure of exn
let point v = Success v
let (>>=) m f =
match m with
public class Program
{
public void Main()
{
var solution = new Directory
{
["global.json"] = new JObject
{
["projects"] = new JArray { "src", "test" }
},
type LF = (Argument, State) => (State, Result)
case class _then(f : LF)
case class _else(f : LF)
def _if (ifFunc: LF) (thenFunc: _then) (elseFunc: _else) : LF =
(a, state) => ifFunc(a, state) match {
case (_, Accepted) => thenFunc.f(a, state)
case _ => elseFunc.f(a, state)
}
@johnazariah
johnazariah / quick-select.fs
Last active August 29, 2015 14:17
Quick-Select & Quick-Sort in F#
// tail-recursive quick-select
let select vs k =
let rec selectImpl vs k result =
match vs with
| [] -> result
| head :: tail ->
let (less, more) = tail |> List.partition ((>=) head)
match List.length less with
| x when x < k -> selectImpl more (k - x) (less @ result)
@johnazariah
johnazariah / Attempt.fs
Last active August 29, 2015 14:17
Attempt computation expression
open System
[<AutoOpen>]
module Attempt =
type Result<'TSuccess> =
| Success of 'TSuccess
| Failure of Exception
// make sure f is pure, otherwise monad laws will fail
let (>>=) x f =
@johnazariah
johnazariah / infix-eval.fs
Last active August 29, 2015 14:16 — forked from anonymous/infix-eval.fs
2-op infix expression evaluator
module Parsing =
open System.Collections.Generic
let (|Mul|_|) ch = if ch = '*' then Some(fun a b -> a * b) else None
let (|Add|_|) ch = if ch = '+' then Some(fun a b -> a + b) else None
let (|Space|_|) (ch:Char) = if Char.IsWhiteSpace ch then Some(ch) else None
let (|Digit|_|) (ch:Char) = if Char.IsDigit ch then (new String ([|ch|])) |> Int32.Parse |> Some else None
type Token =
| Number of int
@johnazariah
johnazariah / 1_merge.sql
Last active August 29, 2015 14:11
Merge Tables in Oracle
DROP TABLE data_staging;
DROP TABLE data;
CREATE TABLE data_staging
(
id number(10) not null,
name nvarchar2(50) not null,
city nvarchar2(20)
);

Resilient Architectures for the cloud

Slide - Introduction

Ask these questions:

  • How many of you have deployed your applications for the cloud?
  • Have you ever had any downtown out of something you didn't do?
type Building =
{ left : int
right : int
height : int }
let buildings = []
let getHeight building = building.height
let getWidth building = building.right - building.left
let getArea building = getHeight building * getWidth building
@johnazariah
johnazariah / applicationHost.xdt
Created July 31, 2014 23:28
XDT to reconfigure Azure Websites server configuration
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<httpLogging xdt:Transform="SetAttributes(selectiveLogging)" selectiveLogging="LogSuccessful" >
</httpLogging>
</system.webServer>
</configuration>