Skip to content

Instantly share code, notes, and snippets.

@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@gusty
gusty / trampoline.fsx
Last active February 27, 2024 08:04
Trampolines in F#
let trampoline f c n =
let rec loop = function
| Choice1Of2 x -> x
| Choice2Of2 x -> loop (f x)
loop (Choice2Of2 (c,n))
// Test
let factorial n =
let rec factorialT (current, n) =
if n = bigint 0 then Choice1Of2 current
@mathias-brandewinder
mathias-brandewinder / gist:5558573
Last active October 31, 2023 05:05
Stub for F# Machine Learning Dojo
// This F# dojo is directly inspired by the
// Digit Recognizer competition from Kaggle.com:
// http://www.kaggle.com/c/digit-recognizer
// The datasets below are simply shorter versions of
// the training dataset from Kaggle.
// The goal of the dojo will be to
// create a classifier that uses training data
// to recognize hand-written digits, and
// evaluate the quality of our classifier
@bent-rasmussen
bent-rasmussen / Actor.fs
Last active September 12, 2023 04:23
Experimental high performance actor implementation for F# using channel and task computation expression.
// NOTE: import this Nuget package: TaskBuilder.fs (written using 2.1.0)
//
// Tested in LINQPad (hence Dump method usage).
open System
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open System.Linq
open System.Threading
@t0yv0
t0yv0 / AsyncSockets.fs
Last active September 7, 2023 11:45
Asynchronous socket programming with F# async.
open System.Net.Sockets
type A = System.Net.Sockets.SocketAsyncEventArgs
type B = System.ArraySegment<byte>
exception SocketIssue of SocketError with
override this.ToString() =
string this.Data0
/// Wraps the Socket.xxxAsync logic into F# async logic.
anonymous
anonymous / gist:1406238
Created November 29, 2011 20:09
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
namespace Tsunami.Server
open System
open System.IO
open System.Linq
open System.Net
open System.Net.Sockets
open System.Text
open System.Threading
open System.Runtime.Serialization
@shawnbot
shawnbot / README.md
Created December 20, 2013 19:04
d3 voronoi interpolation!
@cloudRoutine
cloudRoutine / 01_folds.fs
Last active December 12, 2022 13:01
F# Transducers - they work for the most part
open System.Collections.Generic
open Microsoft.FSharp.Collections
[<RequireQualifiedAccess>]
module Folds =
// These are the fast implementations we actually want to use