This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" > | |
<head> | |
<title>GetJSON</title> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script src="rx.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
Rx.Observable.GetJSON = function(url, data) { | |
var subject = new Rx.AsyncSubject(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Collections.Generic | |
type IMonoid<'T> = | |
abstract member mempty : unit -> 'T | |
abstract member mappend : 'T * 'T -> 'T | |
type MonoidAssociations private() = | |
static let associations = new Dictionary<Type, obj>() | |
static member Add<'T>(monoid : IMonoid<'T>) = associations.Add(typeof<'T>, monoid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IObservable<Stream> GetRequestStreamAsync(this WebRequest request) | |
{ | |
return Observable.FromAsyncPattern<Stream>(request.BeginGetRequestStream, request.EndGetRequestStream)(); | |
} | |
public static IObservable<WebResponse> GetResponseAsync(this WebRequest request) | |
{ | |
return Observable.FromAsyncPattern <WebResponse>(request.BeginGetResponse, request.EndGetResponse)(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IObservable<WebResponse> GetResponseAsync(this WebRequest request) | |
{ | |
return Observable.FromAsyncPattern <WebResponse>(request.BeginGetResponse, request.EndGetResponse)(); | |
} | |
public static IObservable<Stream> GetResponseStreamAsync(this WebRequest request) | |
{ | |
return Observable.FromAsyncPattern <Stream>(request.BeginGetRequestStream, request.EndGetRequestStream)(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = WebRequest.Create("http://github.com/"); | |
var html = from response in request.GetResponseAsync() | |
let responseStream = response.GetResponseStream() | |
let reader = new StreamReader(responseStream) | |
select reader.ReadToEnd(); | |
var htmlSub = html.Subscribe(Console.WriteLine); | |
public static IObservable<WebResponse> GetResponseAsync(this WebRequest request) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" > | |
<head> | |
<title>Dictionary Suggest</title> | |
<link rel="stylesheet" href="demo.css"/> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script src="rx.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function createSearchRequest(term) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" > | |
<head> | |
<title>Letter Count</title> | |
<link rel="stylesheet" href="demo.css"/> | |
<style type="text/css"> | |
body {text-align: center; | |
background-color: #CCFFCC; | |
color: #006600;} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Ensuring directory" | |
mkdir -p ~/src/mono | |
cd ~/src/mono | |
curr=`pwd` | |
echo "Changed to $curr" | |
MONO_PREFIX=/usr/local/mono | |
cat << EOF > mono_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script src="rx.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
var click = Rx.Observable.FromHtmlEvent($("#scanButton").context, "click"); | |
var dblClick = Rx.Observable.FromHtmlEvent($("#scanButton").context, "dblclick"); | |
var clickAggregate = click.Merge(dblClick).Scan(0, function(acc, x) { | |
return acc + 1; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (?) (targetObject : obj) (targetMember:string) : 'TargetResult = | |
let targetResultType = typeof<'TargetResult> | |
if not (FSharpType.IsFunction targetResultType) | |
then | |
let cs = CallSite<Func<CallSite, obj, obj>>.Create(Binder.GetMember(CSharpBinderFlags.None, targetMember, null, [| CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) |])) | |
unbox (cs.Target.Invoke(cs, targetObject)) | |
else | |
if not (FSharpType.IsFunction targetResultType) then failwithf "%A is not a function type" targetResultType | |
let domainType,_ = FSharpType.GetFunctionElements targetResultType | |
let domainTypes = |