Skip to content

Instantly share code, notes, and snippets.

View WhiteBlackGoose's full-sized avatar
🦆
Quack

WhiteBlackGoose

🦆
Quack
View GitHub Profile
@WhiteBlackGoose
WhiteBlackGoose / whatisit.py
Last active December 25, 2018 14:05
computer_ling
from nltk import word_tokenize, sent_tokenize
PATH = "text_for_test.txt"
text = open(PATH, encoding="utf8").read()
words3, words1 = 0, 0
for word in word_tokenize(text):
if len(word) == 3:
words3 += 1
elif len(word) == 1:
words1 += 1
class Vector(list):
def __init__(self, *el):
for e in el:
self.append(e)
def __add__(self, other):
if type(other) is Vector:
assert len(self) == len(other), "Error 0"
r = Vector()
for i in range(len(self)):
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())
class InteractionField:
def __init__(self, F):
self.points = []
self.F = F
def move_all(self, dt):
for p in self.points:
p.move(dt)
@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 / 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 / instr.md
Last active February 20, 2021 16:11
Инструкция настройки почты на кастомном домене на reg.ru

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

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

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

Создаем

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

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

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

@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 / 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__)