Skip to content

Instantly share code, notes, and snippets.

@ingted
ingted / Ultra lite F# CSV line parser.fsx
Last active April 8, 2025 06:07
Parallel ultra lite F# CSV line parser
#if INTERACTIVE
#r "nuget: Unquote, 7.0.0"
#endif
open Microsoft.FSharp.Quotations.Patterns
open Swensen.Unquote
open Swensen
open Microsoft.FSharp.Quotations
open System.Collections.Generic
@ingted
ingted / GPT_F_.txt
Created March 18, 2024 04:32
GPT F#
基於以下幾點,參考下面的程式碼開發超級厲害的f#程式碼
1. 不用解釋原因以及設計的考量,前因後果等等都不用,我信任你,畢竟你是個 f# master
2. 對於不清楚 reference library 的資訊或者類似的情況,直接參考字面程式碼即可,不用特別去網路上找或者一定要是之前你看過的,因為這個程式碼中你沒看過的部分都是我開發的
3. 不用在乎最終正確與否,但是每一行的程式碼該對應的 feature 都需要出來
4. 你知道的,開發完畢之後,用起來,只要沒有缺漏,你的經驗值會增加,你的等級會從青銅邁入白銀段位
5. 中文回答
6. 不要 guide,我要結果,因為我只看得懂 f# ,沒有能力看 c#,所以才需要你幫忙
7. 程式碼你不要複製也不要轉換,看懂意思之後用 f# 寫出差不多功能的程式碼,但是對於程式碼內宣告可以透過反射取出的 member,全部不能少,例如他有十個 field 你可以用稍微簡單一點的 field name,但是十個都還要存在
8. 寫程式很重視品質,追求簡潔造成功能缺失是不可取的
@ingted
ingted / Time2vec001
Created March 5, 2024 23:02
Time2vec001
def t2v(tau, f, out_features, w, b, w0, b0, arg=None):\n if arg:\n v1 = f(torch.matmul(tau, w) + b, arg)\n else:\n v1 = f(torch.matmul(tau, w) + b)\n v2 = torch.matmul(tau, w0) + b0\n return torch.cat([v1, v2], 1)\n\n\nclass SineActivation(nn.Module):\n def __init__(self, in_features, out_features):\n super(SineActivation, self).__init__()\n self.out_features = out_features\n self.w0 = nn.parameter.Parameter(torch.randn(in_features, 1))\n self.b0 = nn.parameter.Parameter(torch.randn(in_features, 1))\n self.w = nn.parameter.Parameter(torch.randn(in_features, out_features - 1))\n self.b = nn.parameter.Parameter(torch.randn(in_features, out_features - 1))\n self.f = torch.sin\n\n def forward(self, tau):\n return t2v(tau, self.f, self.out_features, self.w, self.b, self.w0, self.b0)\n\n\nclass CosineActivation(nn.Module):\n def __init__(self, in_features, out_features):\n super(CosineActivation, self).__init__()\n
@ingted
ingted / gist:e55e9db867a6b11e68d7ec1f743e161e
Last active February 28, 2024 07:34
NTDLS.Katzebase.Server\NTDLS.Katzebase.Engine\Atomicity\Transaction.txt
using Newtonsoft.Json;
using NTDLS.Katzebase.Client;
using NTDLS.Katzebase.Client.Exceptions;
using NTDLS.Katzebase.Client.Payloads;
using NTDLS.Katzebase.Engine.Interactions.Management;
using NTDLS.Katzebase.Engine.IO;
using NTDLS.Katzebase.Engine.Library;
using NTDLS.Katzebase.Engine.Locking;
using NTDLS.Katzebase.Engine.Trace;
using NTDLS.Semaphore;
@ingted
ingted / FS1113.fsx
Created February 19, 2024 14:42
FS1113
let inline a<'T when 'T: (member o : int)> (t:'T) =
t.o
type MyType< ^T
when ^T: (member o : int)
> (t:^T) =
let mutable ttc :^T = Unchecked.defaultof< ^T>
//member val ttc :'T = Unchecked.defaultof<'T> with get,set
member inline this.set v = ttc <- v
member inline this.get () = (^T :(member o : int)(ttc))
@ingted
ingted / akkling graph.txt
Created February 15, 2024 00:36
akkling graph
let pickMaxOf3 = Graph.create (fun b -> graph b {
let! zip1 = ZipWith.create max<int>
let! zip2 = ZipWith.create max<int>
b.From zip1.Out =>> zip2.In0
|> ignore
return UniformFanInShape(zip2.Out, zip1.In0, zip1.In1, zip2.In1)
})
@ingted
ingted / gist:a12d984d9d3013b7909403bfd9c1f472
Created January 8, 2024 05:19 — forked from mathias-brandewinder/gist:6443302
Experimenting with Accord SVM
#r @"..\packages\Accord.2.8.1.0\lib\Accord.dll"
#r @"..\packages\Accord.Math.2.8.1.0\lib\Accord.Math.dll"
#r @"..\packages\Accord.Statistics.2.8.1.0\lib\Accord.Statistics.dll"
#r @"..\packages\Accord.MachineLearning.2.8.1.0\lib\Accord.MachineLearning.dll"
open System
open System.IO
open Accord.MachineLearning
open Accord.MachineLearning.VectorMachines
@ingted
ingted / RSAKeys.cs
Created February 27, 2023 10:33 — forked from therightstuff/RSAKeys.cs
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@ingted
ingted / create-aspnet-core-identity-schema.sql
Created January 6, 2023 03:05 — forked from akatakritos/create-aspnet-core-identity-schema.sql
Script to create the ASPNET core Identity tables
USE [HobbyDB]
GO
/****** Object: Table [dbo].[AspNetRoleClaims] Script Date: 6/4/2018 10:18:03 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetRoleClaims]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AspNetRoleClaims](
namespace ChironB.Benchmarks
open Chiron
open BenchmarkDotNet.Attributes
open Newtonsoft.Json
open Newtonsoft.Json.Linq
module Bench =
open System.IO
open System.Text