1. PHP / Говнокод #8147

    +163

    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
    switch(true) {
                case ((0x7F & $bytes) == $bytes):
                    // this case should never be reached, because we are in ASCII range
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0x7F & $bytes);
    
                case (0x07FF & $bytes) == $bytes:
                    // return a 2-byte UTF-8 character
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0xC0 | (($bytes >> 6) & 0x1F))
                         . chr(0x80 | ($bytes & 0x3F));
    
                case (0xFFFF & $bytes) == $bytes:
                    // return a 3-byte UTF-8 character
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0xE0 | (($bytes >> 12) & 0x0F))
                         . chr(0x80 | (($bytes >> 6) & 0x3F))
                         . chr(0x80 | ($bytes & 0x3F));
            }

    В одной из реализаций JSON.php

    * @package Services_JSON
    * @author Michal Migurski <[email protected]>
    * @author Matt Knapp <mdknapp[at]gmail[dot]com>
    * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
    * @copyright 2005 Michal Migurski
    * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
    * @license http://www.opensource.org/licenses/bsd-license.php
    * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198

    lobovkin, 10 Октября 2011

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

    +160

    1. 1
    2. 2
    http://habrahabr.ru/blogs/about_cms/130082/
    facepalm.png

    dlemaser (aka WebKill), хабр ниторт^Wговно

    DrFreez, 10 Октября 2011

    Комментарии (64)
  3. Куча / Говнокод #8145

    +128

    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
    <style type="text/css">
    <!--
    body,html {
    	margin-left: 0px;
    	margin-top: 0px;
    	margin-right: 0px;
    	margin-bottom: 0px;
    	padding: 0px;
    }
    -->
    </style>
    
    <body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">

    Source: http://www.letsturnthisfuckingwebsiteyellow.com/

    cephuo, 10 Октября 2011

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

    +162

    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
    $sql = "SELECT aps.* FROM apps_applicationinterfaceincoming aps
    WHERE aps.applicationid = '$id' ORDER BY aps.name ASC";
                           $Result = $Database->query( $sql );
                           foreach( $Result as $aResult )
                           {
                                   $editIcon = Common_Image_Icon_Overlay::fetchIcon(
    Common_Image_Icon_Overlay::EDIT, _('Edit interface' ),
    '/apps/serveroverlay.php?table=apps_applicationinterfaceincoming&edit=1&mode='.AppsEnvironment::iVIEWMODE_EDIT.'&id='.$aResult['id']
    );
                                   $deleteIcon = Common_Image_Icon_Ajax::fetch(
    Common_Image_Icon_Ajax::DELETE, array( 'aLinkAttributes' => array(
    'onclick' => "new Browser.Http.Ajax.Updater( '#interfacein',
    '/apps/interfacein_ajax.php?action=remove&id={$aResult['id']}' );" ) )
    );
                                   $html .= <<<EOF
                                                   <tr>
                                                           <td>{$aResult['name']}</td>
                                                           <td>{$aResult['frequency_data_transfers']}</td>
                                                           <td>{$aResult['type_of_interface']}</td>
                                                           <td>{$aResult['internal_external']}</td>
                                                           <td>{$aResult['description']}</td>
                                                           <td class="actions">{$editIcon} {$deleteIcon}</td>
                                                   </tr>
    EOF;
                           }
                           $html .= <<<EOF
                                           </tbody>
                                   </table>
                           </fieldset>
    EOF;

    PHP Bestpractice php + sql + html + js in one file
    или даэже in one String.

    ... 800 строк в том же духе. (толко в етом файле)

    andrejlr, 10 Октября 2011

    Комментарии (16)
  5. Java / Говнокод #8143

    +126

    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
    //javax.swing.JTree
                public void setBounds(Rectangle r) {
                    AccessibleContext ac = getCurrentAccessibleContext();
                    if (ac instanceof AccessibleComponent) {
                        ((AccessibleComponent) ac).setBounds(r);
                    } else {
                        Component c = getCurrentComponent();
                        if (c != null) {
                            c.setBounds(r);
                        }
                    }
                }
            
                public void setSize (Dimension d) {
                    AccessibleContext ac = getCurrentAccessibleContext();
                    if (ac instanceof AccessibleComponent) {
                        ((AccessibleComponent) ac).setSize(d);
                    } else {
                        Component c = getCurrentComponent();
                        if (c != null) {
                            c.setSize(d);
                        }
                    }
                }  
        
    
                public void requestFocus() {
                    AccessibleContext ac = getCurrentAccessibleContext();
                    if (ac instanceof AccessibleComponent) {
                        ((AccessibleComponent) ac).requestFocus();
                    } else {
                        Component c = getCurrentComponent();
                        if (c != null) {
                            c.requestFocus();
                        }
                    }
                }
        
                public void addFocusListener(FocusListener l) {
                    AccessibleContext ac = getCurrentAccessibleContext();
                    if (ac instanceof AccessibleComponent) {
                        ((AccessibleComponent) ac).addFocusListener(l);
                    } else {
                        Component c = getCurrentComponent();
                        if (c != null) {
                            c.addFocusListener(l);
                        }
                    }
                }
                public boolean isFocusTraversable() {
                    AccessibleContext ac = getCurrentAccessibleContext();
                    if (ac instanceof AccessibleComponent) {
                        return ((AccessibleComponent) ac).isFocusTraversable();
                    } else {
                        Component c = getCurrentComponent();
                        if (c != null) {
                            return c.isFocusTraversable();
                        } else {
                            return false;
                        }
                    }
                }

    3.14159265, 10 Октября 2011

    Комментарии (50)
  6. Java / Говнокод #8142

    +77

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public static void main(final String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
        try {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          JFrame.setDefaultLookAndFeelDecorated(false);
          JDialog.setDefaultLookAndFeelDecorated(false);
        } finally {
          new ImageMaps().start();
        }
      }

    НАКОНЕЦ запускаю десктоп-приложение.
    Не знаю как вам, а по мне - выглядит весьма странно.

    Lure Of Chaos, 10 Октября 2011

    Комментарии (153)
  7. Pascal / Говнокод #8141

    +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
    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
    unit uIsPalindrome; 
      
    interface
      
    function IsPalindrome(const aString: string): Boolean; 
      
    implementation
      
    uses
           Spring.Collections 
         , {$IF CompilerVersion >= 230}System.{$IFEND}SysUtils 
         ; 
      
    function CleanString(const aString: string): string; 
    var
      C: char; 
    begin
      // Remove all non-alpha chars and make all lower case 
      // Spaces don't matter, so let's count only letters 
      Result := ''; 
      for C in LowerCase(aString) do
      begin
        if CharInSet(C, ['a'..'z', 'A'..'Z']) then
        begin
          Result := Result + C; 
        end; 
      end; 
    end; 
      
    function IsPalindrome(const aString: string): Boolean; 
    var
      Stack: IStack<Char>; 
      C: Char; 
      NoSpaces: string; 
      Temp: string; 
    begin
      NoSpaces :=  CleanString(aString); 
      
      Stack := TCollections.CreateStack<Char>; 
      for C in NoSpaces do
      begin
        Stack.Push(C); 
      end; 
      Temp := ''; 
      repeat
        Temp := Temp + Stack.Pop; 
      until Stack.Count = 0; 
      Result := Temp = NoSpaces; 
    end; 
      
    end.

    true java style...

    d_dev, 10 Октября 2011

    Комментарии (31)
  8. PHP / Говнокод #8140

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //...
    include_once("includes/global.php");
    //check_license("license/license.zl");
    db_connection();
    //...

    jokz, 10 Октября 2011

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $login='55526723433';
    for($n=0; $n!=strlen($login)-2; $n++)
    {
    	if( $login[$n] == $login[$n+1] && $login[$n] == $login[$n+2] )
    	{
    		echo 'есть повторение';
    		exit;
    	}
    }

    снова на ваш суд))

    суть проблемы: проверка содержания строки, есть ли более двух одинаковых символов.

    beetle, 09 Октября 2011

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

    +160

    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
    class array
    {
        int data[256];
        int p;
    
    public:
        array ():
            p (0)
        {}
    
        array & operator , (int a)
        {
            data[p++] = a;
            return *this;
        }
    
        array & operator = (const array & arr)
        {
            p = 0;
            memcpy (data, arr.data, sizeof (data));
            return *this;
        }
    
        int & operator [] (size_t i)
        {
            return data[i];
        }
    };
    
    #define _I array(),
    #define I_
    #define o_O ,
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        array arr;
        arr = _I 1,2,3,4,5,6 I_;    // init
        arr o_O 7,8,9,10;           // append new
        arr o_O 11 o_O 12;          // append new
    }

    http://www.gamedev.ru/flame/forum/?id=153265#m4

    RS-232, 09 Октября 2011

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