Skip to content

Instantly share code, notes, and snippets.

<!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();
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)
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)();
}
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)();
}
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)
{
<!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) {
@panesofglass
panesofglass / LetterCount.html
Created March 14, 2010 19:38 — forked from mattpodwysocki/LetterCount.html
mattpodwysocki: Quick letter counter from FlapJax demos to RxJS and jQUery
<!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>
#!/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
@panesofglass
panesofglass / ClickAggregate.html
Created February 17, 2010 01:21 — forked from mattpodwysocki/ClickAggregate.html
Rx JavaScript mouse clicks
<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;
});
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 =