This file contains hidden or 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
defmodule Utils do | |
def logw(content) do | |
write("iex_output.exs", content, [:write]) | |
content | |
end | |
def loga(content) do | |
write("iex_output.exs", content, [:append], 1) | |
content | |
end |
This file contains hidden or 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
const hueToRgb = (p, q, t) => { | |
let tlocal = t; | |
if (tlocal < 0) tlocal += 1; | |
if (tlocal > 1) tlocal -= 1; | |
if (tlocal < 1 / 6) return p + (q - p) * 6 * tlocal; | |
if (tlocal < 1 / 2) return q; | |
if (tlocal < 2 / 3) return p + (q - p) * (2 / 3 - tlocal) * 6; | |
return p; | |
}; |
This file contains hidden or 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
// Deploy service bus + topic & subscription using the Azure .NET Fluent API | |
// Some references in C# here: | |
// https://github.com/Azure-Samples/service-bus-dotnet-manage-publish-subscribe-with-advanced-features/blob/master/Program.cs | |
(* | |
Necessary references to be added to your fsproj | |
<ItemGroup> | |
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.33.0" /> | |
<PackageReference Include="Microsoft.Azure.Management.ServiceBus.Fluent" Version="1.33.0" /> | |
</ItemGroup> |
This file contains hidden or 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 | |
open Akka.Actor | |
open Akka.FSharp | |
type ActorAMessages = | |
| MessageA1 of name: string | |
| MessageA2 of quantity: int | |
| MessageA3 | |
type ActorBMessages = |
This file contains hidden or 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
using System; | |
namespace FunWithExceptions | |
{ | |
public class FolderCouldNotBeCreatedException : Exception | |
{ | |
public FolderCouldNotBeCreatedException(string folderPath) | |
: base("Folder '" + folderPath + "' could not be created!") | |
{} | |
} |
This file contains hidden or 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
using System; | |
namespace FunWithExceptions | |
{ | |
/* | |
* 'Vindigator' is an imaginary 3rd-party library that contains | |
* a lot of useful (if you're into the vindication business) APIs. | |
*/ | |
public static class Vindigator | |
{ |
This file contains hidden or 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
// Issue decribed here: http://websharper.com/question/82758/post-endpoint-with-a-json-body-cannot-be-reached | |
namespace HelloWebSharper | |
open WebSharper.Html.Server | |
open WebSharper | |
open WebSharper.Sitelets | |
module Site = |
This file contains hidden or 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 | |
type PizzaRecipe() = class end | |
type PizzaOrder() = class end | |
type ColdPizza() = class end | |
type HotPizza() = class end | |
type PizzaDelivery() = class end | |
let order (size:string) (recipe:PizzaRecipe) = | |
PizzaOrder() |
This file contains hidden or 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
// Check out the associated blog post at: | |
// http://www.ybouglouan.pl/2017/03/are-you-polish-fharp-will-tell-us-probably/ | |
open System | |
// ----------------------------------------------------------------------------------------------- | |
/// Return the number of occurrences of a given char within a word (case-insensitive) | |
let countCharCI char word = | |
word |