Skip to content

Instantly share code, notes, and snippets.

View adelarsq's full-sized avatar
🐢
I may be really slow to respond.

Adelar da Silva Queiróz adelarsq

🐢
I may be really slow to respond.
View GitHub Profile
open Donald
open System.Data.Common
open System.Data.SQLite
open System.Threading.Tasks
open Giraffe
open Giraffe.ViewEngine
open FsToolkit.ErrorHandling
open Microsoft.AspNetCore.Builder
[<RequireQualifiedAccess>]
@RaafatTurki
RaafatTurki / hex_editor.lua
Last active June 1, 2023 01:55
proper hex editing in neovim
local xxd_dump_cmd = 'xxd -g 1 -u'
local xxd_cur_pos = nil
local function is_binary_file()
local filename = vim.fn.expand('%:t')
-- local basename = string.match(filename, "^[a-z]*$")
local binary_ext = { 'png', 'jpg', 'jpeg', 'out' }
local ext = string.match(filename, "%.([^%.]+)$")
if ext == nil and string.match(filename, '[a-z]+') then return true end
@gaoDean
gaoDean / autolist.lua
Last active August 16, 2022 08:29
Minimal automatic list continuing for ordered and unordered lists for nvim in Lua
M.autolist = function()
local preceding_line = vim.fn.getline(vim.fn.line(".") - 1)
if preceding_line:match("^%s*%d+%.%s.") then
local list_index = preceding_line:match("%d+")
print(list_index .. "t")
vim.fn.setline(".", preceding_line:match("^%s*") .. list_index + 1 .. ". ")
vim.cmd([[execute "normal \<esc>A\<space>"]])
elseif preceding_line:match("^%s*%d+%.%s$") then
vim.fn.setline(vim.fn.line(".") - 1, "")
elseif preceding_line:match("^%s*[-+*]") and #preceding_line:match("[-+*].*") == 1 then
#r "nuget:FParsec"
open FParsec
type AttackVector =
| Network
| AdjacentNetwork
| Local
| Physical
@nikoloz-pachuashvili
nikoloz-pachuashvili / Money.fs
Last active July 15, 2022 14:25
Monetary value modeling in F#
namespace Domain
open System
open System.Runtime.CompilerServices
open System.Globalization
[<AutoOpen>]
module rec Money =
[<Struct;IsReadOnly>]
type Money = private Money of decimal * Currency with
@nojaf
nojaf / style.fsx
Created June 2, 2022 16:32
Compiling a Sass file using an F# script
#r "nuget: JavaScriptEngineSwitcher.ChakraCore.Native.win-x64"
#r "nuget: JavaScriptEngineSwitcher.ChakraCore, 3.18.2"
#r "nuget: DartSassHost, 1.0.0-preview7"
#r "nuget: FSharp.Control.Reactive, 5.0.5"
open System
open System.IO
open DartSassHost
open DartSassHost.Helpers
open JavaScriptEngineSwitcher.ChakraCore
@mrpmorris
mrpmorris / app.css
Created May 20, 2022 09:12
The CSS I put in the top of every new web app
:root {
box-sizing: border-box;
}
*, ::before, ::after {
box-sizing: inherit;
}
html {
scroll-behavior: smooth;
}
@mrange
mrange / 0_README.md
Last active August 10, 2022 19:24
Simple physics in F# and WPF

Simple physics in F# and WPF

This is an example on how to use WPF and F# to do some simple physics using Verlet Integration.

The program creates a system of particles and constraints. Particles have inertia and is affected by gravity but their motion is also contrained by the constraints.

I tried to annotate the source code to help guide a developer familiar with languages like C#. If you have suggestions for how to improve it please leave a comment below.

How to run

@tnishimura
tnishimura / generate-jwt-with-fsharp.fsx
Last active September 5, 2023 10:00
This is an F# interactive script to generate a JWT. You can use it as a reference for when you are generating JWT on your server for a client, for example. It is hard coded for symmetric signing (HS256), but can be modified for asymmetric signing RS256, see notes in code.
(*
This is an F# interactive script to generate a JWT. You can use it as a reference for when you are generating JWT on
your server for a client, for example. It is hard coded for symmetric signing (HS256), but can be modified for
asymmetric signing RS256, see notes.
*)
#r "nuget: System.IdentityModel.Tokens.Jwt"
open System
open System.Text // for Encoding
open System.IdentityModel.Tokens.Jwt // For JwtSecurityToken (Install it from Nuget)
open System.Security.Claims // For Claim, ClaimTypes