Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
Working from sea

Sergey Tihon sergey-tihon

🌊
Working from sea
View GitHub Profile
View gist:4388174
type IndependentSets(n) =
let rank, boss = Array.create n 0, Array.init n (fun x->x)
member this.find(x) =
if boss.[x] = x then x else boss.[x] <- this.find(boss.[x]); boss.[x]
member this.union(x,y) =
let a,b = this.find(x), this.find(y)
if (rank.[a] < rank.[b]) then boss.[a] <- b
if (rank.[a] > rank.[b]) then boss.[b] <- a
if (rank.[a] = rank.[b]) then boss.[b] <- a; rank.[a] <- rank.[a] + 1
View gist:4506157
System.Net.ServicePointManager.ServerCertificateValidationCallback
<- System.Net.Security.RemoteCertificateValidationCallback(fun _ _ _ _ -> true)
///type TypeName = Microsoft.FSharp.Data.TypeProviders.WsdlService<"https://...">
View gist:4550826
<?xml version="1.0" encoding="utf-8"?>
<ServiceMetadataFiles>
<ServiceMetadataFile name="developer.atlassian.com.rpc.soap-axis.confluenceservice-v2.wsdl">
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://rpc.confluence.atlassian.com" xmlns:tns2="http://beans.soap.rpc.confluence.atlassian.com" xmlns:impl="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" targetNamespace="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2">
<import namespace="http://beans.soap.rpc.confluence.atlassian.co
View gist:4551155
<?xml version="1.0" encoding="utf-8"?>
<ServiceMetadataFiles>
<ServiceMetadataFile name="developer.atlassian.com.rpc.soap-axis.confluenceservice-v2.wsdl">
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://rpc.confluence.atlassian.com" xmlns:tns2="http://beans.soap.rpc.confluence.atlassian.com" xmlns:impl="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" targetNamespace="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="https://developer.atlassian.com/rpc/soap-axis/confluenceservice-v2">
<import namespace="http://beans.soap.rpc.confluence.atlassian.co
@sergey-tihon
sergey-tihon / gist:5343737
Created Apr 9, 2013
F#, ServiceStack + Project Service
View gist:5343737
open System
open ServiceStack.ServiceHost
open ServiceStack.WebHost.Endpoints
open ServiceStack.ServiceInterface
type Project() =
let mutable projectID = 0
let mutable projectName = ""
let mutable companyName = ""
let mutable projectStatus = ""
View App.fs
module MainApp
open System
open System.Windows
open System.Windows.Controls
open FSharpx
type MainWindow = XAML<"MainWindow.xaml">
let loadWindow() =
View gist:5476455
using java.io;
using edu.stanford.nlp.process;
using edu.stanford.nlp.ling;
using edu.stanford.nlp.trees;
using edu.stanford.nlp.parser.lexparser;
namespace Stanford_Parser
{
class Program
View gist:5648075
open System
open System.Net
open System.Text
open System.IO
let siteRoot = @"D:\mySite\"
let host = "http://localhost:8080/"
let listener (handler:(HttpListenerRequest -> HttpListenerResponse -> Async<unit>)) cancellationToken =
let hl = new HttpListener()
View gist:5665600
type Message =
| Sleep of int*int
| SyncPoint of AsyncReplyChannel<unit>
let agent =
MailboxProcessor.Start(fun inbox ->
let rec loop() =
async {
let! msg = inbox.Receive()
match msg with
@sergey-tihon
sergey-tihon / gist:5995802
Created Jul 14, 2013
The N Queens problem!
View gist:5995802
type ChessboardState =
{Row:bool[]; DiagPlus:bool[]; DiagMin:bool[]}
let inline diagMinInd (chessboard:ChessboardState) (x,y) =
if x-y>=0 then x-y else x-y+chessboard.DiagMin.Length
let canPlaceOn (chessboard:ChessboardState) (x,y) =
chessboard.Row.[y] && chessboard.DiagPlus.[x+y] && chessboard.DiagMin.[diagMinInd chessboard (x,y)]
let changeState (chessboard:ChessboardState) (x,y) =