Skip to content

Instantly share code, notes, and snippets.

View Thorium's full-sized avatar

Tuomas Hietanen Thorium

View GitHub Profile
@AndrewNewcomb
AndrewNewcomb / WebSocketServer.fs
Last active January 9, 2017 18:58
OLD from 2010 ... Updated example of using F# MailboxProcessor against an HTML5 WebSocket (in Google Chrome)
// Example of using F# MailboxProcessor against an HTML5 WebSocket (in Google Chrome)
// taken from http://v2matveev.blogspot.com/2010/04/mailboxprocessors-practical-application.html
// and then modified to work with the revised WebSocket protocol that includes a set of challenge bytes.
// The main changes are in the handshake function.
// Have a look at the http://nugget.codeplex.com for example WebSocket code in C#, on which I based the
// challenge processing code.
open System
open System.IO
open System.Linq
@forki
forki / gist:1400378
Created November 28, 2011 13:21
Poor mans type classes
// Mimic type classes with additional param
type 'a Num = {
zero: 'a
add: 'a -> 'a -> 'a
mult: 'a -> 'a -> 'a
fromInteger: int -> 'a }
let intNum = {
zero = 0
@ferventcoder
ferventcoder / setup.ps1
Last active December 12, 2019 16:59
Really rocking out the environment setup
$scriptDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
function Install-NeededFor {
param(
[string] $packageName = ''
,[bool] $defaultAnswer = $true
)
if ($packageName -eq '') {return $false}
$yes = '6'
@junosuarez
junosuarez / Dockerfile
Last active December 19, 2015 12:29
F# 3.0 in a Docker image
# DOCKER-VERSION 0.4.8
FROM base:ubuntu-12.10
RUN apt-get -y install mono-devel autoconf pkg-config make git libtool
RUN git clone https://github.com/fsharp/fsharp
RUN cd fsharp && ./autogen.sh --prefix /usr && make && make install
@dsyme
dsyme / gist:9b18608b78dccf92ba33
Last active November 1, 2022 18:11
Working self-contained getting-started sample for Suave Web Scripting
//==========================================
// Working fully self-contained getting-started example for Suave Web Server scripting
//
// Note you don't need to have _anything_ installed before starting with this script. Nothing
// but F# Interactive and this script.
//
// This script fetches the Paket.exe component which is referenced later in the script.
// Initially the #r "paket.exe" reference is shown as unresolved. Once it has been
// downloaded by the user (by executing the first part of the script) the reference
// shows as resolved and can be used.
@PatrickJS
PatrickJS / rxPipeRegistry.ts
Last active November 12, 2015 16:51
rx support for Angular 2 Async Pipe
/// <reference path="../../typings/tsd.d.ts" />
///
import {PipeFactory} from 'angular2/src/change_detection/pipes/pipe';
import {async} from 'angular2/src/change_detection/change_detection';
import {NullPipeFactory, Pipe, PipeRegistry, defaultPipes} from 'angular2/change_detection';
import {bind} from 'angular2/di';
import {ObservablePipe} from 'angular2/pipes';
import * as Rx from 'rx';
export function isObservable(obs) {
@mathias-brandewinder
mathias-brandewinder / Script.fsx
Created August 9, 2015 01:30
Language Safety Score using Logistic Regression
(*
This is a reaction to this blog post by Steve Shogren:
http://deliberate-software.com/safety-rank-part-2/
*)
#I @"../packages"
#r @"Accord.3.0.1-alpha\lib\net45\Accord.dll"
#r @"Accord.MachineLearning.3.0.1-alpha\lib\net45\Accord.MachineLearning.dll"
#r @"Accord.Math.3.0.1-alpha\lib\net45\Accord.Math.dll"
#r @"Accord.Statistics.3.0.1-alpha\lib\net45\Accord.Statistics.dll"