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
@mrange
mrange / 0_README.md
Last active June 3, 2024 08:06
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
@JustinGrote
JustinGrote / AddFSharpType.fs
Created October 24, 2021 23:52
A version of Add-Type for F# in PowerShell
namespace AddFSharpType
module AddFSharpType =
open System.IO
open FSharp.Compiler.CodeAnalysis
open System
/// This is basically the compiler so we name it that way
let compiler = FSharpChecker.Create()
let AddFromFile (sourceFile : string) =
@p4bl0-
p4bl0- / 00_readme.md
Last active January 2, 2025 09:03
A complete compiler for a simple language (in less than 150 LoC)

This project is a tiny compiler for a very simple language consisting of boolean expression.

The language has two constants: 1 for true and 0 for false, and 4 logic gates: ! (not), & (and), | (or), and ^ (xor).

It can also use parentheses to manage priorities.

Here is its grammar in BNF format:

expr ::= "0" | "1"

@kMutagene
kMutagene / dash-stock-ticker-less-loc.fs
Last active February 14, 2022 07:42
Dash stonks ticker App to pluck into an asp.netcore app via DashApp.toHttpHandler.
open Dash.NET; open Plotly.NET; open FSharp.Data; open Deedle; open System; open System.IO; open System.Text; open System.Text.RegularExpressions
let req = Http.Request("https://finance.yahoo.com/quote/AMZN/history?p=AMZN",httpMethod=HttpMethod.Get)
let body = match req.Body with | HttpResponseBody.Text b -> b
let crumb = Regex("CrumbStore\":{\"crumb\":\"(?<crumb>.+?)\"}").Match(body).Groups.["crumb"].Value
let cookie = req.Cookies.["B"]
let getDf ticker : Frame<System.DateTime,string> =
let response =
Http.RequestString(
@object
object / ProtobufSerializationTest.fs
Created May 24, 2021 19:13
Protobuf serialization in F#
module ProtobufSerializationTests
open System
open System.IO
open ProtoBuf
open Xunit
module ProtoBufUtils =
[<ProtoContract>]
@ityonemo
ityonemo / test.md
Last active May 10, 2025 18:28
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@saneleg24
saneleg24 / PY0101EN-2-4-Dictionaries.ipynb
Created October 5, 2020 01:06
Created on Skills Network Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PatOConnor43
PatOConnor43 / lsp_config.lua
Created September 24, 2020 15:24
A small gist to show a dartls setup function to allow all the codeactions. These can be shown with `:lua vim.lsp.buf.code_action()`
local dart_capabilities = vim.lsp.protocol.make_client_capabilities()
dart_capabilities.textDocument.codeAction = {
dynamicRegistration = false;
codeActionLiteralSupport = {
codeActionKind = {
valueSet = {
"",
"quickfix",
"refactor",
"refactor.extract",
@bent-rasmussen
bent-rasmussen / Actor.fs
Last active September 12, 2023 04:23
Experimental high performance actor implementation for F# using channel and task computation expression.
// NOTE: import this Nuget package: TaskBuilder.fs (written using 2.1.0)
//
// Tested in LINQPad (hence Dump method usage).
open System
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open System.Linq
open System.Threading