Skip to content

Instantly share code, notes, and snippets.

Tuomas Hietanen Thorium

Block or report user

Report or block Thorium

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Thorium / gist:9752096
Created Mar 25, 2014
Generate random hex-string and calculate base58encode. I made these for some initial BTC-testing, but didn't test too much... seems to work, but would need some unit-tests... :-)
View gist:9752096
module BtcTesting
open System
open System.Security.Cryptography
let base58encode (hash:byte[]) =
let code_string = ['1'..'9']@['A'..'H']@['J'..'N']@['P'..'Z']@['a'..'k']@['m'..'z'] |> List.toArray
let data = hash |> Array.toList
View gist:92ac23e297eb21d65c8e
//Using Azure Table Storage with WindowsAzure.Storage
open Microsoft.WindowsAzure.Storage
open Microsoft.WindowsAzure.Storage.Table
open Microsoft.WindowsAzure.ServiceRuntime
type Person(partitionKey, rowKey, name) =
inherit TableEntity(partitionKey, rowKey)
new(name) = Person("defaultPartition", System.Guid.NewGuid().ToString(), name)
new() = Person("")
Thorium / gist:4ee6b0debdbcb9bddb7f
Last active Aug 29, 2015
Analyse word count from files. You can use it e.g. to create Tag Clouds
View gist:4ee6b0debdbcb9bddb7f
//From NuGet: Sparc.TagCloud
#r @"..\packages\Sparc.TagCloud.0.0.1\lib\net40\Sparc.TagCloud.dll"
module MyTagCloud
open System.IO
open Sparc.TagCloud
let analyzer = new TagCloudAnalyzer()
Thorium / gist:b1dff8526d407ff43597
Last active Aug 29, 2015
Microsoft Kinect Body Basics with Kinect SDK 2.0 and F#
View gist:b1dff8526d407ff43597
// Microsoft Kinect Body Basics with Kinect SDK 2.0 and F#
#r @"..\packages\Microsoft.Kinect.2.0.1410.19000\lib\net45\Microsoft.Kinect.dll"
module Kinect20
open Microsoft.Kinect
open System.Collections.Generic
let bodyFrameReader =
Thorium / music.fs
Last active Aug 29, 2015
Musical Note Frequencies: With the usual Western music it is common to use the Equal temperament: Then the note frequencies are calculated by this formula. For more information: http://en.wikipedia.or…
View music.fs
/// (Infinite) list of note-frequency -pairs
let tones =
let bass = 55.0
let octave = ["A"; "A#"; "B"; "C"; "C#"; "D"; "D#"; "E"; "F"; "F#"; "G"; "G#"]
let notes = seq { while true do yield! octave }
let frequency = bass |> Seq.unfold (fun x -> Some (x, x*System.Math.Pow(2.0, 1.0 / 12.0))) notes frequency
//let ``guitar open A`` = tones |> Seq.nth 24 // val it : float * string = (220.0, "A")
Thorium / gulpfile.js
Last active Aug 29, 2015
JavaScript minifier for FunScript
View gulpfile.js
// Put this file to your FunScript output folder.
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps');
var jsfile = {
targetPath: '',
//This is your FunScript-generated .js-file:
sources: ['generated.js']
Thorium / ParallelReduce.fs
Last active Aug 29, 2015
Idea from Guy L. Steele - Organizing Functional Code for Parallel Execution; or, foldl and foldr Considered Slightly Harmful -
View ParallelReduce.fs
// Reduce / Aggregate / Fold
// Usual way makes deep recursion and trusts tail-opt:
// (a,b,c,d,e,f,g,h) => (((((((a + b) + c) + d) + e) + f) + g) + h)
// This more is quicksort-style parallel:
// (a,b,c,d,e,f,g,h) => (((a + b) + (c + d)) + ((e + f) + (g + h)))
// No Haskell Kinds support for F# so List and Array are easiest to make as separate methods.
open System.Threading.Tasks
module List =
let reduceParallel<'a> f (ie :'a list) =
Thorium / findrefs.fsx
Last active Aug 29, 2015
Fetching dll-infos and their references from a source directory.
View findrefs.fsx
open System
open System.IO
open System.Net
open System.Reflection
let ``not in gac`` (filename:string) =
Assembly.Load filename |> ignore
with | :? IOException -> true
Thorium / gist:c64b8c5bd105f4f53d1e
Last active Aug 29, 2015
Getting started with Akka.NET
View gist:c64b8c5bd105f4f53d1e
// Create Console-application, then NuGet: Install-Package Akka
module AkkaConsoleApplication
open Akka
open Akka.Actor
type Greet(who) =
member x.Who = who
type GreetingActor() as g =
inherit ReceiveActor()
Thorium / gist:c155e8404dedc7b5610b
Last active Aug 29, 2015
Create NuGet packages.config files for csproj-files.
View gist:c155e8404dedc7b5610b
// This program will create packages.config files for each .csproj.
// It will enumerate your projects dll references to know the corresponding NuGet packages.
// packages.config files are used by Paket when converting from NuGet.
#r "System.Xml.dll" //for scripts or interactive
#r "System.Xml.Linq.dll" //add reference if using F# as library
module GeneratePaketConfigs
You can’t perform that action at this time.