Skip to content

Instantly share code, notes, and snippets.

@dgfitch
dgfitch / simple_wcf.fs
Created Nov 3, 2010
A sample WCF host and client in F#, extremely simple but a starting point
View simple_wcf.fs
open System
open System.ServiceModel
open System.ServiceModel.Description
[<ServiceContract(ConfigurationName = "PublishService", Namespace = "http://xyz.gov/PublishService")>]
[<ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)>]
type IPublishService =
[<OperationContract(Name="TestMethod")>]
abstract member TestMethod : name:string -> string
@decisionmechanics
decisionmechanics / spark_random_forest.R
Created Mar 21, 2017
Predicting wine quality using a random forest classifier in SparkR
View spark_random_forest.R
library(readr)
library(dplyr)
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv"
df <-
read_delim(url, delim = ";") %>%
dplyr::mutate(taste = as.factor(ifelse(quality < 6, "bad", ifelse(quality > 6, "good", "average")))) %>%
dplyr::select(-quality)
@CarstenKoenig
CarstenKoenig / Hylo.fs
Last active Feb 19, 2018
Factorial using a Hylomorphism in F#
View Hylo.fs
type List<'i,'r> = Nil | Cons of 'i*'r
type FixList<'i> = FixList of List<'i,FixList<'i>>
let rec fmap (f : 'a -> 'b) (l : List<'i,'a>) : List<'i,'b> =
match l with
| Nil -> Nil
| Cons (x, tail) -> Cons (x, f tail)
// you can express hylo directly without using ana and cata (by either following the
View Differ.fs
type DifferenceType<'TKey, 'T> =
| Added of 'TKey * 'T
| Removed of 'TKey * 'T
| Modified of 'TKey * 'T * 'T * seq<string * (string * string)> with
member this.Key =
match this with
| Added (key, _)
| Removed (key, _)
| Modified (key, _, _, _) -> key
@ArthurHub
ArthurHub / ClipboardHelper.cs
Last active May 23, 2019
Helper class for setting HTML and plain text formatting to clipboard (http://theartofdev.com/2014/06/12/setting-htmltext-to-clipboard-revisited/)
View ClipboardHelper.cs
/// <summary>
/// Helper to encode and set HTML fragment to clipboard.<br/>
/// See http://theartofdev.com/2014/06/12/setting-htmltext-to-clipboard-revisited/.<br/>
/// <seealso cref="CreateDataObject"/>.
/// </summary>
/// <remarks>
/// The MIT License (MIT) Copyright (c) 2014 Arthur Teplitzki.
/// </remarks>
public static class ClipboardHelper
{
@isaacabraham
isaacabraham / io-monad.fsx
Last active May 28, 2019
F# port of the first half of John De Goes "FP to the max" (https://www.youtube.com/watch?v=sxudIMiOo68)
View io-monad.fsx
#load @".paket\load\net452\FSharpPlus.fsx"
open FSharpPlus
open System
[<AutoOpen>]
module rec IO =
let run (IO computation) = computation()
type IO<'T> =
@vjeux
vjeux / x.md
Last active Jun 19, 2019
Ocaml / functional programming
View x.md

I'm taking down this post. I just posted this as a side comment to explain a sentence on my latest blog post. This wasn't meant to be #1 on HN to start a huge war on functional programming... The thoughts are not well formed enough to have a huge audience. Sorry for all the people reading this. And please, don't dig through the history...

@robert-claypool
robert-claypool / app_offline.htm
Created Jul 21, 2015
A simple "app offline" template for ASP.NET
View app_offline.htm
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Offline</title>
</head>
<body style="margin:3em;font-family:sans-serif">
<h2>Offline</h2>
<p>This site is offline for maintenance.</p>
<!--
@battermann
battermann / io.fsx
Last active Jul 6, 2020
IO Monad in F#
View io.fsx
[<AutoOpen>]
module IO =
type IO<'a> =
private
| Return of (unit -> 'a)
| Suspend of (unit -> IO<'a>)
let rec run x =
match x with
| Return v -> v()
@phrawzty
phrawzty / 2serv.py
Last active Oct 9, 2020
simple python http server to dump request headers
View 2serv.py
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
You can’t perform that action at this time.