1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #2769

    +164.6

    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
    <HTML>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
    </meta>
    <BODY>
    <style>
    <? include "style.css"; ?>
    </style>
    <?
    include "menu.php";
    include "main.php";
    ?>
    </BODY>
    </HTML>

    Своеобразный способ подключения стилей)))
    Из ЛС вконтакта.

    Subsanek, 12 Марта 2010

    Комментарии (39)
  3. PHP / Говнокод #792

    +349.7

    1. 1
    define("_WINDOWS_",file_exists("c:\autoexec.bat") ? TRUE : FALSE);

    :)

    guest, 31 Марта 2009

    Комментарии (39)
  4. C++ / Говнокод #325

    +15.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
    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
    BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime)
    {
        int dayofweek, month, year;
        UINT8 *month_tab;
    
        //Calculate current day of the week
        dayofweek = GetDayOfWeek(days);
    
        year = ORIGINYEAR;
    
        while (days > 365)
        {
            if (IsLeapYear(year))
            {
                if (days > 366)
                {
                    days -= 366;
                    year += 1;
                }
            }
            else
            {
                days -= 365;
                year += 1;
            }
        }
    
    
        // Determine whether it is a leap year
        month_tab = (UINT8 *)((IsLeapYear(year))? monthtable_leap : monthtable);
    
        for (month=0; month<12; month++)
        {
            if (days <= month_tab[month])
                break;
            days -= month_tab[month];
        }
    
        month += 1;
    
        lpTime->wDay = days;
        lpTime->wDayOfWeek = dayofweek;
        lpTime->wMonth = month;
        lpTime->wYear = year;
    
        return TRUE;
    }

    То что вызвало зависание всех MS Zune 30Gb по всему миру.

    guest, 03 Января 2009

    Комментарии (39)
  5. Куча / Говнокод #28820

    +1

    1. 1
    DDoS

    admin, 15 Июля 2023

    Комментарии (38)
  6. Си / Говнокод #28466

    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
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    // https://github.com/flipperdevices/flipperzero-firmware/blob/2a6a3a1bf7ba1ecb42b8cbfc1b1856a54f2878b7/applications/plugins/music_player/music_player.c#L74
    
    static bool is_white_note(uint8_t semitone, uint8_t id) {
        switch(semitone) {
        case 0:
            if(id == 0) return true;
            break;
        case 2:
            if(id == 1) return true;
            break;
        case 4:
            if(id == 2) return true;
            break;
        case 5:
            if(id == 3) return true;
            break;
        case 7:
            if(id == 4) return true;
            break;
        case 9:
            if(id == 5) return true;
            break;
        case 11:
            if(id == 6) return true;
            break;
        default:
            break;
        }
    
        return false;
    }
    
    static bool is_black_note(uint8_t semitone, uint8_t id) {
        switch(semitone) {
        case 1:
            if(id == 0) return true;
            break;
        case 3:
            if(id == 1) return true;
            break;
        case 6:
            if(id == 3) return true;
            break;
        case 8:
            if(id == 4) return true;
            break;
        case 10:
            if(id == 5) return true;
            break;
        default:
            break;
        }
    
        return false;
    }

    Хуйня какая-то. То ли дело "паттерн матчинг".

    j123123, 01 Декабря 2022

    Комментарии (38)
  7. Python / Говнокод #27947

    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
    def foo(n):
        f = True
        k = n % 10
        while n > k:
            n //= 10
            if n % 10 != k:
                f = False
                break
        return f
    
    array = [
        [22, 14, 8, 14],
        [22, 13, 70, 95],
        [22, 12, 51, 10], # Для тестирования
        [20, 11, 51, 56],
        [49, 10, 36, 85]
    ]
    
    f2 = True
    for i in range(len(array[0])):
        c = 0
        for j in range(len(array)):
            if foo(array[j][i]):
                c += 1
        if c > 3:
            f2 = False
            break
    print("True" if f2 else "False")

    Lisya, 12 Января 2022

    Комментарии (38)
  8. JavaScript / Говнокод #27350

    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
    type User = {
        status: 'lamer' | 'junior' | 'govnokoder';
        login: string;
        iq: number;
    }
    
    type ChangeListener<T, K extends keyof T> = {
        name: `${K & string}_Listener`;
        on(newValue: T[K])
    }
    
    const UserIqListener: ChangeListener<User, 'iq'> = {
        name: "iq_Listener", //ничто другое не скомпилируется
        on(event: number) { //понятно, что string тут не скомпилируется
        }
    }
    const UserStatusListener: ChangeListener<User, 'status'> = {
        name: "status_Listener",
        on(newValue: User["status"]) {
            switch (newValue) {
                case "govnokoder": { //понятно, что неверный тип тут не скомпилируется
    
                }
            }
        }
    
    }

    Почему у нас нет "TypeScript"?

    MAKAKA, 11 Апреля 2021

    Комментарии (38)
  9. PHP / Говнокод #27135

    +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
    44. 44
    45. 45
    <?php
    $data = file_get_contents('https://music.yandex.ru/users/[данные удалены]/playlists/[данные удалены]');
    $data = json_decode($data);
    $tracks = $data->result->tracks;
    $track = $tracks[$argv[1]]; // передаём номер песни из плейлиста
    /* Step 1 */
    $trackId = $track->track->id;
    $albumId = $track->track->albums[0]->id;
    $time = strval(time()) . '000';
    $url1 = 'https://music.yandex.ru/api/v2.1/handlers/track/' . $trackId . '%3A' . $albumId . '/web-user_playlists-playlist-track-saved/download/m?hq=0&external-domain=music.yandex.ru&overembed=no&__t=' . $time;
    
    $options['http']['header'] = "Accept: application/json; q=1.0, text/*; q=0.8, */*; q=0.1\r\n"
                               . "X-Retpath-Y: https%3A%2F%2Fmusic.yandex.ru%2F\r\n"
                               . "X-Requested-With: XMLHttpRequest\r\n"
                               . "User-Agent: Mozilla/5.0 [данные удалены]\r\n"
                               . "Cookie: [данные удалены]\r\n";
    $context = stream_context_create($options);
    $data = file_get_contents($url1, false, $context);
    $data = json_decode($data);
    /* Step 2 */
    $time = strval(time()) . '000';
    $url2 = 'https:' . $data->src . '&format=json&external-domain=music.yandex.ru&overembed=no&__t=' . $time;
    $data = file_get_contents($url2);
    $data = json_decode($data);
    /* Step 3 */
    $salt = 'XGRlBW9FXlekgbPrRHuSiA';
    $hash = md5($salt . substr($data->path, 1) . $data->s);
    $url3 = 'https://' . $data->host . '/get-mp3/' . $hash . '/' . $data->ts . $data->path;
    
    $name = $track->track->title;
    if(isset($track->track->version)) {
        $name .= ' (' . $track->track->version . ')';
    }
    
    $artists = array();
    foreach($track->track->artists as $artist) {
        $artists[] = $artist->name;
    }
    $name = implode(',', $artists) . ' - ' . $name;
    
    $name = strtr($name, ':/\\*?<|>', '________');
    $name = str_replace('"', '”', $name);
    $name = mb_substr($name, 0, 255-4);
    
    copy($url3, $name . '.mp3');

    Найдётся всё.

    Fainal_kantdaun, 26 Ноября 2020

    Комментарии (38)
  10. Куча / Говнокод #27119

    0

    1. 1
    https://journal.tinkoff.ru/diary-quality-manager-moscow-950k/

    OCETuHCKuu_nemyx, 19 Ноября 2020

    Комментарии (38)
  11. C++ / Говнокод #27029

    +5

    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
    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
    #include <iostream>
    #include <set>
    #include <unicode/brkiter.h>
    #include <unicode/unistr.h>
    #include <unicode/coll.h>
    #include <unicode/sortkey.h>
    
    bool hasRepeatingCharacters(const icu::UnicodeString &word)
    {
        icu::Locale locale = icu::Locale::getDefault();
        UErrorCode status = U_ZERO_ERROR;
        std::unique_ptr<icu::BreakIterator> it{icu::BreakIterator::createCharacterInstance(locale, status)};
        if (U_FAILURE(status)) throw 42;
        it->setText(word);
    
        std::unique_ptr<icu::Collator> collator{icu::Collator::createInstance(status)};
        if (U_FAILURE(status)) throw 42;
        collator->setStrength(icu::Collator::SECONDARY);
    
        auto less = [](const icu::CollationKey &k1, const icu::CollationKey &k2){
            UErrorCode status = U_ZERO_ERROR;
            bool isLess = k1.compareTo(k2, status) == UCOL_LESS;
            if (U_FAILURE(status)) throw 42;
            return isLess;
        };
        std::set<icu::CollationKey, decltype(less)> cache(less);
    
        int32_t p = it->first();
        while (p != icu::BreakIterator::DONE) {
            int32_t q = it->next();
            if (q == icu::BreakIterator::DONE)
                break;
    
            icu::CollationKey key;
            collator->getCollationKey(word.tempSubStringBetween(p, q), key, status);
            if (U_FAILURE(status)) throw 42;
    
            if (cache.find(key) != cache.end())
                return true;
    
            cache.insert(key);
            p = q;
        }
    
        return false;
    }
    
    int main()
    {
        icu::UnicodeString words(u8"Example english Боб мир כוכב 民主主義語こんにちは", "utf-8");
    
        icu::Locale locale = icu::Locale::getDefault();
        UErrorCode status = U_ZERO_ERROR;
        std::unique_ptr<icu::BreakIterator> it{icu::BreakIterator::createWordInstance(locale, status)};
        if (U_FAILURE(status)) throw 42;
        it->setText(words);
    
        int32_t p = it->first();
        while (p != icu::BreakIterator::DONE) {
            int32_t q = it->next();
            if (q == icu::BreakIterator::DONE)
                break;
    
            if (it->getRuleStatus() != UBRK_WORD_NONE)
            {
                icu::UnicodeString word{words.tempSubStringBetween(p, q)};
                bool hasRepeats = hasRepeatingCharacters(word);
    
                std::string wordUtf8;
                word.toUTF8String(wordUtf8);
                std::cout << (hasRepeats ? "Has repeats: " : "No repeats: ") << wordUtf8 << std::endl;
            }
    
            p = q;
        }
    
        return 0;
    }

    По мотивам https://govnokod.ru/27025

    Сформировать строку из слов исходной строки, содержащих повторяющиеся буквы.

    В 60 строк, к сожалению, не уложился :(

    bormand, 14 Октября 2020

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