Skip to content

Instantly share code, notes, and snippets.

Avatar
🦎

Amin Khansari akhansari

🦎
View GitHub Profile
View OAuth Bible.md

The OAuth Bible

I tried to make this as understandable as possible for any party reading it which means that the wording, references, and terminology used may not reflect that of a technical paper or resource. Excuse me if you may for I wish all to understand this, and not just those with a degree in understanding legal or technical jargon.

Created with love by Nijikokun @ Mashape, the team behing the OSS API management layer Kong, and Mashape Analytics for visualizing and monitoring API traffic.


Hey! Interested in simplifying the process to consume OAuth services like twitter, facebook, github, and thousands more? Check out Guardian, it was built with simplicity, security, and ease of use in mind, allowing you to consume OAuth in a single request.

@akhansari
akhansari / HttpClientFactory.fsx
Last active October 19, 2022 08:51
HttpClientFactory and named HttpClient with F#
View HttpClientFactory.fsx
#r "nuget: Microsoft.Extensions.Http, 6.0.0"
let factory =
ServiceCollection()
.AddHttpClient("dummy")
.ConfigureHttpClient(fun c ->
printfn "dummy configured"
c.BaseAddress <- Uri "https://dummyjson.com"
c.Timeout <- TimeSpan.FromMinutes 2.)
.Services
View Microsoft.PowerShell_profile.ps1
Invoke-Expression (&starship init powershell)
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
Invoke-Expression (& zoxide init --hook 'pwd' powershell | Out-String)
Set-Alias -Name ee -Value extLauncher
@akhansari
akhansari / EsBankAccount.cs
Last active July 27, 2022 17:31
C# prototype of Decider pattern. F# version: https://github.com/akhansari/EsBankAccount
View EsBankAccount.cs
namespace EsBankAccount.Account;
using Events = IReadOnlyCollection<IEvent>;
public record Transaction(decimal Amount, DateTime Date);
// events
public interface IEvent { } // used to mimic a discriminated union
public record Deposited(Transaction Transaction) : IEvent;
public record Withdrawn(Transaction Transaction) : IEvent;
View BowlingKata.fsx
type Pins = int
let [<Literal>] MaxPins : Pins = 10
type Frame =
| Strike of Pins
| Spare of Pins * Pins
| Open of Pins * Pins
| Pending of Pins
| Final of Pins * Pins option * Pins option
@akhansari
akhansari / .gitconfig
Last active June 7, 2022 13:08
Multiple Git Configs
View .gitconfig
[core]
excludesFile = ~/.gitignore
[user]
name = My Name
[includeIf "gitdir:~/git/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/github/"]
path = ~/.gitconfig-home
@akhansari
akhansari / AsyncSeq.fs
Last active March 3, 2022 11:50
F#: IEnumerable to IAsyncEnumerable
View AsyncSeq.fs
module AsyncSeq =
open System.Collections.Generic
open System.Threading.Tasks
let cancelled (cancellationToken: CancellationToken) =
Task.FromCanceled<bool> cancellationToken
|> ValueTask<bool>
let ofSeq (sq: Task<'T> seq) = {
new IAsyncEnumerable<'T> with
@akhansari
akhansari / async_vs_task_1.fs
Last active November 12, 2021 18:23
F# 6: Async VS Task
View async_vs_task_1.fs
(*
| Method | Mean | Error | StdDev | Allocated |
|------- |--------:|--------:|--------:|----------:|
| Task | 15.99 s | 0.107 s | 0.095 s | 314 KB |
| Async | 16.02 s | 0.089 s | 0.079 s | 990 KB |
*)
open System.Threading.Tasks
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
@akhansari
akhansari / useful-tools.md
Last active December 21, 2021 10:11
My Useful Tools
View useful-tools.md

Scoop

  • firacode
  • windows-terminal
  • starship
  • gopass
  • pass-winmenu-nogpg
  • micro
  • nodejs
  • jq
@akhansari
akhansari / ConsulKv.fs
Last active August 18, 2021 15:08
Simple Consul KV client in F#
View ConsulKv.fs
[<AutoOpen>]
module Helpers =
let rec (|NestedHttpRequestException|_|) (e: exn) =
match e with
| null -> None
| :? Net.Http.HttpRequestException as e -> Some e
| e -> (|NestedHttpRequestException|_|) e.InnerException
[<RequireQualifiedAccess>]
module ConsulKv =