Си диез / Говнокод #29183 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
using Godot;

namespace CW2EB.UI;
public partial class EscQuittingLabel : Label {

	Tween tween, tween2thesequel;
	public override void _Ready(){
		base._Ready();
		tween = GetTree().CreateTween().SetParallel();
		tween2thesequel = GetTree().CreateTween();
		tween.TweenProperty(this, "theme_override_colors/font_color", new Color(1f, 1f, 1f, 1f), 1);
		tween.TweenProperty(this, "theme_override_colors/font_shadow_color", new Color(0f, 0f, 0f, 1f), 1);

		
		tween2thesequel.TweenCallback(Callable.From(TweenStage1)).SetDelay(.25);
		tween2thesequel.TweenCallback(Callable.From(TweenStage2)).SetDelay(.25);
		tween2thesequel.TweenCallback(Callable.From(TweenStage3)).SetDelay(.25);
		tween2thesequel.TweenCallback(Callable.From(TweenStage4)).SetDelay(.5);
	}

	public void TweenStage1()
		=> Text = Tr("Quitting") + ".";

	public void TweenStage2()
		=> Text = Tr("Quitting") + "..";

	public void TweenStage3()
		=> Text = Tr("Quitting") + "...";

	public void TweenStage4()
		=> GetTree().Quit();
}

Как сделать постепенно появляющееся многоточие?

GhostNoise GhostNoise, (Updated )

Комментарии (1, +1)

Си диез / Говнокод #29152 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
// https://github.com/dotnet/runtime/issues/117233#issuecomment-3028066225

// Issue: Math.Pow relies directly on the OS pow implementation

// Location: [src/coreclr/classlibnative/float/floatdouble.cpp lines 232‑236] and [src/coreclr/classlibnative/float/floatsingle.cpp lines 207‑211]

// COMDouble::Pow and COMSingle::Pow simply call pow/powf from the C runtime. On Windows 11 Insider Preview (build 27881.1000),
// these functions can return incorrect results (e.g., Math.Pow(-1, 2) giving -1). The JIT also uses these functions for constant folding, causing
// wrong constants to be embedded at compile time.

// Suggested Fix: Introduce a managed fallback in COMDouble::Pow/COMSingle::Pow that handles negative bases with integral exponents, bypassing the faulty system call.

//A simple approach:

FCIMPL2_VV(double, COMDouble::Pow, double x, double y)
{
    FCALL_CONTRACT;

    if ((x < 0.0) && (y == floor(y)))
    {
        double absResult = pow(-x, y);
        return fmod(fabs(y), 2.0) == 1.0 ? -absResult : absResult;
    }

    return pow(x, y);
}

// Suggested Implementation:

// Add the following code to src/coreclr/classlibnative/float/floatdouble.cpp below line 234 before the return pow:

if ((x < 0.0) && (y == floor(y)))
{
    double result = pow(-x, y);

    if (fmod(fabs(y), 2.0) != 0.0)
    {
        result = -result;
    }

    return result;
}

// Add the following code to src/coreclr/classlibnative/float/floatsingle.cpp below line 209 before the return powf:

if ((x < 0.0f) && (y == floorf(y)))
{
    float result = powf(-x, y);

    if (fmodf(fabsf(y), 2.0f) != 0.0f)
    {
        result = -result;
    }

    return result;
}

// Add the following code to src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Math.cs below line 1124:

[Fact]
public static void Pow_NegativeBaseEvenExponent_ReturnsPositive()
{
    Assert.Equal(1.0, Math.Pow(-1, 2));
    Assert.Equal(16.0, Math.Pow(-2, 4));
}

Вот к чему плавучий петух приводит!

j123123 j123123, (Updated )

Комментарии (22, +22)

Си диез / Говнокод #29059 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
using System;
using System.Threading;
using System.Diagnostics;

public class ANYRUN_server
{
    private static string application = null;

    public static void Main(string[] args)
    {
        Authorization();
    }
    
    private static void Authorization()
    {
	DateTime today = DateTime.Now;
	
        Console.WriteLine("\"Not business mail users\" registration");
        Console.WriteLine("Please fill out our straightforward application form:");
	application = Console.ReadLine();
	SendApplication(application);
	Thread.Sleep(3600000);
        if (today.Month == 4 && today.Day == 1)
        {
            AcceptApplication();
        }
	else
	{
	    RejectApplication();
	}
    }
	
    private static void SendApplication(string application)
    {
        // Like, who cares about the application?
	application = null;
    }
    
    private static void RejectApplication()
    {
        Console.Write("Hello, after reviewing your application we are unable to provide you with a free personal account. ");
        Console.Write("If you want to check files for malware I recommend using services such as https://opentip.kaspersky.com/ and https://www.virustotal.com/gui/home/upload.");
    }
	
    private static void AcceptApplication()
    {
        Console.WriteLine("Hello, after reviewing your application we decided to provide you with a free personal account.");
	Console.WriteLine("Please, wait for a password...");
	Thread.Sleep(1800000);
	Console.WriteLine("Here's your password: ");
	Thread.Sleep(5000);
	Process.Start("videoplayer.exe", "C:\\Rickrolled.mp4");
    }
}

Исходный код для регистрации пользователей без бизнеспочты в дискорде сайта any.run #meme

BelCodeMonkey BelCodeMonkey, (Updated )

Комментарии (1, +1)

Си диез / Говнокод #28997 Ссылка на оригинал

0

  1. 1
Тип объекта, который инициализируется безумно.

https://learn.microsoft.com/ru-ru/dotnet/api/system.lazy-1?view=net-8.0#--------------
Обожаю автоматический перевод в документации

В оригинале, кстати, вот так:
https://learn.microsoft.com/en-us/dotnet/api/system.lazy-1?view=net-8.0#type-parameters
Заметьте, что ссылка тоже побилась

kezzyhko kezzyhko, (Updated )

Комментарии (3, +3)

Си диез / Говнокод #28985 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
private void UpdateRowInfo()
{
	//код
	if (condition);
	{
		//код
	}
	//код
}

Наткнулся на вот такое в одном проекте. Точка с запятой после if считается пустым statement, а всё что внутри фигурных скобок - просто блок, от if'а независящий. Всё, как IDEшка об этом сообщает - точка с запятой стала серого цвета (на сером фоне, ага). Угадайте, сколько времени искался этот баг

kezzyhko kezzyhko, (Updated )

Комментарии (3, +3)

Си диез / Говнокод #28939 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
/// <summary>
/// перобразуем DateTime? в DateTime, если не получается, то возвращаем текущую дату
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private DateTime DateTimeHelper(DateTime? date)
{
    try
    {
        return (DateTime)date;
    }
    catch
    {
        return DateTime.Now;
    }
}

reemind reemind, (Updated )

Комментарии (1, +1)

Си диез / Говнокод #28877 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
string[] words = line.Split(' ');
foreach (var word in words)
{
    Console.Write(word);
    switch (word)
    {
        case "11":
            Console.WriteLine($"{tableEng[0, 0]}");
            break;
        case "12":
            Console.WriteLine($"{tableEng[0, 1]}");
            break;
        case "13":
            Console.WriteLine($"{tableEng[0, 2]}");
            break;
        case "14":
            Console.WriteLine($"{tableEng[0, 3]}");
            break;
        case "15":
            Console.WriteLine($"{tableEng[0, 4]}");
            break;
        case "21":
            Console.WriteLine($"{tableEng[1, 0]}");//
            break;
        case "22":
            Console.WriteLine($"{tableEng[1, 1]}");
            break;
        case "23":
            Console.WriteLine($"{tableEng[1, 2]}");
            break;
        case "24":
            Console.WriteLine($"{tableEng[1, 3]}");
            break;
        case "25":
            Console.WriteLine($"{tableEng[1, 4]}");
            break;
        case "31":
            Console.WriteLine($"{tableEng[2, 0]}");
            break;
        case "32":
            Console.WriteLine($"{tableEng[2, 1]}");
            break;
        case "33":
            Console.WriteLine($"{tableEng[2, 2]}");
            break;
        case "34":
            Console.WriteLine($"{tableEng[2, 3]}");
            break;
        case "35":
            Console.WriteLine($"{tableEng[2, 4]}");
            break;
        case "41":
            Console.WriteLine($"{tableEng[3, 0]}");
            break;
        case "42":
            Console.WriteLine($"{tableEng[3, 1]}");
            break;
        case "43":
            Console.WriteLine($"{tableEng[3, 2]}");
            break;
        case "44":
            Console.WriteLine($"{tableEng[3, 3]}");
            break;
        case "45":
            Console.WriteLine($"{tableEng[3, 4]}");
            break;
        case "51":
            Console.WriteLine($"{tableEng[4, 0]}");
            break;
        case "52":
            Console.WriteLine($"{tableEng[4, 1]}");
            break;
        case "53":
            Console.WriteLine($"{tableEng[4, 2]}");
            break;
        case "54":
            Console.WriteLine($"{tableEng[4, 3]}");
            break;
        case "55":
            Console.WriteLine($"{tableEng[4, 4]}");
            break;
    }
    
}
}
Console.ReadLine();

Дело IsBukva живёт.

https://habr.com/ru/articles/771530/

ISO ISO, (Updated )

Комментарии (34, +34)

Си диез / Говнокод #28850 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
public readonly struct Int64 : IComparable<long>, IConvertible, 
IEquatable<long>, IParsable<long>, ISpanParsable<long>, 
System.Numerics.IAdditionOperators<long,long,long>, 
System.Numerics.IAdditiveIdentity<long,long>, 
System.Numerics.IBinaryInteger<long>, System.Numerics.IBinaryNumber<long>, 
System.Numerics.IBitwiseOperators<long,long,long>, 
System.Numerics.IComparisonOperators<long,long,bool>, 
System.Numerics.IDecrementOperators<long>, 
System.Numerics.IDivisionOperators<long,long,long>, 
System.Numerics.IEqualityOperators<long,long,bool>, 
System.Numerics.IIncrementOperators<long>, 
System.Numerics.IMinMaxValue<long>, 
System.Numerics.IModulusOperators<long,long,long>, 
System.Numerics.IMultiplicativeIdentity<long,long>, 
System.Numerics.IMultiplyOperators<long,long,long>, 
System.Numerics.INumber<long>, System.Numerics.INumberBase<long>, 
System.Numerics.IShiftOperators<long,int,long>, 
System.Numerics.ISignedNumber<long>, 
System.Numerics.ISubtractionOperators<long,long,long>, 
System.Numerics.IUnaryNegationOperators<long,long>, 
System.Numerics.IUnaryPlusOperators<long,long>

https://learn.microsoft.com/en-us/dotnet/api/system.int64?view=net-7.0

ISO ISO, (Updated )

Комментарии (43, +43)