1. JavaScript / Говнокод #25403

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    var normalWidth = 1440 + 20;
    var maxStep = 720;
    
    var eDivSizeWidth = 1440;
    var eDivBodyEndWidth = 1400;
    var eSearchInputWidth = 920;
    var eSearchButtonLeft = 1210;
    var eCartButtonLeft = 1260;
    
    function onWindowResize()
    {
    	var step = normalWidth - innerWidth;
    	if (step < 0)
    		step = 0;
    	else if (step > maxStep)
    		step = maxStep;
    	document.getElementById('divSize').style.width = eDivSizeWidth - step;
    	document.getElementById('divBody').style.width = eDivBodyEndWidth - step;
    	document.getElementById('divEnd').style.width = eDivBodyEndWidth - step;
    	document.getElementById('mainSearch').style.width = eSearchInputWidth - step;
    	document.getElementById('searchButton').style.left = eSearchButtonLeft - step;
    	document.getElementById('cartButton').style.left = eCartButtonLeft - step;
    }
    
    window.onresize = function() { onWindowResize(); };
    window.onload = function() { onWindowResize(); };

    GenkaFF, 24 Февраля 2019

    Комментарии (0)
  2. C# / Говнокод #25402

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    static string ArrayToString(byte[] a) => return string.Join(",", a); // гуд
    
            static byte[] StringToArray(string a) // бэд
            {
                var parts = a.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var partsLen = parts.Length;
                var b = new byte[partsLen];
                for (var i = 0; i < partsLen; i++)
                    b[i] = Convert.ToByte(parts[i]);
                return b;
            }

    GenkaFF, 24 Февраля 2019

    Комментарии (8)
  3. C++ / Говнокод #25401

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    constexpr void foo(int &a, const int b)
    {
      a = b * 2;
    }
    
    constexpr void foo2(int *a, const int b)
    {
      *a = b * 2;
    }
    
    constexpr int shit = []() constexpr {int a = 0; foo(a, 666); return a;}();
    
    constexpr int shit2 = []() constexpr {int a = 0; foo2(&a, 666); return a;}();

    Итак, время обсирать крестоговно. Вот есть там такая фича - можно по ссылке и указателю хуйню через constexpr присваивать. Только вот эта тупая херня под названием лямбда, она обязательно требует инициализации некоторого говна, передаваемого куда-то там, если она объявлена как constexpr. На кой хрен мне что-то инициализировать, если это говно я в constexpr не читаю, а только присваиваю? И сделайте там какие-нибудь write-only переменные, которые через ссылку или указатель пробрасывать можно, ну чисто чтоб поржать

    j123123, 23 Февраля 2019

    Комментарии (37)
  4. PHP / Говнокод #25400

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
    	$i = -1;
    	while ($i == $i)
    	{
    		$i = $i + (1);
    		echo($i + "," + " ");
    	}
    ?>

    KEK

    GenkaFF, 23 Февраля 2019

    Комментарии (40)
  5. Си / Говнокод #25399

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    // https://github.com/ghc/ghc/blob/e204431e5a5e2fd16da52b04bda2798f16c51344/rts/Interpreter.c#L1184
    
            case bci_PUSH8: {
                int off = BCO_NEXT;
                Sp_subB(1);
                *(StgWord8*)Sp = *(StgWord8*)(Sp_plusB(off+1));
                goto nextInsn;
            }
    
            case bci_PUSH16: {
                int off = BCO_NEXT;
                Sp_subB(2);
                *(StgWord16*)Sp = *(StgWord16*)(Sp_plusB(off+2));
                goto nextInsn;
            }
    
            case bci_PUSH32: {
                int off = BCO_NEXT;
                Sp_subB(4);
                *(StgWord32*)Sp = *(StgWord32*)(Sp_plusB(off+4));
                goto nextInsn;
            }
    
            case bci_PUSH8_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }
    
            case bci_PUSH16_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }
    
            case bci_PUSH32_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }

    https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Interpreter

    > The linker lives in rts/Linker.c and is responsible for handling runtime loading of code into a Haskell process. This is something of a big blob of unpleasant code, and see DynamicGhcPrograms for information about efforts to reduce our dependence on this linker.

    Итак, тут у нас стековая машина из хачкеля, которая вродекак отвечает за динамическую загрузку какого-то говна.

    j123123, 22 Февраля 2019

    Комментарии (101)
  6. Куча / Говнокод #25398

    +1

    1. 1
    Прыщи

    syoma, 22 Февраля 2019

    Комментарии (299)
  7. Си / Говнокод #25397

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    // https://github.com/alpertron/calculators/blob/15607feafb0ddb1c075bb326dc6ea2224a4c50bb/siqs.c#L3720
    
                switch (NumberLengthA)
                {
                case 7:
                  dRem = (double)*(piDividend + 6) * (double)rowPrimeTrialDivisionData->exp6 +
                    (double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
                    (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 6:
                  dRem = (double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
                    (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 5:
                  dRem = (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 4:
                  dRem = (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                default:
                  dRem = (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                }

    Generic two integer variable equation solver
    This calculator can solve equations of the form a⁢x² + b⁢x⁢y + c⁢y² + dx + ey + f = 0 where the unknowns x and y are integer numbers.

    j123123, 22 Февраля 2019

    Комментарии (6)
  8. Куча / Говнокод #25396

    0

    1. 1
    Хостинг

    syoma, 22 Февраля 2019

    Комментарии (1561)
  9. C++ / Говнокод #25395

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    // https://github.com/CVC4/CVC4/blob/14b9dbaa0c9e8dce52d1a28595dc1cc80756abed/src/expr/pickler.cpp
    
    
    static Block mkBlockBody4Chars(char a, char b, char c, char d) {
      Block newBody;
      newBody.d_body.d_data = (a << 24) | (b << 16) | (c << 8) | d;
      return newBody;
    }
    
    static char getCharBlockBody(BlockBody body, int i) {
      Assert(0 <= i && i <= 3);
    
      switch(i) {
      case 0: return (body.d_data & 0xff000000) >> 24;
      case 1: return (body.d_data & 0x00ff0000) >> 16;
      case 2: return (body.d_data & 0x0000ff00) >> 8;
      case 3: return (body.d_data & 0x000000ff);
      default:
        Unreachable();
      }
      return '\0';
    }
    
    // ...
    
    void PicklerPrivate::toCaseString(Kind k, const std::string& s) {
      d_current << mkConstantHeader(k, s.size());
    
      unsigned size = s.size();
      unsigned i;
      for(i = 0; i + 4 <= size; i += 4) {
        d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], s[i + 3]);
      }
      switch(size % 4) {
      case 0: break;
      case 1: d_current << mkBlockBody4Chars(s[i + 0], '\0','\0', '\0'); break;
      case 2: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1], '\0', '\0'); break;
      case 3: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], '\0'); break;
      default:
        Unreachable();
      }
    
    }

    Очередное переизобретение какой-то байтоебской поеботы типа ntohl(). И вообще, тут UB.

    j123123, 21 Февраля 2019

    Комментарии (94)
  10. Kotlin / Говнокод #25394

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private fun GetDeviceInfo(request: HttpServerRequest): HashMap<String, Info>
    	{
    		val deviceInfo = request.getParam(NAME_ID)?.let { id ->
    			(Ports.ById(id) ?: Ports.ByDeviceId(id))?.let(DeviceInfo.Companion::Create)
    			?: Files.FromPath(id)?.let { file ->
    				FileInfo.GetInfo(file)
    			} ?: (Core.GetTask(id) as? Scenario)?.SourceFile?.let(::FileInfo)
    		}
    
    		return deviceInfo?.let { hashMapOf(REQUEST_RESULT to it) } ?: hashMapOf()
    	}

    jadedolej, 21 Февраля 2019

    Комментарии (15)