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

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

    +155

    1. 1
    2. 2
    3. 3
    if (!"list".equals(message.getString("response"))) {
        throw new IOException("Expected list response but got: " + message.toString());
    }

    принятие ответа от сервера

    guest, 20 Февраля 2009

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

    +155

    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
    void SimpleTest::testTrivial() {
        wxTst::TempInteractive interactive;
        wxTst::ModalDialogTimer timer(wxID_OK);
       // *** Loop up top level containers ***
        CPPUNIT_ASSERT_MESSAGE ("Application top window invalid", 
    			    wxTheApp->GetTopWindow () != NULL);
        wxMDIParentFrame *topFrame = 
    	dynamic_cast< wxMDIParentFrame * >(wxTheApp->GetTopWindow ());
        CPPUNIT_ASSERT_MESSAGE ("Top window is not an MDI Parent frame", 
    			    topFrame != NULL);
        wxMenuBar *menuBar = topFrame->GetMenuBar ();
        CPPUNIT_ASSERT_MESSAGE ("Menubar not found", menuBar != NULL);
    
    //    interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
    
        // *** Check menu item ***
        int platformMenuItemId = menuBar->FindMenuItem (_("Advanced"), 
                MC _T("Platform Specific Example"));
        CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'platformMenuItem' not found",
                platformMenuItemId != wxNOT_FOUND);
        wxMenuItem *platformMenuItem = menuBar->FindItem (
                platformMenuItemId);
        CPPUNIT_ASSERT_MESSAGE ("Menu item 'platformMenuItem' not found",
                platformMenuItem != NULL);
        wxTst::EventSimulationHelper::SelectMenuItem (
                platformMenuItemId, topFrame);
        wxTst::WxGuiTestHelper::FlushEventQueue ();
        wxWindow* wdw = topFrame->FindWindow(_T("platform_child"));
        if (wdw == NULL)
    	wdw = wxWindow::FindWindowByName(_T("platform_child"));
        CPPUNIT_ASSERT_MESSAGE("First Child not found", wdw != NULL);
        wxMDIChildFrame* child1 = dynamic_cast<wxMDIChildFrame*>(wdw);
        CPPUNIT_ASSERT_MESSAGE("Window isn't an MDI Child", child1 != NULL);
        wxTst::WxGuiTestHelper::FlushEventQueue ();
        interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
    
        wxTst::EventSimulationHelper::SelectMenuItem (
                platformMenuItemId, topFrame);
        wxTst::WxGuiTestHelper::FlushEventQueue ();
    
    //    interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
    
        wxMDIChildFrame* child2 = topFrame->GetActiveChild();
        CPPUNIT_ASSERT_MESSAGE("Second child not found", child2 != NULL);
        CPPUNIT_ASSERT_MESSAGE("Second child same as first ", child2 != child1);
    
        child2->Close();
    
        int derived_toolMenuItemId = menuBar->FindMenuItem (_("Advanced"),
                MC _T("Custom Class Example"));
        CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'derived_toolMenuItem' not found",
                derived_toolMenuItemId != wxNOT_FOUND);
        wxMenuItem *derived_toolMenuItem = menuBar->FindItem (
                derived_toolMenuItemId);
        CPPUNIT_ASSERT_MESSAGE ("Menu item 'derived_toolMenuItem' not found",
                derived_toolMenuItem != NULL);
        wxTst::EventSimulationHelper::SelectMenuItem (
                derived_toolMenuItemId, topFrame);
        wxTst::WxGuiTestHelper::FlushEventQueue ();
    
         wxWindow *custom_child = 
    	 wxWindow::FindWindowByName (_T("custom_class_child"));
         CPPUNIT_ASSERT_MESSAGE ("Container window for button 'wxID_OK' not found", 
     			    custom_child != NULL);
    //    interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
        wxWindow *wxID_OKWdw4 = custom_child->FindWindow (XRCID("wxID_OK"));
        CPPUNIT_ASSERT_MESSAGE ("Window for button 'wxID_OK' not found", 
                wxID_OKWdw4 != NULL);
        wxTst::EventSimulationHelper::ClickButton (wxID_OKWdw4->GetId (), 
                wxID_OKWdw4);
        wxTst::WxGuiTestHelper::FlushEventQueue ();
        CPPUNIT_ASSERT_MESSAGE("OK Button didn't hide Mac Specific Dialog",
    			   custom_child->IsShown() == false);
    
    
    
    
    }

    Источник: метод примера из wxGuiTesting

    guest, 27 Января 2009

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

    +154.9

    1. 1
    2. 2
    $time_portions = explode(' ', microtime());
    $actual_time = $time_portions[1] . substr($time_portions[0], 1);

    microtime(true) было бы слишком просто

    shitcoder, 10 Сентября 2009

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

    +154.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $res = & $mdb2->query ( " SELECT * FROM manage WHERE parsed = 0 AND timestamp = DATE_FORMAT(now(), '%Y-%m-%d'); ");
    while ( $row = $res->fetchRow ()) {
    …
    try {
    …
    } catch (Exception $e) {
    …
    }
    if (empty($e)) $res = & $mdb2->query ( «UPDATE `user_control`.`manage` SET `parsed` = 1 WHERE `manage`.`ti_uid` ='».$row['ti_uid']."' LIMIT 1; ");
    }

    $res

    random2, 10 Августа 2009

    Комментарии (0)
  6. PHP / Говнокод #1506

    +154.9

    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
    $url = URL::uri('chatsW.php', $params);
    	$chatters_link=new HAW_link('chat rooms',	$url);
    	
    	$url = URL::uri('browseW.php', $params);
    	$people_link    =new HAW_link('people',			$url);
    
    	$url = URL::uri('recentW.php', $params);
    	$photos_link    =new HAW_link('photos',			$url);
    
    	$url = URL::uri('find_area_codeW.php', $params);
    	$find_by_areacode_link =new HAW_link('search by US area code', $url);
    
    	$url = URL::uri('inboxW.php', $params);
    	$messages_link  =new HAW_link('messages' . $message_count_text,	$url);
    	
    	$url = URL::uri('whatsnewW.php', $params);
    	$whatsnew_link  =new HAW_link('what\'s new',		$url);
    
    	$url = URL::uri('invites_mainW.php', $params);
    	$invites_link   =new HAW_link('invites' . $invite_count_text, $url);
    
    	$url = URL::uri('friendsW.php', $params);
    	$my_friends_link=new HAW_link('my friends',		$url);
    
    	$url = URL::uri('phone_bookW.php', $params);
    	$phone_book_link=new HAW_link('my phone book',		$url);
    
    	$url = URL::uri('chatterW.php', $params);
    	$my_chatter_link=new HAW_link('my chatter',		$url);
    
    	$url = URL::uri('my_profileW.php', $params);
    	$my_profile_link=new HAW_link('my profile',		$url);
    
    	$url = URL::uri('settingsW.php', $params);
    	$settings_link  =new HAW_link('settings',		$url);
    	
    	$url = URL::uri('logout.php', $params);
    	$logout_link=new HAW_link("log out", $url);
    	
    	$wapPage->add_link($people_link);
    	$wapPage->add_link($photos_link);
    	$wapPage->add_link($find_by_areacode_link);
    	$wapPage->add_link($chatters_link);
    	$wapPage->add_link($messages_link);
    	$wapPage->add_link($whatsnew_link);
    	$wapPage->add_link($invites_link);
    	$wapPage->add_link($my_friends_link);
    	$wapPage->add_link($phone_book_link);
    	$wapPage->add_link($my_chatter_link);
    	$wapPage->add_link($my_profile_link);
    	$wapPage->add_link($settings_link);
    	$wapPage->add_link($logout_link);

    e.lamskoy, 10 Августа 2009

    Комментарии (0)
  7. PHP / Говнокод #834

    +154.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function telefon_sotovyj($n) {
    $return[] = $n;
    $return[] = $n[0].$n[1].$n[2]." ".$n[3].$n[4].$n[5]." ".$n[6].$n[7].$n[8].$n[9];
    $return[] = $n[0].$n[1].$n[2]." ".$n[3].$n[4].$n[5]." ".$n[6].$n[7]." ".$n[8].$n[9];
    $return[] = $n[0].$n[1].$n[2]." ".$n[3].$n[4].$n[5].$n[6].$n[7].$n[8].$n[9];
    $return[] = "(".$n[0].$n[1].$n[2].")".$n[3].$n[4].$n[5]." ".$n[6].$n[7].$n[8].$n[9];
    $return[] = "(".$n[0].$n[1].$n[2].")".$n[3].$n[4].$n[5]." ".$n[6].$n[7]." ".$n[8].$n[9];
    $return[] = "(".$n[0].$n[1].$n[2].")".$n[3].$n[4].$n[5].$n[6].$n[7].$n[8].$n[9];
    $return[] = "8".$n;
    return $return;
    }

    http://community.livejournal.com/ru_php/1352884.html

    guest, 08 Апреля 2009

    Комментарии (0)
  8. Си / Говнокод #3057

    +154.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
    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
    #include <avr/interrupt.h>
    #include <avr/io.h>
    #include <stdio.h>
    
    static void avr_init(void);
    void uart_putchar(char value);
    unsigned char read_adc(unsigned char adc_input);
    
    unsigned char adc_enable;
    
    ISR(SIG_UART_RECV)
    {
    	unsigned char tmp;
    	tmp=UDR;
    	if (tmp=='1') adc_enable=1;
    	else adc_enable=0;
    }
    
    int main(void)
    {
    	avr_init();
      sei();
    	uart_putchar('A');
      for(;;)
      {
        if(adc_enable)
        {
          uart_putchar(read_adc(0x00));
          adc_enable = 0;
        }
      }
      return(0);
    }
    
    static void avr_init(void)
    {
      PORTB=0b00000000;
      DDRB=0b00001111;
    
      PORTD=0b00111100;
      DDRD=0b11000011;
    
      // Baud Rate: 57600
      // Character Size: 8-bit
      // Mode: Asynchronous
      // Parity: Disabled
      // Stop Bit: 1-bit
      // Multi-processor Communication
      UBRRL = 0x0c;
      UBRRH = 0x00;
      UCSRA = 0x01;
      UCSRC = 0x86;
      UCSRB = 0xd8;
    
      ADMUX=0x60;
      ADCSRA=0xA6;
      SFIOR&=0x0F;
      SFIOR|=0x10;
    
      return;
    }
    
    void uart_putchar(char value)
    {
      loop_until_bit_is_set(UCSRA, UDRE);
      UDR = value;
      return;
    }
    
    unsigned char read_adc(unsigned char adc_input)
    {
      ADMUX=adc_input|0x60;
      // Start the AD conversion
      ADCSRA|=0x40;
      // Wait for the AD conversion to complete
      while ((ADCSRA & 0x10)==0);
      ADCSRA|=0x10;
      return ADCH;
    }

    JovialLiX, 19 Апреля 2010

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

    +154.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    //Таблица для пароля администратора
    mysql_query("CREATE TABLE $admintable (
    ID SMALLINT UNSIGNED NOT NULL auto_increment,
    pass VARCHAR(30) NOT NULL,
    PRIMARY KEY(ID)
    )");
    
    mysql_query("INSERT INTO $admintable (pass) VALUES ('')");

    оригинальный способ хранения пароля администратора в системе nevius

    breathe, 15 Апреля 2010

    Комментарии (7)
  10. PHP / Говнокод #2329

    +154.8

    1. 1
    substr ("1111117495". ereg_replace ("[^0-9]", "", $user1->data["mobile_phone"]), -10) == substr ("1111117495". ereg_replace ("[^0-9]", "", $user2->data["mobile_phone"]), -10)

    Сравнение двух мобильных телефонов.

    IHateBidloKod, 24 Декабря 2009

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

    +154.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $srv_id=$_POST['srv_id'];
    $result = mysql_query("
    SELECT *
    FROM srv
    WHERE
    srv_id='$srv_id'");
    $data = mysql_fetch_array($result);
    // ...
    $srv_id=$data['srv_id'];

    marten.spb, 25 Ноября 2009

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