Skip to content

Instantly share code, notes, and snippets.

View sergey-tihon's full-sized avatar
🦀

Sergey Tihon sergey-tihon

🦀
View GitHub Profile
type I<'T> = interface end
type I1<'T> = inherit I<'T>
type I2<'T> = inherit I<'T>
type A =
inherit I1<int>
inherit I2<double>
interface I<T>
{}
interface I1<T> : I<T>
{}
interface I2<T> : I<T>
{}
class A : I1<int>, I2<double>
{}
@sergey-tihon
sergey-tihon / gist:6467164
Created September 6, 2013 17:41
F# PowerShell Get-Item
#r @"System.Management.Automation.dll"
#r @"PowerShellTypeProvider.dll"
type PS = FSharp.PowerShell.PowerShellTypeProvider< PSSnapIns="", Is64BitRequired=false >
PS.``Get-Item``()
*** Assembly Binder Log Entry (10/30/2013 @ 11:29:27 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
@sergey-tihon
sergey-tihon / gist:8180076
Created December 30, 2013 10:01
simple shift
let shift (s:string) (k:int) =
System.String(
s.ToCharArray()
|> Array.map (function
| x when 'a' <= x && x <='z' ->
let code = int(x)-int('a')
char(int('a') + (code + k + 26) % 26)
| x -> x )
)
@sergey-tihon
sergey-tihon / gist:8325391
Created January 8, 2014 22:10
F# MongoDB sample (C# Driver)
#I @"..\packages\mongocsharpdriver.1.8.3\lib\net35\"
#r "MongoDB.Driver.dll"
#r "MongoDB.Bson.dll"
open System
open MongoDB.Bson
open MongoDB.Bson.Serialization.Attributes
open MongoDB.Driver
open MongoDB.Driver.Builders
open MongoDB.Driver.Linq
public List<Dependency> GetDependency(Tree tree)
{
var tlp = new PennTreebankLanguagePack();
var gsf = tlp.grammaticalStructureFactory();
var gs = gsf.newGrammaticalStructure(tree);
var dependencies = gs.typedDependenciesCollapsedTree();
return (from TypedDependency dependency in dependencies.toArray()
select new Dependency
{
@sergey-tihon
sergey-tihon / gist:ceaf835ef2df2d9bcf8f
Created October 21, 2014 20:28
NuGet download stats
#I @"packages\Nuget.Core.2.8.3\lib\net40-Client"
#r "NuGet.Core.dll"
#r "System.Xml.Linq.dll"
let repository =
NuGet.PackageRepositoryFactory.Default.CreateRepository
"https://nuget.org/api/v2"
type NuGetStat =
{ Id: string; DownloadCount:int}
@sergey-tihon
sergey-tihon / gist:51e21e328454567594f4
Created November 13, 2014 19:53
Joke radio powered by COM Type Provider
#r "../packages/FSharp.ComProvider.1.0.0-pre1/lib/net40/FSharp.ComProvider.dll"
#r @"../packages/FSharp.Data.2.1.0/lib/net40/FSharp.Data.dll"
open FSharp.Data
type SpeechService = TypeLib.``Microsoft Speech Object Library``.``5.4``
let speech = SpeechService.SpVoiceClass()
type js = JsonProvider<"""{ "type": "success", "value": { "id": 42, "joke": "Joke here." } }""" >
let getJoke num =
#r @"packages\Streams.0.2.5\lib\Streams.Core.dll"
open System
open System.IO
open System.Collections.Generic
open Nessos.Streams
// make Visual Studio use the script directory
Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__)