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

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

    +141

    1. 1
    #define ass assert (false)

    ...

    XAKEP, 22 Апреля 2010

    Комментарии (23)
  3. SQL / Говнокод #3032

    −131.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
    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
    SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER 
    JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = 
    ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and 
    ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table 
    AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS 
    rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE 
    '002%' and ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM 
    com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN 
    payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id 
    WHERE ct.tax_id LIKE '001%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, 
    rt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id 
    LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = 
    ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, 
    ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = 
    ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt 
    ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '2' UNION SELECT ct.com_id, 
    cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS 
    cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN 
    tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '2' UNION SELECT 
    ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN 
    com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id 
    LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '3' 
    UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table AS ct LEFT 
    OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = 
    ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and 
    ct.com_id = '3';

    Не помню, что именно. Вырыл в старом логе. К сожалению из-за местных ограничений по длине кода не удалось выложить подобные портянки длинной в 10 тыщ символов.

    Washington, 17 Апреля 2010

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

    +115.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
    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
    class TReadWrapper<TItemType>
        {
    		public static object item(string ItemString)
            {
    			if (typeof(TItemType) == typeof(double))
    				return Convert.ToDouble(ItemString);
                TDbg.Assert(false);
                return null;
            }
        };
    
        class TRead<TItemType>
        {
    		public static TItemType item(StreamReader BinaryStream)
            {
    			string ItemString = BinaryStream.ReadLine();
    			if (ItemString == null)
    				throw new Exception();
    			return (TItemType)TReadWrapper<TItemType>.item(ItemString);
            }
        };
    
    	class TFileToList<TListItem> : List<TListItem>
        {
            public TFileToList(string FileName)
            {
    			if(typeof(TListItem)==typeof(char))
    			{
    				StreamReader file = new StreamReader(FileName, Encoding.Unicode);
    				string FileData = file.ReadToEnd();
    				foreach (char item in FileData)
    					this.Add((TListItem)(object)item);
    				file.Close();
    				return;
    			};
    
    			StreamReader fileSource = new StreamReader(FileName, Encoding.Unicode);
    			try
                {
    				for (;;)
    					this.Add(TRead<TListItem>.item(fileSource));
    			}
    			catch
    			{
    			};
    			fileSource.Close();
            }
        }
    
        class TListToFile<TListItem>
        {
            static public void rewrite(string NameOfDestinationFile, List<TListItem> Source)
            {
    			if(typeof(TListItem)==typeof(char))
    			{
    				StreamWriter file = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
    				foreach (TListItem item in Source)
    					file.Write(item);
    				file.Flush();
    				file.Close();
    				return;
    			};
    
    			StreamWriter fileDestination = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
    			foreach (TListItem item in Source)
    				fileDestination.WriteLine(Convert.ToString(item));
    			fileDestination.Flush();
    			fileDestination.Close();
            }
        }

    Говногость, 11 Апреля 2010

    Комментарии (23)
  5. Pascal / Говнокод #2972

    +110

    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
    Function IsBigLet(Let: String): Boolean;
    var r: bool;
    begin
    r:=false;
    if pos('Й',Let)>0 then r:=true;
    if pos('Ц',Let)>0 then r:=true;
    if pos('У',Let)>0 then r:=true;
    if pos('К',Let)>0 then r:=true;
    if pos('Е',Let)>0 then r:=true;
    if pos('Н',Let)>0 then r:=true;
    if pos('Г',Let)>0 then r:=true;
    if pos('Ш',Let)>0 then r:=true;
    if pos('Щ',Let)>0 then r:=true;
    if pos('З',Let)>0 then r:=true;
    if pos('Х',Let)>0 then r:=true;
    if pos('Ф',Let)>0 then r:=true;
    if pos('Ы',Let)>0 then r:=true;
    if pos('В',Let)>0 then r:=true;
    if pos('А',Let)>0 then r:=true;
    if pos('П',Let)>0 then r:=true;
    if pos('Р',Let)>0 then r:=true;
    if pos('О',Let)>0 then r:=true;
    if pos('Л',Let)>0 then r:=true;
    if pos('Д',Let)>0 then r:=true;
    if pos('Ж',Let)>0 then r:=true;
    if pos('Э',Let)>0 then r:=true;
    if pos('Я',Let)>0 then r:=true;
    if pos('Ч',Let)>0 then r:=true;
    if pos('С',Let)>0 then r:=true;
    if pos('М',Let)>0 then r:=true;
    if pos('И',Let)>0 then r:=true;
    if pos('Т',Let)>0 then r:=true;
    if pos('Б',Let)>0 then r:=true;
    if pos('Ю',Let)>0 then r:=true;
    Result:=r;
    end;

    Немножко индусского кода!

    Temnenkov, 09 Апреля 2010

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

    +186.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $AmountOfChairs=0;
    foreach($faculty['Chair'] as $currChair)
    {
        $AmountOfChairs++;
    }
    echo $AmountOfChairs;

    Shiz89, 07 Апреля 2010

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

    +162.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
    <?php 
       function db_connect($host, $user, $pass, $db) {
           global $glink;
           $glink = mysql_connect($host, $user, $pass) or db_give_error(3, '', db_error($glink));
            mysql_select_db($db, $glink) or db_give_error(4, '', db_error($glink));
    		mysql_query("SET CHARSET cp1251",$glink);
           return $glink;
       }
       
       function db_query($sql, $log = 0) {
           global $glink;
           $res = mysql_query($sql, $glink) or db_give_error(5, $sql, db_error($glink));
           return $res;
       }
                
       function db_fetch_row($res) {
           $row = empty($res) ? false : mysql_fetch_row($res);
           return $row;
       }
       
       function db_num_rows($res, $stmt = '') {
           $rows = mysql_num_rows($res); 
           if (null === $rows) db_give_error(6, '', db_error($glink));
           return $rows;
       }
      
       function db_num_fields($res, $stmt = '') {
           $fields = empty($res) ? false : mysql_num_fields($res);
           if (null === $fields) db_give_error(7, '', db_error($glink));
           return $fields;
       }
        
       function db_field_name($res, $fld) {
           $name = (empty($res) or !isset($fld)) ? false : mysql_field_name($res, $fld);
           if (false === $name) db_give_error(8, '', db_error($glink));
           return $name;
       }
       
       function db_affected_rows($res) {
           global $glink;
           $rows = mysql_affected_rows($glink); 
           if (null === $rows) db_give_error(9, '', db_error($glink));
           return $rows;
       }
    
       function db_insert_id($id = 0) {
           $id = mysql_insert_id();
           return ($id) ? $id : 1;
       }
       
       function db_next_id($table, $field, $seqname = 'seq') {
           return 0;
       }
       
       function db_errno($res) {
           return mysql_errno($res);
       }
       
       function db_error($res) {
           return mysql_error();
       }
       
       function db_free_result($res) {
           $res = mysql_free_result($res);
           return $res;
       }
    ?>

    Все из того же проекта (http://govnokod.ru/2929). авторам видимо надоело писать mysql_ и они решили сделать свой аналог db_. При чем смысла от этого полный NULL. Говнокод, он и в Африке говнокод

    MoLe-X, 05 Апреля 2010

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

    +163.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
    if($id>542)
           {        
             echo '<img Name="altimg" src="'.$foto.'" border=0>';
           }
           else
           {
           	 $size = getimagesize ($foto);
            if($size['0']>=500 ? $w=500:$w=$size['0']);
            if($size['1']>=500 ? $h=500:$h=$size['1']);
            
            echo '<img Name="altimg" src="'.$foto.'" width="'.$w.'" height="'.$h.'" border=0>';
           }

    вот что значит запускать бета верси говноскрипта в действие. Не продумав изначально что не плохо бы изменять размеры изображения при заливке пришлось вот так говнокодить.

    GoodTalkBot, 26 Марта 2010

    Комментарии (23)
  9. C++ / Говнокод #2802

    +55.4

    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
    #include <math.h>
    #include <assert.h>
    #include "vector10d.h"
     
    float vcompare_epsilon10d = 0.0005f;
     
    ml inlined float v10d_getElement(vec10d *v, int index)
    {
        assert( v != 0);
        assert( index >= 0 );
        assert( index <  3 );
        return (* ((&((v)->x)) +  (index) ));
    }
    ml inlined bool v10d_isValid(const vec10d *v)
    {
        if(v == 0) return g_false;
        if((v->x * v->x) < 0.0f)return g_false;
        if((v->y * v->y) < 0.0f)return g_false;
        if((v->z * v->z) < 0.0f)return g_false;
        if((v->w * v->w) < 0.0f)return g_false;
        if((v->m * v->m) < 0.0f)return g_false;
        if((v->n * v->n) < 0.0f)return g_false;
        if((v->o * v->o) < 0.0f)return g_false;
        if((v->p * v->p) < 0.0f)return g_false;
        if((v->r * v->r) < 0.0f)return g_false;
        if((v->s * v->s) < 0.0f)return g_false;
        return g_true;
    }
    ml inlined void v10d_set(vec10d *v, float x, float y, float z, float w, float m,
               float n, float o, float p, float r, float s)
    {
        assert(v = 0);
        v->x=x;
        v->y=y;
        v->z=z;
        v->w=w;
        v->m=m;
        v->n=n;
        v->o=o;
        v->p=p;
        v->r=r;
        v->s=s;
        assert( v10d_isValid(v) != g_false );
    }
    ml inlined void v10d_get(const vec10d *v, float *x, float *y, float *z, float *w,
         float *m, float *n, float *o, float *p, float *r, float *s)
    {
        assert ( v != 0 );
        assert ( x != 0 );
        assert ( y != 0 );
        assert ( z != 0 );
        assert ( w != 0 );
        assert ( m != 0 );
        assert ( n != 0 );
        assert ( o != 0 );
        assert ( p != 0 );
        assert ( r != 0 );
        assert ( s != 0 );
        assert( v10d_isValid(v) != g_false );
     
        *x = v->x;
        *y = v->y;
        *z = v->z;
        *w = v->w;
        *m = v->m;
        *n = v->n;
        *o = v->o;
        *p = v->p;
        *r = v->r;
        *s = v->s;
    }

    Сие чудо нарыл на просторах интернетов. Для ценителей весь исходник http://pastebin.org/114060 .. Очевидно чуваки писали очередной Crysis :)

    Valor, 16 Марта 2010

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

    +62.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #define DOIT(why, doit) !(why) || ((doit), (why))
    ...
    STDMETHODIMP CSimpleCtrl::SetObjectRects(LPCRECT prcPos,LPCRECT prcClip)
    {
        DOIT(prcPos, ATLTRACE(_T("t: %d | l: %d | b: %d | r: %d"),
            prcPos->top, prcPos->left, prcPos->bottom, prcPos->right));
    
        return IOleInPlaceObject_SetObjectRects(prcPos, prcClip);
    }

    gg_, 11 Марта 2010

    Комментарии (23)
  11. Java / Говнокод #2760

    +72.6

    1. 1
    2. 2
    3. 3
    4. 4
    Object[] o = new Object[16];
    for (int i = 0; i < 20; i++) {
        o[i] = "";
    }

    Korwin, 11 Марта 2010

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