This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is a C# port of @karpathy microgpt python script (https://gist.github.com/karpathy/8627fe009c40f57531cb18360106ce95) | |
| // It's the closest I could get using C#. | |
| // Use with caution as it could be wrong, but it does seem to get similar outputs | |
| namespace MicroGpt; | |
| public class Value(double data, Value[]? children = null) | |
| { | |
| private readonly Value[] _children = children ?? []; | |
| private Action _backward = () => { }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/share/dotnet/dotnet run | |
| #:package Microsoft.Agents.AI.OpenAI@1.0.0-preview.251113.1 | |
| #:package OpenAI@2.7.0 | |
| using OpenAI; | |
| using Microsoft.Extensions.AI; | |
| using System.ComponentModel; | |
| using static System.Console; | |
| var openAIKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generate_lucky_numbers(limit): | |
| # Start with a list of odd numbers up to 'limit' | |
| numbers = list(range(1, limit + 1, 2)) | |
| idx = 1 # Start with the second number in the list (index 1) | |
| while idx < len(numbers): | |
| step = numbers[idx] | |
| if step >= len(numbers): | |
| break | |
| # Remove every 'step'-th number from the list, starting from the 'step'-1 index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getNext(name) { | |
| var response = getContext().getResponse(); | |
| var result = __.chain() | |
| .filter(function(doc) { return doc.id === name; }) | |
| .value({}, updateCounter); | |
| if(!result.isAccepted) throw new Error("The call was not accepted"); | |
| var next; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| Test1(5); | |
| Test2(5); | |
| } | |
| void Test1(int _) | |
| { | |
| _ = 2 + 2; | |
| Console.WriteLine(_); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get latest remote changes for all repos in sub-directories | |
| Write-Output "Fetching remote repositories..." | |
| Get-ChildItem -Directory | | |
| # Has a hidden .git directory (i.e. is a repository) | |
| Where-Object { ( $_ | Get-ChildItem -Hidden ).Name -contains ".git" } | | |
| # Has at lease one remote | |
| Where-Object { Push-Location $_; (git remote).Count -gt 0; Pop-Location } | | |
| # Fetch remote changes | |
| ForEach-Object { Push-Location $_; "Checking $_..."; git fetch; Pop-Location; "`t...Done"; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-GitIgnore { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory=$true)] | |
| [string[]] | |
| $Targets, | |
| [string] | |
| $OutputDirectory = "$PWD", | |
| [string] | |
| $Filename = ".gitignore", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Suitable for LINQPad with the Autofac nuget package | |
| void Main() | |
| { | |
| ExpectedBehaviour(); | |
| UnexpectedBehaviour(); | |
| } | |
| public void ExpectedBehaviour() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Reactive.Concurrency; | |
| using System.Reactive.Disposables; | |
| using System.Reactive.Linq; | |
| using System.Reactive.Threading.Tasks; | |
| using System.Runtime.InteropServices; | |
| using System.Text; | |
| using System.Threading; |
NewerOlder