Skip to content

Instantly share code, notes, and snippets.

View KvanTTT's full-sized avatar

Ivan Kochurkin KvanTTT

View GitHub Profile
@KvanTTT
KvanTTT / remarks.md
Created February 25, 2018 20:28
seva-calculator

Функциональность

  • Некорректная обработка чисел больше размерности int. Например, 9999999999999999999=-1981284353.
  • IndexOutOfRangeException в случае пустого ввода и в случае если оператор умножения или сложения находятся в начале: +2, *2.
  • Программа не покрыта тестами.
  • Дублирование логики в switch - case. Символьный тип элементарно перевести в число, а блок с проверкой от '0' до '9' заменяется одной строчкой. То же самое относится к операторам '*' и '+'.
@KvanTTT
KvanTTT / Kochurkins.cmd
Created September 12, 2018 21:00
Script for generating genealogy tree inside Git repository
chcp 65001
mkdir Kochurkins
cd Kochurkins
git init
git checkout --orphan @I36@
git commit -m "Татьяна : Birth F" --date "01/01/1970 00:00:00" --author "Татьяна <>" --allow-empty
git checkout --orphan @I35@
git commit -m "Степан Голобоков : Birth M" --date "01/01/1970 00:00:00" --author "Степан Голобоков <>" --allow-empty
git checkout --orphan @I33@
class Program
{
class Animal
{
}
class Cat : Animal
{
public void Meow()
{
@KvanTTT
KvanTTT / QuineSnake.bat
Last active September 16, 2019 13:08
Game Snake in source code (Quine). One can play this with batch or power scripts. The game can be finished =)
echo off
:LOOP
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "QuineSnake.cs"
"QuineSnake.exe" > "QuineSnake.cs"
type "QuineSnake.cs"
goto LOOP
:END
@KvanTTT
KvanTTT / SwitchByObjectVsInt.cs
Created March 13, 2020 13:22
Compare generated code for switch by object vs switch by int
using System;
public class C {
public const int C1Type = 1;
public const int C2Type = 2;
public const int C3Type = 3;
public const int C4Type = 4;
public abstract class Base
{
@KvanTTT
KvanTTT / PolynomialRegression.cs
Last active July 28, 2020 07:48
Implementation of Polynomial regression (http://en.wikipedia.org/wiki/Polynomial_regression) with Math.NET library (http://www.mathdotnet.com/)
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Generic;
public class PolynomialRegression
{
private int _order;
private Vector<double> _coefs;
/// <summary>
/// Calculates polynom regression for xData = [x1, x2, ... , xn] and yData = [y1, y2, ... , yn].
using System;
class Program
{
static void Main()
{
int validTimeCount = 0;
for (int hour = 0; hour < 24; hour++)
{
@KvanTTT
KvanTTT / RESHI_ESLI_SILEN.smt
Last active February 13, 2021 10:37
РЕШИ + ЕСЛИ = СИЛЕН
; R E SH I
; E S L I
; S I L E N
; Обявление уникальных букв
(declare-const R Int)
(declare-const E Int)
(declare-const SH Int)
(declare-const I Int)
@KvanTTT
KvanTTT / CSharpAntlrParser.cs
Last active May 13, 2021 18:31
ANTLR C# runtime code fragment for correct C# code parsing with preprocessor directives (for CSharp grammar in oficial repository: https://github.com/antlr/grammars-v4/tree/master/csharp).
List<IToken> codeTokens = new List<IToken>();
List<IToken> commentTokens = new List<IToken>();
Lexer preprocessorLexer = new CSharpLexer(new AntlrInputStream(sourceCode));
// Collect all tokens with lexer (CSharpLexer.g4).
var tokens = preprocessorLexer.GetAllTokens();
var directiveTokens = new List<IToken>();
var directiveTokenSource = new ListTokenSource(directiveTokens);
var directiveTokenStream = new CommonTokenStream(directiveTokenSource, CSharpLexer.DIRECTIVE);
CSharpPreprocessorParser preprocessorParser = new CSharpPreprocessorParser(directiveTokenStream);
@KvanTTT
KvanTTT / LargeLexerNew.cs
Created January 21, 2022 19:52
Old vs New Atn Serialization C#
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// ANTLR Version: 4.9.3
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------