Snippets created by Tuomas Hietanen
Convert an object to json, and json to object
There is a namespace System.Runtime.Serialization.Json To serialize generic object you can do like this...
40 people like this
Posted: 1 years ago by Tuomas HietanenGetting a key from Windows registry
F# code to fetch a registry key
16 people like this
Posted: 1 years ago by Tuomas HietanenDecrypting a Rijndael string
This F# code decrypts an encrypted string using Rijndael symmetric encryption algorithm. It uses key and initialization vector stored in a registry key.
34 people like this
Posted: 1 years ago by Tuomas HietanenGet Stock Quote Data and Historical Stock Prices from Yahoo Finance
Get Stock Quote Data and Historical Stock Prices from Yahoo Finance.
135 people like this
Posted: 1 years ago by Tuomas HietanenFunction to get all possible combinations
Function to get all possible combinations of list items. There are some Euler problems (like 77 & 78) to get total amounts. But e.g. for some card game implementations you will need the real items.
27 people like this
Posted: 1 years ago by Tuomas HietanenTimestamp with timezone (YYYYMMDDhhmmssffff+zzzz)
Timestamp: Time format in ISO 8601 with timezone. YYYYMMDDhhmmssffff+zzzz For example 2011-05-17 19:01:10.000 -0200 would be: 20110517190110000-0200
2 people like this
Posted: 1 years ago by Tuomas HietanenSHA512 hash code from a string
Generates SHA512 hash code from a string. Usually used in some kind of validity checks, e.g. check first timestamp and then check SHA-hash over id and timestamp to ensure a valid session.
2 people like this
Posted: 1 years ago by Tuomas HietanenSimple F# ViewModel for Silverlight MVVM
Silverlight default architecture is Model-View-ViewModel. This code gives full design time support for Microsoft Expression Blend. The F# ViewModel is seen as strongly typed data source in the Blend UI. There are two properties binded to the view: HiLabel (OneWay data binding) and MyName (TwoWay data binding). ViewModel implements the INotifyPropertyChanged to support the binding. The view project (HelloApp) is made with Blend (by designers) and it is Silverlight 5.0 project. The view codebehind is c# file and it has only this.DataContext -assignment. The viewmodel project (HelloApp.ViewModel) is F# Silverlight 4.0 library. It is made with VS2010 and F# (by developers). It contains the logical functionality of the current view.
4 people like this
Posted: 11 months ago by Tuomas HietanenSilverlight asynchronous WebService call with UI-thread syncronization dispatcher
You can use this code to make a async WebRequest from Silverlight to update ViewModel.
4 people like this
Posted: 11 months ago by Tuomas Hietanen
csproj-file parsing with Linq2Xml
This program reads all *.csproj-files from a path and then uses Linq2Xml to show data about the projects. This should be a good template for scripts to manage tons of c#-project files. F# and LINQ-to-XML is very powerful combination.
6 people like this
Posted: 7 months ago by Tuomas HietanenSimple Reactive Extensions Example
Subject is a class that implements both IObservable<'T> and IObserver<'T>
5 people like this
Posted: 6 months ago by Tuomas HietanenTeam Foundation Server: Check Out a file
Team Foundation Server (TFS): Check Out a file.
2 people like this
Posted: 3 months ago by Tuomas Hietanencsproj-file parsing with Linq2Xml - part 2
This program reads all *.csproj-files from a path and then uses Linq2Xml to show or modify data about the projects. This should be a good template for scripts to manage tons of c#-project files. F# and LINQ-to-XML is very powerful combination.
7 people like this
Posted: 2 months ago by Tuomas HietanenSimple NumericLiteral example
You can use numeric literals, constant expressions and operator overloading to make your own arithmetics. Useful in DSL languages. With NumericLiterals, you can use any of Q, R, Z, I, N, G. Basic syntax: [Number][Letter] will forward the call to the type NumericLiteral[Letter] to FromInt32 [Number] (or FromInt64 or FromString...)
4 people like this
Posted: 29 days ago by Tuomas HietanenF# 3.0 - EntityFramework Type Provider usage with Northwind DB
A small sample how to use F# 3.0 Entity Framework (EF) Type Provider. Visual Studio 11 Beta (and Northwind sample database) needed.
3 people like this
Posted: 29 days ago by Tuomas HietanenSimple builder example: Nullable
Simple Computational expressions / monad / builder -example, using .NET Nullable as demo.
3 people like this
Posted: 28 days ago by Tuomas HietanenYet another Fibonacci
In mathematics, the Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers in the following integer sequence: [0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; 89; 144; 233; 377; ...] http://en.wikipedia.org/wiki/Fibonacci_number
4 people like this
Posted: 11 days ago by Tuomas Hietanen