Skip to content

Instantly share code, notes, and snippets.

View WhiteBlackGoose's full-sized avatar
🦆
Quack

WhiteBlackGoose

🦆
Quack
View GitHub Profile
@WhiteBlackGoose
WhiteBlackGoose / DynamicNumberGenerator.tt
Last active June 9, 2021 15:31
A T4 template for generating some kind of dynamic for numeric types
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
<# var typesArray = new[]{ "byte", "sbyte", "ushort", "short", "uint", "int", "ulong", "long", "float", "double" }; #>
<# var types = new System.Collections.Generic.List<(string, int)>(); #>
<# var i = 0;
foreach (var type in typesArray)
{
types.Add((type, i));
i++;
@WhiteBlackGoose
WhiteBlackGoose / sample.c
Created March 20, 2021 07:28
My sample importing a function
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//On unix make sure to compile using -ldl and -pthread flags.
//Set this value accordingly to your workspace settings
#if defined(_WIN32)
// #define PathToLibrary "D:\\main\\vs_prj\\AngouriMath\\AngouriMath\\Sources\\AngouriMath\\bin\\Release\\netstandard2.0\\win-x64\\native\\AngouriMath.dll"
#define PathToLibrary "D:\\main\\vs_prj\\nativeaottest\\Test\\bin\\release\\netstandard2.0\\win-x64\\publish\\Test.dll"
#elif defined(__APPLE__)
@WhiteBlackGoose
WhiteBlackGoose / permutations.cpp
Created March 18, 2021 17:40
My inefficient (very inefficient) permutations
/*
Do NOT use it. It is not efficient.
*/
#include <iostream>
#include <vector>
#include <algorithm>
@WhiteBlackGoose
WhiteBlackGoose / instr.md
Last active February 20, 2021 16:11
Инструкция настройки почты на кастомном домене на reg.ru

Перед началом

Придется покупать и домен, и хостинг. Будем делать почту, синонимичную нашей основной (т. е. полученные на корп. почту вы получите на основной, а при отправке вы сможете выбрать почту, с какой отправлять).

Создаем нужные DNS записи

Создаем

Получение писем

В ISPManager -> Почта -> Почтовые ящики -> [наш ящик] -> Слать копии писем на email ставим сюда свой email.

Отправка писем

@WhiteBlackGoose
WhiteBlackGoose / What is AngouriMath?.md
Last active December 4, 2020 08:29
A small note on what is AngouriMath and why we need it

What is AngouriMath?

Well, first of all, it's a computer/symbolic algebra library. Say, are you familiar with SymPy? If so, think of AngouriMath as of something similar, but for .NET. It's .NET, after all, which is going to rule the programming world, not python.

If you don't know SymPy, AngouriMath can be similar to Wolfram|Alpha in some way. You can manipulate so-called symbolic expressions, that is, mathematical expressions written within a normal human notation (aka with functions, operators, etc.), and variables.

Nuget (with prereleases)

@WhiteBlackGoose
WhiteBlackGoose / BenchArrays.cs
Created August 26, 2020 10:37
This little benchmark can help you to decide whether to use int* or int[]
/*
i7-7700HQ
| Method | 10 | 1_000 | 30_000 | 1_000_000 | 16_000_000 |
|---------------- |----------:|----------:|----------:|-----------:|-----------:|
| TestSlowChaotic | 0.9583 ns | 1.0177 ns | 2.8141 ns | 21.2463 ns | 86.9868 ns |
| TestFastChaotic | 0.9741 ns | 0.9583 ns | 2.7750 ns | 24.7405 ns | 86.9611 ns |
| TestSlowRow | 0.8036 ns | 0.7278 ns | 0.7230 ns | 0.7543 ns | 0.6666 ns |
| TestFastRow | 0.3722 ns | 0.3746 ns | 0.3648 ns | 0.6517 ns | 0.5979 ns |
*/
@WhiteBlackGoose
WhiteBlackGoose / NestedLoopsCompiler.cs
Last active August 26, 2020 10:40
Simple code for generating loops in linq expressions
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
public static class NestedLoopBuilder
{
public static Expression CreateLoop(ParameterExpression var, Expression until, Expression onIter)
@WhiteBlackGoose
WhiteBlackGoose / GenericTensor.md
Last active March 16, 2023 05:53
This is a short article about how I managed to implement basic generic tensor library

Generic tensor library in C# in a week

Hello!

For this article we take Tensor as a N-dimensional array whose last two axes might be interpreted as Matrix and/or the last axis might be interpreted as Vector. For TLDR the result is here.

What do we want?

  1. Tensors (N-dimensional storage)
  2. Implementation of methods and functions for working with tensors as with data storages
class InteractionField:
def __init__(self, F):
self.points = []
self.F = F
def move_all(self, dt):
for p in self.points:
p.move(dt)
class Point:
def __init__(self, coords, mass=1.0, q=1.0 speed=None, **properties):
self.coords = coords
if speed is None:
self.speed = Vector(*[0 for i in range(len(coords))])
else:
self.speed = speed
self.acc = Vector(*[0 for i in range(len(coords))])
self.mass = mass
self.__params__ = ["coords", "speed", "acc", "q"] + list(properties.keys())