This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ``Next N Friday 13`` n = | |
Seq.initInfinite (fun i -> i |> float |> System.DateTime.Now.AddDays) | |
|> Seq.filter (fun date -> date.Day = 13 && date.DayOfWeek = System.DayOfWeek.Friday) | |
|> Seq.map (fun date -> date.ToShortDateString()) | |
|> Seq.take n | |
|> Seq.toList | |
// Output: | |
// val ( Next N Friday 13 ) : n:int -> string list | |
// val it : string list = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Diagnostics | |
let sizeEventLog (el : EventLog) = | |
Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @"System\CurrentControlSet\Services\EventLog\" + el.Log ) | |
|> Option.ofNull | |
|> Option.bind ( fun registryKey -> registryKey.GetValue("FIle") |> Some ) | |
|> Option.bind Option.ofNull | |
|> Option.bind ( fun x -> x.ToString() |> Some ) | |
|> Option.bind ( fun filePath -> new FileInfo(filePath) |> Some ) | |
|> Option.bind ( fun fi -> fi.Name |> Some ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** # Примеры использования FSharp.Text.RegexProvider*) | |
(** ## Проверка ссылок на F#*) | |
(** Следующий скрипт выводит информацию о ссылках в html-коде, хранящемся в переменной html. | |
Скрипт портирован из примера в книге Д. Фридл, Регулярные выражения стр. 257 *) | |
open System.Text.RegularExpressions | |
open FSharp.Text.RegexProvider | |
[<Literal>] | |
let aTagPattern = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.DirectoryServices.AccountManagement.dll" | |
open System.DirectoryServices.AccountManagement | |
let testSearch fullName = | |
let ctx = new PrincipalContext(ContextType.Domain) | |
let u = new UserPrincipal(ctx) | |
u.Surname <- fullName | |
use ps = new PrincipalSearcher(u) | |
ps.FindAll() | |
|> Seq.cast<System.DirectoryServices.AccountManagement.UserPrincipal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$webclient = New-Object System.Net.WebClient | |
$creds = Get-Credential | |
$webclient.Proxy.Credentials = $creds | |
Update-Help -Credential $creds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Выгружает в формате csv без вставки в заголовок файла описание типа, в кодировке Юникод. | |
export-csv -Path C:\temp\export.csv -Delimiter ';' -NoTypeInformation -Encoding Unicode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
// THE SOFTWARE. | |
namespace Utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I @"../../packages/FSharp.Data/lib/net40" | |
#r @"FSharp.Data.dll" | |
open FSharp.Data | |
[<Literal>] | |
let ianaCsvSample = "Name,Template,Reference | |
1d-interleaved-parityfec,application/1d-interleaved-parityfec,[RFC6015]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Делаем текущий каталог рабочей директорией | |
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ | |
// Если файл paket.exe не существует загружаем его | |
if not (System.IO.File.Exists "paket.exe") then | |
let url = "http://fsprojects.github.io/Paket/stable" | |
use wc = new System.Net.WebClient() | |
let tmp = System.IO.Path.GetTempFileName() | |
let stable = wc.DownloadString(url) | |
wc.DownloadFile(stable,tmp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------ | |
// Step 0. Boilerplate to get the paket.exe tool | |
open System | |
open System.IO | |
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ | |
if not (File.Exists "paket.exe") then | |
let url = "http://fsprojects.github.io/Paket/stable" |
OlderNewer