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

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ((!IsForum() && $url[0] != 'underwater-video' && $end_element !='diveclan' && $end_element !='partners') || ($url[0] != 'underwater-photo' && sizeof($url)==1))
            if ($url[0]!='atlas-uw-photo' && !empty($title) && $end_element!='diving-guide' && $end_element!='atlas-wrecks' && $end_element!='atlas-deep'  && $end_element!='atlas-caves' && $end_element!='sea-inhabitants')
                    if ($APPLICATION->GetCurPage()!='/underwater-video/mygallery.php' && $APPLICATION->GetCurPage()!='/underwater-video/add.php' && $APPLICATION->GetCurPage()!='/atlas_update/travel_add/index.php')
                            if ($url[0] != 'diving-media' && $url[0] != 'underwater-photo')
                                    $APPLICATION->SetTitle($title);

    Унифицированный костыль тайтлов на битриксе. Это лежит во вкл области, которая цепояется после </html>

    atarix12, 16 Августа 2011

    Комментарии (52)
  2. ActionScript / Говнокод #7552

    −117

    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
    // Здесь примерно еще примерно 50 условий
    
    if (event.keyCode == 188)
     	{
       my_answer[pos_text] = "Б";
       pos_text = pos_text + 1;
    
     	}
    
     	if (event.keyCode == 190)
     	{
       my_answer[pos_text] = "Ю";
       pos_text = pos_text + 1;
    
     	}

    Маленький кусочек говнокода..

    KirAmp, 16 Августа 2011

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

    +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
    //отбор произвольного совета
    $query = "SELECT * FROM sovet_faraon";
    $result = mysql_query($query) or die ("Не могу выбрать данные из таблицы");
    
    $number = 0;
    while ($row = mysql_fetch_array($result)) {
        $number++;
    }
    
    //выбираем число случайным образом
    $uniq_id = rand(1, $number++);
    
    
    //выбираем этот совет по номеру
    $query = "select * from sovet_faraon where (id_sovet='$uniq_id')";
    $result = mysql_query($query) or die("Не могу выбрать значение из базы советов");
    
    while ($row = mysql_fetch_array($result)) {
        $id_sovet = $row["id_sovet"];
        $small_sovet = $row["small_sovet"];
        $big_sovet = $row["big_sovet"];
    }
    
    echo "<a href=\"list_sovet.php\" class=\"ssilka2\">" . $small_sovet . "</a>";

    Отбор произвольного совета мля... Один совет такому "программисту" дать хочется: "убейся ап стену!!!" xD
    Шучу конечно, сам наверное лет в 5 так бы написал xD

    code_master, 16 Августа 2011

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

    +184

    1. 1
    enum Bool {True = 0, False = (!True)};

    Автор: Константин с trinity-core.ru

    chaoswithin, 15 Августа 2011

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

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    int[] indexes = list.getSelectedIndices();
            if (indexes.length == 0) {
                indexes = getAllIndexes();
            }
            if (indexes.length == 0) {
                return false;
            }

    индуссы атакуют

    Dexter, 15 Августа 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // convert ',' to '.'
    public static function ConvertDecimal($num) {
    	$num = preg_replace('/,/i', '.', $num);
    	//check if is number after convertion
    	if (is_numeric($num))
    		return $num;
    	return false;
    }

    у автора было суровое детство

    cephuo, 15 Августа 2011

    Комментарии (53)
  7. Java / Говнокод #7547

    +76

    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
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    class PseudoVamp {
    	public int num;
    	public boolean truevamp = false;
    	public int x;
    	public int y;
    	public int n1;
    	public int n2;
    	public int n3;
    	public int n4;
    
    	void breaknsort() {
    		n1 = num % 10;
    		n2 = num / 10 % 10;
    		n3 = num / 100 % 10;
    		n4 = num / 1000;
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (n1 > n2) {
    				tmp = n1;
    				n1 = n2;
    				n2 = tmp;
    			}
    
    			if (n2 > n3) {
    				tmp = n2;
    				n2 = n3;
    				n3 = tmp;
    			}
    
    			if (n3 > n4) {
    				tmp = n3;
    				n3 = n4;
    				n4 = tmp;
    			}
    		}
    	}
    
    	public PseudoVamp(int a, int b) {
    		x = a;
    		y = b;
    		num = x * y;
    		breaknsort();
    	}
    }
    
    public class Test {
    
    	static void checkvamp(PseudoVamp vamp) {
    		int x1 = vamp.x % 10;
    		int x2 = vamp.x / 10;
    
    		int y1 = vamp.y % 10;
    		int y2 = vamp.y / 10;
    
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (x1 > x2) {
    				tmp = x1;
    				x1 = x2;
    				x2 = tmp;
    			}
    
    			if (x2 > y1) {
    				tmp = x2;
    				x2 = y1;
    				y1 = tmp;
    			}
    
    			if (y1 > y2) {
    				tmp = y1;
    				y1 = y2;
    				y2 = tmp;
    			}
    		}
    		if (vamp.n1 == x1 && vamp.n2 == x2 && vamp.n3 == y1 && vamp.n4 == y2)
    			vamp.truevamp = true;
    	}
    
    	public static void main(String[] args) {
    		for (int i = 11; i < 100; i++) {
    			for (int j = 11; j < 100; j++) {
    				PseudoVamp v = new PseudoVamp(i, j);
    				if (v.num < 1000)
    					continue;
    				if (v.num > 9999)
    					return;
    				checkvamp(v);
    				if (v.truevamp)
    				System.out.println(v.x + " * " + v.y + " = " + v.num);
    			}
    		}
    	}
    }

    A vampire number has an even number of digits and is formed by multiplying a pair of numbers containing half the number of digits of the result. The digits are taken from the original number in any order. Pairs of trailing zeroes are not allowed. Examples include:
    1260 = 21 * 60
    1827 = 21 * 87
    2187 = 27 * 81
    Write a program that finds all the 4-digit vampire numbers.
    w/o using of arrays.

    ch0sen, 15 Августа 2011

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

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    char *reg = data;
    char *temp = "blahblah is ";
    
    strcat(temp,(const char*)"reg[4]");

    Как оказывается на Си можно конкатенировать строки

    Kortez, 15 Августа 2011

    Комментарии (8)
  9. Python / Говнокод #7545

    −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
    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
    #weather.pyw
    
    from urllib import request
    from tkinter import *
    import tkinter
    import threading
    from threading import *
    import time
    
    i = 0
    active = True
    
    def timerTick( toSleep ):
      global active
      while active:
        refreshCall(0)
        time.sleep(toSleep)
    
    
    def refreshCall(event):
      t = Thread(target = refresh)
      t.start()
    
    def refresh(*event):
      global i
      ref['text'] = str(i)
      i+=1
      r = request
      page = str(r.urlopen('http://realmeteo.ru/moscow/1/current/').read())
      temperature = page.split('</tr><tr id="num_data"><td>')[1].split(' ')[0]
      pressure = page.split('                    </td><td>')[1].split(' ')[0]
      wind = page.split('<tr id="num_data"><td></td><td>')[1].split(' ')[0]
      dest = page.split('<param name="movie" value="/.swf/wind_dir/')[1].split('.swf')[0]
      destination = ''
      for c in dest:
        if c is dest[-1]:
          destination += {'N':'Север','S':'Юг','W':'Запад','E':'Восток'}[c]
        else:
          destination += {'N':'Северо-','S':'Юго-','W':'Западо-','E':'Востоко-'}[c]
      #print( temperature, pressure, wind, destination )
      l1['text'] = 'Температура: '+temperature
      l2['text'] = 'Давление   : '+pressure
      l3['text'] = 'Сила ветра : '+wind
      l4['text'] = 'Направление: '+destination
    
    r = request
    page = str(r.urlopen('http://realmeteo.ru/moscow/1/current/').read())
    temperature = page.split('</tr><tr id="num_data"><td>')[1].split(' ')[0]
    pressure = page.split('                    </td><td>')[1].split(' ')[0]
    wind = page.split('<tr id="num_data"><td></td><td>')[1].split(' ')[0]
    dest = page.split('<param name="movie" value="/.swf/wind_dir/')[1].split('.swf')[0]
    destination = ''
    for c in dest:
      if c is dest[-1]:
        destination += {'N':'Север','S':'Юг','W':'Запад','E':'Восток'}[c]
      else:
        destination += {'N':'Северо-','S':'Юго-','W':'Западо-','E':'Востоко-'}[c]
    
    
    form = tkinter.Tk()
    l1 = Label(form,text='Температура: '+temperature,justify='left'); l1.pack()
    l2 = Label(form,text='Давление   : '+pressure,justify='left'); l2.pack()
    l3 = Label(form,text='Сила ветра : '+wind,justify='left'); l3.pack()
    l4 = Label(form,text='Направление: '+destination,justify='left'); l4.pack()
    ref = Button(form, text = 'Обновить'); ref.pack()
    
    ref.bind('<Button-1>',refreshCall)
    
    timerThread = Thread(target = timerTick, args=(5,))
    
    timerThread.start()
    
    form.mainloop()
    
    active = False

    Угадайте, с какого языка пересел автор. (не пэхапэ)

    Fai, 15 Августа 2011

    Комментарии (33)
  10. Python / Говнокод #7544

    −99

    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
    # разбираюсь с питоном, может растолкуете почему так
    >>> z = [lambda: i for i in [1,2,3]]
    # почему вот такой результат?
    >>> z[0](), z[1](), z[2]()
    (3, 3, 3) 
    
    # каждый элемент списка - отдельная функция
    >>> z[0] == z[1], z[0] is z[1]
    (False, False)
    
    # вот таким образом выходит правильно.
    >>> z = [lambda: 1, lambda: 2, lambda:3]
    >>> z[0](), z[1](), z[2]()
    (1, 2, 3)

    Автор - я. Меня действительно интересует, почему так происходит.

    Fai, 14 Августа 2011

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