Skip to content

Instantly share code, notes, and snippets.

View mythz's full-sized avatar

Demis Bellot mythz

View GitHub Profile
@mythz
mythz / twitter.fsx
Created September 20, 2011 07:47
Async download and parse twitter user into a typed record with F#
#r "ServiceStack.Text.dll"
open System.Net
open System.IO
open ServiceStack.Text
type System.Net.WebRequest with
member x.GetResponseAsync() =
Async.FromBeginEnd(x.BeginGetResponse, x.EndGetResponse)
@mythz
mythz / FSharpStack.fs
Created September 21, 2011 07:01
Standalone HelloWorld F# WebServices on Mono w/ HttpListener
(* Stand-alone HelloWorld ServiceStack Web Service with F# on Mono/Windows using HttpListener
INFO: and C#/ASP.NET HelloWorld example at: http://servicestack.net/ServiceStack.Hello/
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FSharpStack.fs
3) sudo mono FSharpStack.exe
*)
open System
@mythz
mythz / FTweetStack.fs
Created September 21, 2011 08:27
Stand-alone ServiceStack Twitter API with F# on Mono/Windows using HttpListener
(* Stand-alone Twitter API ServiceStack Web Service with F# on Mono/Windows using HttpListener
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FTweetStack.fs
3) sudo mono FTweetStack.exe
*)
open System
open System.IO
@mythz
mythz / FastIsraelTaxCalculator.cs
Created September 24, 2011 04:19
Calculate Israel's fast with C#
using System;
namespace FastIsraelTaxCalculator
{
class MainClass
{
static readonly string[] DefaultAmounts = new[] { "5000", "5800", "9000", "15000", "50000" };
public static void Main (string[] args)
{
@mythz
mythz / FTweetStack.fs
Last active September 27, 2015 08:38
Twitter async web services with F# and ServiceStack running on Windows/OSX/Linux
(* Stand-alone Twitter API ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FTweetStack.fs
3) sudo mono FTweetStack.exe
*)
open System
open ServiceStack.ServiceHost
@mythz
mythz / FoldedIsraelTaxRates.fs
Created September 27, 2011 04:54
Simon Cousins Israel Tax Solution in F#
(* http://www.simontylercousins.netsolution to http://ayende.com/blog/108545/the-tax-calculation-challenge *)
let taxes salary =
let rates = [
40230.0m,0.45m;
21240.0m,0.33m;
14070.0m,0.3m;
8660.0m,0.23m;
5070.0m,0.14m;
0.0m,0.1m]
@mythz
mythz / Hello.fs
Created September 28, 2011 06:36
Stand-alone Hello World ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener
(* Stand-alone Hello World ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll Hello.fs
3) sudo mono Hello.exe
Read More: For the benefits of a ServiceStack Hello World Service see: http://www.servicestack.net/ServiceStack.Hello/
*)
@mythz
mythz / Global.asax
Created September 28, 2011 10:14
Hello World ServiceStack ASP.NET Web Service in F#
<%@ Application Inherits="HelloFSharp.Global" %>
@mythz
mythz / FTweetStackAsp.fs
Last active September 27, 2015 10:58
F# Twitter API ServiceStack ASP.NET Web Service on Windows/Mono/OSX
(* F# Twitter API ServiceStack ASP.NET Web Service on Windows/Mono/OSX
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll --target:library FTweetStackAsp.fs
3) mkdir bin && cp *.dll bin
4) echo "<%@ Application Inherits=\"FTweetStack.Global\" %>" >> Global.asax
5) copy Web.config mappings from http://www.servicestack.net/ServiceStack.Hello/
6) xsp4
*)
@mythz
mythz / Global.asax.cs
Created November 2, 2011 18:51
Hello World Example with Basic Auth RequestFilters
using System;
using Funq;
using ServiceStack.Common;
using ServiceStack.Common.Web;
using ServiceStack.Service;
using ServiceStack.ServiceClient.Web;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface.ServiceModel;
using ServiceStack.Text;
using ServiceStack.WebHost.Endpoints;