Skip to content

Instantly share code, notes, and snippets.

View chgeuer's full-sized avatar
🏠
Working from Düsseldorf

Dr. Christian Geuer-Pollmann chgeuer

🏠
Working from Düsseldorf
View GitHub Profile
#r "nuget: Thoth.Json.Net, 7.1.0"
open Thoth.Json.Net
type Foo =
{ Name: string
Age: int }
module Encoders =
let fooDecoder : Decoder<Foo> =
@chgeuer
chgeuer / main.rs
Created September 14, 2021 09:43
Strike Training Solution
// My solution to https://strikecommunity.azurewebsites.net/articles/8612/course-introduction-to-the-rust-programming-langua-1.html
use std::collections::HashMap;
fn main() -> Result<(), std::io::Error> {
let mut arguments = std::env::args().skip(1);
let k = arguments.next().unwrap();
let v = arguments.next().unwrap();
let mut db = Database::from_disk("kv.db")?;
@chgeuer
chgeuer / DownloadBlobsToMemory.cs
Created September 2, 2021 06:36
A gazillion ways to download a blob
using System;
using System.IO;
using System.Threading.Tasks;
using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
static class Program
{
// https://github.com/Azure/azure-sdk-for-net/issues/22022
#!/bin/bash
mkdir device server
cd device
# Create a key pair
openssl genrsa -out device-priv.pem 2048

Regex

[\+\(]?\d[\(\)\-\d\ ]+

Demo text

<!DOCTYPE html>
<html>
<head>
<style>
h1 {co​lor: bl​ue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
namespace JoseJwtTester
{
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Jose; // <PackageReference Include="jose-jwt" Version="2.6.0" />
public class ApplicationCreationRequest
{
[JsonPropertyName("tenantId")]
#!/bin/bash
# --proxy http://127.0.0.1:8888/ --insecure \
aadTenant="chgeuerfte.onmicrosoft.com"
subscriptionId="724467b5-bee4-484b-bf13-d6a5505d2b51"
resourceGroup="longterm"
storageAccountName="chgeuer"
containerName="aadtest"
blobName="index.html"

Interfaces defined in F# and used from C#

For a customer project, I needed to define an interface, and an implementation of that interface, implementing a factory. I wanted to pass in a creation lambda (from C#) to the factory, and the Create() function under the hood should invoke the lambda.

Wrong - The interface defines a property, which returns a Func.

open System