Skip to content

Instantly share code, notes, and snippets.

View wallymathieu's full-sized avatar

Oskar Gewalli wallymathieu

View GitHub Profile
@wallymathieu
wallymathieu / personnummer.rb
Created September 18, 2019 08:28 — forked from henrik/personnummer.rb
Generate valid Swedish personnummer.
# Generator for valid Swedish personnummer: http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
# By Henrik Nyh <http://henrik.nyh.se> 2009-01-29 under the MIT license.
require 'date'
module Personnummer
def self.generate(date=nil, serial=nil)
date ||= Date.new(1900+rand(100), 1+rand(12), 1+rand(28))
serial = serial ? serial.to_s : format("%03d", 1+rand(999)) # 001-999
@wallymathieu
wallymathieu / fsharpplus_haskell_compatibility.md
Last active August 25, 2019 10:25
F#+ Haskell Compatibility
+--------------------+--------------------+-------------------------+--------------------+
|Operation           | F#+ / F#           |F#+ Haskell Compatibility|Haskell             |
+====================+====================+=========================+====================+
|List.append         | @                  |                         | ++                 |
+--------------------+--------------------+-------------------------+--------------------+
|Function composition| f << g             | f . (g)                 | f . g              |
+--------------------+--------------------+-------------------------+--------------------+
|                    | <|                 | $                       | $                  |
+--------------------+--------------------+-------------------------+--------------------+
@wallymathieu
wallymathieu / Controllers__ValuesController.fs
Last active July 26, 2019 16:21
1_ClientCredentials.fs
namespace identity.Controllers
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Mvc
[<Route("api/[controller]")>]
[<ApiController>]
@wallymathieu
wallymathieu / Startup.cs
Last active March 28, 2019 13:21
HowTo register auth for swashbuckle with identity server on asp.net core
Namespace ProjectWithSwagger
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
//....
services.ConfigureSwaggerGen(swaggerGen =>
{
@wallymathieu
wallymathieu / Collection.fs
Created September 5, 2018 17:20
Maxima and minima
open FSharpPlus
open FSharpPlus.Operators
module Collection=
let inline maximaBy (projection: 'T->'Key) (source: '``Collection<'T>``) : '``Collection<'T>``=
let sorted = sortByDescending projection source
match tryHead sorted with
| None -> sorted
| Some max -> takeWhile ((compare <| projection max) >> (=) 0 << projection) sorted
@wallymathieu
wallymathieu / fsharp_codeformat.txt
Created January 29, 2018 19:12
V2 vs V3 of FSharp Formatting assemblies
* FSharp.CodeFormat.Constants
Added: FSharp.CodeFormat.Constants (.NET type: Module and base: System.Object)
+ (Instance/Inheritance of FSharp.CodeFormat.Constants).Equals :
obj:System.Object
-> System.Boolean
@wallymathieu
wallymathieu / build.log
Created January 28, 2018 16:17
building a .net core solution / project in Visual Studio for Mac
Building Solution: SynVer (Debug)
Build started 1/28/2018 5:03:07 PM.
__________________________________________________
Project "/Users/mathieu/src/SyntacticVersioning/src/SynVer.Lib/SynVer.Lib.fsproj" (Build target(s)):
Target GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target CoreCompile:
/usr/local/share/dotnet/sdk/2.1.4/FSharp/RunFsc.sh -o:obj/Debug/netstandard2.0/SynVer.Lib.dll
+--------------------+--------------------+-------------------------+--------------------+
|Operation           | F#+ / F#           |F#+ Haskell Compatibility|Haskell             |
+====================+====================+=========================+====================+
|List.append         | @                  |                         | ++                 |
+--------------------+--------------------+-------------------------+--------------------+
|Function composition| f << g             | f . (g)                 | f . g              |
+--------------------+--------------------+-------------------------+--------------------+
|                    | <|                 | $                       | $                  |
+--------------------+--------------------+-------------------------+--------------------+
@wallymathieu
wallymathieu / us-states.xml
Created December 14, 2017 09:02 — forked from bzerangue/us-states.xml
List of States in the United States of America (with dates of when they became as state)
<?xml version="1.0" encoding="UTF-8"?>
<states nation="United States of America" nation-abbreviation="USA" nation-capital="Washington, D.C.">
<state name="Alabama" abbreviation="AL" capital="Montgomery" date="1819-12-14" most-populous-city="Birmingham" population="4708708" square-miles="52423" time-zone-1="CST (UTC-06)" time-zone-2="EST (UTC-05)" dst="Yes"/>
<state name="Alaska" abbreviation="AK" capital="Juneau" date="1959-01-03" most-populous-city="Anchorage" population="698473" square-miles="656425" time-zone-1="AKST (UTC-09)" time-zone-2="HST (UTC-10)" dst="Yes"/>
<state name="Arizona" abbreviation="AZ" capital="Phoenix" date="1912-02-14" most-populous-city="Phoenix" population="6595778" square-miles="114006" time-zone-1="MT (UTC-07)" dst="No"/>
<state name="Arkansas" abbreviation="AR" capital="Little Rock" date="1836-06-15" most-populous-city="Little Rock" population="2889450" square-miles="53182" time-zone-1="CST (UTC-06)" dst="Yes"/>
<state name="California" abbreviation="CA" capital="Sacrame
@wallymathieu
wallymathieu / CpsTests.fs
Created November 4, 2017 21:58
ExtCore Cps tests
module Tests
open System
open Xunit
open System
open ExtCore.Control.Cps
open ExtCore.Control.Collections.Cps
//https://github.com/fabriceleal/Continuations/blob/master/Continuations/Program.fs