Skip to content

Instantly share code, notes, and snippets.

View AlbertoDePena's full-sized avatar

Alberto De Pena AlbertoDePena

  • Crane Worldwide Logistics
  • Willis, TX
View GitHub Profile
@AlbertoDePena
AlbertoDePena / MinimalApi.fs
Last active May 8, 2024 13:26
Delegate to make minimal APIs FSharp friendly
namespace WebApp.Extensions
open System
open System.Text
open System.Threading.Tasks
open Microsoft.AspNetCore.Http
open Microsoft.AspNetCore.Antiforgery
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging
namespace WebApp.HtmlTemplate
open System
open System.IO
open System.Net
open System.Text
open System.Text.RegularExpressions
/// The path to a HTML file or a HTML string.
type FileOrContent = string
@AlbertoDePena
AlbertoDePena / Tips-And-Tricks.MD
Last active March 19, 2024 16:08
Tips and Tricks

Visual Studio 2022 / Visual Studio Code

Press Alt while selecting the block of code with the mouse (boxing).

Press Alt+Shift+Up / Alt+Shift+Down to insert cursor above / below.

Press Ctrl+Alt / Alt and click where you want to add a caret.

Select the word then press Alt+Shift+. / Ctrl+D to select the next occurance.

USE EventStore;
GO
CREATE TABLE dbo.Events
(
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY,
[Type] NVARCHAR(256) NOT NULL,
[Data] NVARCHAR(MAX) NOT NULL,
[Version] INT NOT NULL,
[StreamName] NVARCHAR(256) NOT NULL,
@AlbertoDePena
AlbertoDePena / fsharp.json
Created August 13, 2022 15:42
FSharp snippets
{
"Elmish Component": {
"prefix": "elmish-comp",
"body": [
"open Elmish",
"open Elmish.React",
"open Feliz",
"",
"type State = { Message: string }",
"",
function prompt {
Write-Host("")
$statusString = ""
$symbolicRef = git symbolic-ref HEAD
$isGit = $NULL -ne $symbolicRef
$location = $(get-location)
if ($isGit) {
$branch = $symbolicRef.substring($symbolicRef.IndexOf("heads/") + 6)
$statusString = "GIT " + $branch + " " + $location + ">"
[<RequireQualifiedAccess>]
module DotEnv =
open System
open System.IO
let private parseLine (line: string) =
let splitCount = 2
match line.Split('=', splitCount, StringSplitOptions.RemoveEmptyEntries) with
| args when args.Length = splitCount -> Environment.SetEnvironmentVariable(args.[0], args.[1])
// Microsoft.IdentityModel.Protocols.OpenIdConnect
// System.IdentityModel.Tokens.Jwt
/// <summary>
/// Token validator
/// </summary>
public class TokenValidator
{
private readonly TokenValidationParameters _tokenValidationParameters;
@AlbertoDePena
AlbertoDePena / Serilog.fs
Last active January 21, 2023 00:06
FSharp logger with Serilog (app insights and console sinks)
// NuGet Packages
// Serilog.Enrichers.Environment
// Serilog.Sinks.ApplicationInsights
// Serilog.Sinks.Console
open System
open Serilog
open Serilog.Events
[<RequireQualifiedAccess>]
@AlbertoDePena
AlbertoDePena / yaml.json
Last active September 14, 2020 13:33
YML snippets (VSCODE)
{
"Kubernetes Deployment": {
"prefix": "k8s-deployment",
"body": [
"apiVersion: apps/v1",
"kind: Deployment",
"metadata:",
" name: ${1:deployment-name}",
" labels:",
" ${2:label-key}: ${3:label-value}",