Skip to content

Instantly share code, notes, and snippets.

View semuserable's full-sized avatar
💭
Looking for remote job opportunities

semuserable

💭
Looking for remote job opportunities
View GitHub Profile
open FSharp.Data
open FSharp.Data.JsonExtensions
open System.IO
open System
module City =
type T = City of string
let Kyiv = City "Киев"
let Kharkiv = City "Харьков"
[System.Runtime.InteropServices.DllImport("KERNEL32.DLL")]
private static extern int GetSystemDefaultLCID();
private RegionInfo CurrentRegionInfo()
{
var cultureInfo = new CultureInfo(GetSystemDefaultLCID());
return new RegionInfo(cultureInfo);
}
// OR (it's preferable if Vista or higher)
@semuserable
semuserable / SimpleObservableCreate.cs
Last active April 18, 2016 12:53
Simple methods from Rx made using Observable.Create<T>()
public static class RxExamples
{
// Equal to Observable.Empty<T>()
public static IObservable<T> Empty<T>()
{
return Observable.Create<T>(observer =>
{
observer.OnCompleted();
return Disposable.Empty;
});
@semuserable
semuserable / Subscribing.cs
Created April 10, 2016 11:51
Rx .NET samples
static void Main()
{
IObservable<int> observable = Enumerable.Range(0, 10).ToObservable();
// Long version
observable.Subscribe(new IntObserver());
// Short version (lambda)
observable.Subscribe(Console.WriteLine)