Skip to content

Instantly share code, notes, and snippets.

View dadhi's full-sized avatar
🎯
Focusing

Maksim Volkau dadhi

🎯
Focusing
View GitHub Profile
@dadhi
dadhi / HVML.c
Created November 7, 2024 06:24 — forked from VictorTaelin/HVML.c
$10k bounty - make HVML.c 50% faster on Apple M3
// Post: https://x.com/VictorTaelin/status/1854326873590792276
// Note: The atomics must be kept.
// Note: This will segfault on non-Apple devices due to upfront mallocs.#include <stdint.h>
#include <stdint.h>
#include <stdatomic.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
@dadhi
dadhi / rename-pictures.sh
Created October 4, 2024 20:33 — forked from jart/rename-pictures.sh
Shell script for renaming all images in a folder
#!/bin/sh
# rename-pictures.sh
# Author: Justine Tunney <[email protected]>
# License: Apache 2.0
#
# This shell script can be used to ensure all the images in a folder
# have good descriptive filenames that are written in English. It's
# based on the Mistral 7b and LLaVA v1.5 models.
#
# For example, the following command:
@dadhi
dadhi / gist:b6d19276c0619d78b41d93138b07a562
Created September 2, 2024 13:30
better_target_framework_selector.csproj
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net48;$(TargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<DefineConstants Condition="'$(TargetFramework)' != 'net48'">$(DefineConstants);READONLYSPAN</DefineConstants>
</PropertyGroup>
@dadhi
dadhi / Program.cs
Created May 7, 2024 13:43 — forked from kolebynov/Program.cs
Fixed stack/heap array with any element type
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList<string, Buffer16<string>>();
var list2 = new FixedList<string, Buffer32<string>>();
UseList(ref list1, "Hello");
UseList(ref list2, "World");
Console.WriteLine(list1.GetRef(0));
Console.WriteLine(list2.GetRef(0));
@dadhi
dadhi / Program.cs
Created May 7, 2024 13:27 — forked from kolebynov/Program.cs
Simple stack/heap dynamic array
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList16<int>();
var list2 = new FixedList32<int>();
UseList(ref list1, 1);
UseList(ref list2, 2);
static void UseList<TItem, TList>(ref TList list, TItem item)
where TItem : unmanaged
@dadhi
dadhi / HeapSort.cs
Created January 9, 2024 23:06
Heap sort of string in place instead of insertion sort
// https://www.hackertouch.com/csharp-generic-heap-sort.html
using System;
public static class HeapSortMethods
{
public static void HeapSort(string[] a)
{
// build binary heap from all items
for (int i = 0; i < a.Length; i++)
@dadhi
dadhi / CSharpBench.cs
Created December 15, 2023 21:34 — forked from stolnikov/CSharpBench.cs
Odin vs C#
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace CSharpLib;
public class CSharpBench
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int[] CSharp_Bench2(int[] a, int[] b, int[] result, int size)
@dadhi
dadhi / fix-wsl2-dns-resolution
Created November 27, 2023 14:17 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@dadhi
dadhi / interview_question_phone_permutations.cs
Last active September 27, 2023 10:07
Phone permutations interview question
using System;
using System.Collections.Generic;
// Image of a telephone's keypad: https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Telephone-keypad2.svg/2880px-Telephone-keypad2.svg.png
// Problem: Given phone number, output all possible letter values or "words".
// Example:
// Input: 123-000
// Output: 1ad-000 1ae-000 1af-000 1bd-000 1be-000 1bf-000 1cd-000 1ce-000 1cf-000
//
// Example:
@dadhi
dadhi / AsyncQueueWithLimitedParalellizm.cs
Created September 26, 2023 16:49
The possible interview question about the work queue in C# // @ThePrimeagen
// ## Dumb-dumb initial solution
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
public class Program
{
public static async Task Main()
{