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

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function trim(s)
    {
        var i,j;
        for (i = 0; i < s.length && s.charAt(i) == " "; i++);
        for (j = s.length-1; j >= 0 && s.charAt(j) == " "; j--);
        if (i<=j)
            return s.substring(i, j+1);
        else
            return '';
    }

    opzab, 19 Октября 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $f=file('[путь к файлу]'); 
    shuffle($f); 
    $f[0] - первая случайная строка 
    $f[1] - вторая случайная строка 
    $f[2] - третья случайная строка

    вот PHP еще. если например несколько строк надо. ну и оптимальнее чем предложено выше.
    http://megaobzor.com/forum-top-77608.html

    Наверху было классическое

    $quote=file('words.txt'); 
    echo $quote[rand(0,count($quote)-1)];

    Несомненно, оптимальнее. Особенно, если строчек эдак тыщ сто.

    Кстати, предлагаю начать очередной холивар по поводу того, как с самыми меньшими затратами вынуть из файла рандомную строчку :)

    7ion, 02 Февраля 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function openSQLConnection($data)
    {
    	$db_host = $data["host"];
    	$db_user = $data["login"];
    	$db_pass = $data["pass"];
    	$db_name = $data["db"];
    	mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
    	mysql_select_db($db_name) or die(mysql_error()); 
    }

    Суровый SQL-коннектор, взято из скриптов платежной системы nextpay[ru]

    zenn, 20 Января 2011

    Комментарии (61)
  5. Lua / Говнокод #4220

    −79

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ga = {} --gay/pure lua style
    GA = ga --1337 men style
    GlobalAdmin = ga --Java style
    GlObAlAdMiN = ga --xxx asked :D
    globalAdmin = ga --C style
    globaladmin = ga --other plain lua style

    Долго не могли решить как назвать глобальную таблицу в lua... лучшего решения не нашли.

    Alexsey, 10 Сентября 2010

    Комментарии (61)
  6. Assembler / Говнокод #3179

    +217

    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
    mov ebx, [sKey]
                                  mov ecx, 31
    
                                  l9:
                                  ;----------loop------------
                                  	fprem
    	                        shr ebx,1
                                  	jnc if9
    			.......
                                  	if9:
                                  	fmul st0,st0
                                  ;----------loop------------              
                                  loop l9

    реабилитируюсь за пост несвежего, но смешного говна немного раньше

    3.14159265, 07 Мая 2010

    Комментарии (61)
  7. JavaScript / Говнокод #2007

    +144.9

    1. 1
    <a href="javascript:void(0)" onclick="this.parentNode.submit(); return false;">Добавить</a>

    в ответ на http://govnokod.ru/1994 и длинный флуд в коментах.
    говнокод или нормально?

    tinimi, 20 Октября 2009

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

    −8

    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
    class C
    {
    	val: number;
    
    	constructor()
    	{
    		this.val = 2;
    	}
    }
    
    function o(val? : C)
    {
    	print(val?.val);
    }
    
    function main()
    {
    	o(new C());
    	o(null);
    	o();
    }

    Новый говнокод подоспел.... а как тебе такое слабый ужасный С/C++ ... ты так умеешь?

    Результат работы:

    C:\temp>C:\dev\TypeScriptCompiler\__build\tsc\bin\tsc.exe --emit=jit --opt --shared-libs=C:\dev\TypeScriptCompiler\__build\tsc\bin\TypeScriptRuntime.dll C:\temp\1.ts
    2
    0
    0

    ASD_77, 20 Декабря 2021

    Комментарии (60)
  9. Си / Говнокод #27266

    +3

    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
    // https://deadlockempire.github.io/
    // Игра, где надо играть за планировщик чтоб вызвать дедлок
    
    // https://deadlockempire.github.io/#2-flags
    
    // First Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }
    
    // Second Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }

    The day finally came. The Deadlock Empire opened its gates and from them surged massive amounts of soldiers, loyal servants of the evil Parallel Wizard. The Wizard has many strengths - his armies are fast, and he can do a lot of stuff that we can't. But now he set out to conquer the world, and we cannot have that.

    You are our best Scheduler, commander! We have fewer troops and simpler ones, so we will need your help. Already two armies of the Deadlock Empire are approaching our border keeps. They are poorly equipped and poorly trained, however. You might be able to desync them and break their morale.

    j123123, 20 Февраля 2021

    Комментарии (60)
  10. C++ / Говнокод #26341

    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
    t = rx + (ry * 100);
    std::vector<std::string> tmap;
    coin = 0;
    rcol = 0;
    roomname = "Untitled room ["+UtilityClass::String(rx) + "," + UtilityClass::String(ry)+"]";
    
    switch(t)
    {
    
    case rn(50,50):
    
        tmap.push_back("283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,284,444,444,444,444,444,444,444,444,444,285,283,284,444,444,444,444,444,444,444,444,444,444,444,444,285,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,363,364,365,0,0,0,403,283,405,0,0,0,363,364,365,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,403,283,405,0,0,0,443,444,445,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("444,444,444,444,444,444,285,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,403,283,324,364,364,364,364,364,364,364,364,364,325,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,403,283,283,283,283,283,283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,443,444,444,444,444,444,444,444,444,444,444,444,285,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("364,364,365,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,403,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,403,283,324,364,364,364,364,364,364,364,364,364,364,364,365,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,403,283,283,283,283,283,283,283,283,283,283,283,283,283,405,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,443,444,444,444,444,444,444,444,444,444,444,444,444,444,445,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,403,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,324,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,325,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
        tmap.push_back("283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,405,0,0,0,0,0,0,403,283,283,283,283,283,283");
    
        obj.createentity(game, 232, 24, 10, 0, 250500);  // (savepoint)
    
        if(game.intimetrial)
        {
            obj.createblock(0, 0, 0, 8, 240);
        }
    
        rcol=1;
        roomname = "Get Ready To Bounce";
        break;

    Именно поэтому я за «std::embed».
    https://github.com/TerryCavanagh/VVVVVV/blob/master/desktop_version/src/Labclass.cpp

    gost, 11 Января 2020

    Комментарии (60)
  11. PHP / Говнокод #25570

    +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
    <?php
        define('_SECUR_GAMES', 1);
        $rootpath = '../';
        require_once '../includes/start.php';
        require_once '../includes/function.php';
        require_once '../includes/header.php';
    if($level >0 AND $fr_id!=0)
    {
    $header='alliance';
    mysql_query("UPDATE `mesto` SET `place` = '".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($header)))))))."' WHERE `uid`=".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."");
    }
    $fr=check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($_GET['f'])))))));
    $q = mysql_query("SELECT * FROM `fractions` WHERE `id`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($fr)))))))."'");
    $f = mysql_fetch_array($q);
    $ucount = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."';"), 0);
    $fadm = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."' AND `adm`=1;"), 0);
        if($game==0 OR $level==0 OR $ban==1){
               echo "<title>Доступ закрыт!!!</title>";

    @since 2019

    eskrano, 25 Апреля 2019

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