Skip to content

Instantly share code, notes, and snippets.

View otto-gebb's full-sized avatar

otto-gebb

  • Karlsruhe
View GitHub Profile
#!/usr/bin/env bash
whoami
let inline fromStr< ^T when ^T : enum<int32> and ^T : equality >(s: string) : Option< ^T > =
let t = typeof<'T>
let enumStrings = System.Enum.GetNames(t)
let vals = System.Enum.GetValues(t) :?> 'T[]
Array.zip vals enumStrings
|> Array.tryFind (fun (x, s') -> s' = s)
|> Option.map fst
let inline toStr< ^T when ^T : enum<int32> and ^T : equality >(x: ^T) =
let t = typeof<'T>
@otto-gebb
otto-gebb / reverseParentheses.fsx
Last active January 5, 2019 06:52
ReverseParentheses - Codefights
(*
You are given a string s that consists of English letters, punctuation marks,
whitespace characters and brackets.
It is guaranteed that the brackets in s form a regular bracket sequence.
Your task is to reverse the strings in each pair of matching parenthesis,
starting from the innermost one.
Example
For string "s = a(bc)de" the output should be
#pragma warning disable 1591
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using DomainDbHelpers.Domain;
using DomainDbHelpers.DomainHelpers;
using DomainDbHelpers.Persistence;
using DomainDbHelpers.PersistenceHelpers;
namespace TestUtils
/// An unbounded pool of browsers.
module BrowserPool =
open System
open OpenQA.Selenium.Chrome
open System.Collections.Concurrent
let private pool = ConcurrentQueue<ChromeDriver>()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
// A separate NuGet package.
namespace Acme.Validation
{
public static class Validator
{
<#
.NOTES
Licensed under WTFPL, Version 2.
.SYNOPSIS
Extracts the DB-schema from the latest EF migration in the specified database.
.DESCRIPTION
Writes the extracted schema to the output file in the EDMX format.
The "(local)" server is used.
.PARAMETER Database
The database with EF migrations (in the __MigrationHistory table).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.