Skip to content

Instantly share code, notes, and snippets.

View johnazariah's full-sized avatar

John Azariah johnazariah

  • Microsoft Corporation
  • Brisbane, Queensland, Australia
  • 06:14 (UTC +10:00)
View GitHub Profile
@johnazariah
johnazariah / fspickler serialization.fs
Created May 20, 2014 05:27
Serialization with FsPickler
type AccountIdentifier =
| AccountIdentifier of System.Guid
type Account = {
Identifier : AccountIdentifier
Name : string
}
open Nessos.FsPickler // https://www.nuget.org/packages/FsPickler/
@johnazariah
johnazariah / mine.fs
Last active August 29, 2015 14:04
Interview Question
type Building = {
left : int
right : int
height : int
}
let buildings : Building[] = [| (* ... *) |]
let getHeight building = building.height
let getWidth building = building.right - building.left
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>
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

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