1. Java / Говнокод #12588

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public class Test {
        public static final int a;
        static {
            System.out.println(Main.a);
            a = 42;
            System.out.println(Main.a);
        }
    }

    javac такой javac...

    Так видит проблему: http://ideone.com/jhPN5X
    А вот так - нет: http://ideone.com/qAMIvH

    bormand, 14 Февраля 2013

    Комментарии (18)
  2. C++ / Говнокод #12587

    +24

    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
    template <typename IdType, class Tag>
    class id {
    public:
        typedef IdType value_type;
    
        explicit id(value_type val)
            : value(val)
        {}
    
        bool operator==(id rhs)
        {
            return rhs.value == value;
        }
    
        bool operator!=(id rhs)
        {
            return rhs.value != value;
        }
    
        value_type value;
    };
    
    #define HASKELL_NEWTYPE(type_name, value_type) struct __##type_name##_tag__ {}; \
        typedef ::id<value_type, __##type_name##_tag__> type_name

    Когда newtype нет, но очень хочется.
    http://ideone.com/VRu56j
    Простите за синтетику

    roman-kashitsyn, 14 Февраля 2013

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

    +138

    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
    $sql_ex = array();
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '5')
    	$sql_ex[] = " `ex`.`num` = 5 ";
    else
    	$sql_ex[] = " `ex`.`num` != 5 ";
    
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '7')
    	$sql_ex[] = " `ex`.`num` = 7 ";
    else
    	$sql_ex[] = " `ex`.`num` != 7 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '4')
    	$sql_ex[] = " `ex`.`num` = 4 ";
    else
    	$sql_ex[] = " `ex`.`num` != 4 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '10')
    	$sql_ex[] = " `ex`.`num` = 10 ";
    else
    	$sql_ex[] = " `ex`.`num` != 10 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '11')
    	$sql_ex[] = " `ex`.`num` = 11 ";
    else
    	$sql_ex[] = " `ex`.`num` != 11 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '14')
    	$sql_ex[] = " `ex`.`num` = 14 ";
    else
    	$sql_ex[] = " `ex`.`num` != 14 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '19')
    	$sql_ex[] = " `ex`.`num` = 19 ";
    else
    	$sql_ex[] = " `ex`.`num` != 19 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '20')
    	$sql_ex[] = " `ex`.`num` = 20 ";
    else
    	$sql_ex[] = " `ex`.`num` != 20 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '21')
    	$sql_ex[] = " `ex`.`num` = 21 ";
    else
    	$sql_ex[] = " `ex`.`num` != 21 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '13')
    	$sql_ex[] = " `ex`.`num` = 13 ";
    else
    	$sql_ex[] = " `ex`.`num` != 13 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '12')
    	$sql_ex[] = " `ex`.`num` = 12 ";
    else
    	$sql_ex[] = " `ex`.`num` != 12 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '6')
    	$sql_ex[] = " `ex`.`num` = 6 ";
    else
    	$sql_ex[] = " `ex`.`num` != 6 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '17')
    	$sql_ex[] = " `ex`.`num` = 17 ";
    else
    	$sql_ex[] = " `ex`.`num` != 17 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '23')
    	$sql_ex[] = " `ex`.`num` = 23 ";
    else
    	$sql_ex[] = " `ex`.`num` != 23 ";
    if(isset($this->request->get["id"]) && $this->request->get["id"] == '16')
    	$sql_ex[] = " `ex`.`num` = 16 ";
    else
    	$sql_ex[] = " `ex`.`num` != 16 ";
    $sql_extra = '';
    if (!empty($sql_ex)) $sql_extra = ' AND '.implode(" AND ", $sql_ex);

    В начале нужно было одно условие, потом еще и еще и ...

    gvncode, 14 Февраля 2013

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

    +9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    y=fopen(lex,"w+");
    fclose(y);
    FILE *r=fopen(result,"w+");
    fclose(r);
    FILE *k=fopen("pryklad.obj","w+");
    fclose(k);

    Abbath, 13 Февраля 2013

    Комментарии (11)
  5. Куча / Говнокод #12584

    +116

    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
    <style type="text/css">
    	header
    	{
    		display: block;
    	}
    
    	header
    	{
    		clear: both;
    		height: 160px;
    		width: 100%;
    		background: url(/images/imges.jpg) no-repeat;
    		-moz-background-size: 100%;
    		-webkit-background-size: 100%;
    		-o-background-size: 100%;
    		background-size: 100% 100%;
    		background-position: center center;
    
    	}
    	.block1
    	{
    		height: 160px;
    		width: 20%;
    	}
    	.block2
    	{
    		height: 160px;
    		width: 15%;
    	}
    	.block3
    	{
    		height: 160px;
    		width: 30%;
    	}
    	.block4
    	{
    		height: 160px;
    		width: 15%;
    	}
    	.block5
    	{
    		height: 160px;
    		width: 20%;
    	}
    	table
    	{
    		width: 100%;
    		border-collapse: collapse;
    		table-layout: fixed;
    	}
    
    </style>
    
    
    <header>
    	<table>
    		<tr>
    			<td class="block1" onClick="document.location='/' "  onmouseover ="this.style.cursor='pointer' " title= "Главная">
    			</td>
    			<td class="block2">
    			</td>
    			<td class="block3">
    			</td>
    			<td class="block4">
    			</td>
    			<td class="block5" onClick="document.location='/script/enter.php' " onmouseover ="this.style.cursor='pointer' " title= "Вход">
    			</td>
    		</tr>
    	</table>
    </header>

    Найдено на просторах интернета: обычная шапка сайта, ничего лишнего.
    Код был нечитаемым - форматировал я. CSS, касаемо использованных тегов, вся.

    superfood, 13 Февраля 2013

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

    +79

    1. 1
    2. 2
    3. 3
    public class StringToObjectMap extends HashMap<String, Object> {
    
        public StringToObjectMap(Map<? extends String, ? extends Object> map)

    Нет слов выразить мою печаль.

    nafania217518, 13 Февраля 2013

    Комментарии (41)
  7. Objective C / Говнокод #12582

    −88

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // поднимаем и опускаем панель голосования при входящем вызове
            for (ASSlideView* slideView in self.view.subviews)
                if ([slideView isKindOfClass:[ASSlideView class]])
                    for (UIScrollView* scroll in slideView.subviews)
                        if ([scroll isKindOfClass:[UIScrollView class]])
                            for (UIView* view in scroll.subviews)
                                if ([view isKindOfClass:[UIView class]])
                                    for (KVRateView* rateView in view.subviews)
                                        if ([rateView isKindOfClass:[KVRateView class]]){
                                            [rateView setFrame:CGRectMake(rateView.frame.origin.x, [[UIScreen mainScreen] bounds].size.height - 140 - [[UIApplication sharedApplication]statusBarFrame].size.height, rateView.frame.size.width, rateView.frame.size.height)];
                                            break;
                                        }

    No comments

    mas_an, 13 Февраля 2013

    Комментарии (17)
  8. Куча / Говнокод #12580

    +110

    1. 1
    <img border="0" width="476" height="179" src="file:///C|/Users/jy88h0/AppData/Roaming/Macromedia/Dreamweaver /eCustomer/iq/images/AI289.jpg" alt="Image of a properly addressed mail piece">

    http://faq.usps.com/eCustomer/iq/usps/request.do?create=kb%3AUSPSFAQ&view%28%2 9=c[c_usps0910]

    someone, 13 Февраля 2013

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

    +127

    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
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    /* Групповые операции с обращениями */
    public function issuegroupopsAction() {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $operation = $this->_request->getPost('operation');
        define('RTF_SYMBOL_PAGE_BREAK', '\page');
        try {
            // Валидация
            if(!in_array($operation, array('print-letters', 'print-work-order'))) {
                throw new Exception('Неверная операция');
            }
            $issue_numbers = explode(';', (string)$_POST['issues']);
            if(!count($issue_numbers)) {
                throw new Exception('Не выбрано ни одного обращения.');
            }
            // Вычитка указанных обращений
            $filter = new Type_Issue_Filter(array('issue_number' => $issue_numbers));
            $paginator = new Type_Paginator;
            $paginator->items_per_page = 40;
            $issues = services::Issue()->records($this->user->sessionId, $filter, array('executant', 'address'), 'number', $paginator);
            if(!count($issues->items)) {
                throw new Exception('Выбранные обращения не найдены.');
            }
            $templateMaker = new Prodom_Rtf_TemplateMaker;
            $templatesDir = dirname(__FILE__).'/templates/';
            $outputFiles = array();
            // Вид операции с группой обращений
            switch($operation) {
                case 'print-letters': {
                    // Сформирвать письма
                    $templateMaker->readTemplatesFromRtfFile($templatesDir.'templates.rtf');
                    $outputFiles = array('executants_%u.rtf' => array('issue2', 'letter1'), 'declarant_%u.rtf' => array('letter2'));
                    break;
                }
                case 'print-work-order': {
                    // Печать заказ-нарядов
                    if(!is_null($this->user->organization->issue_form_template)) {
                        // Если для организации определен свой собственный шаблон
                        $templateMaker->readTemplatesFromRtfFile($templatesDir.$this->user->organization->issue_form_template);
                    } else {
                        // Если шаблон явно не определен
                        $templateMaker->readTemplatesFromRtfFile($templatesDir.'templates.rtf');
                    }
                    $outputFiles = array('issue_%u.rtf' => array('issue1'));
                    break;
                }
            }
            $toworkIssueIds = array();
            $outputs = array_fill_keys(array_keys($outputFiles), null);
            // Перебор выбранных пользователем обращений
            foreach($issues->items as $issue) {
                // Переводим все новые обращения в статус "В работе"
                $issue_new_statuses = array(ISSUE_STATUS_NEW, ISSUE_STATUS_CONFIRMED);
                if(($operation == 'print-work-order') && in_array($issue->status_id, $issue_new_statuses) && ($issue->org_executor_id == $this->user->organization->id)) {
                    $toworkIssueIds[] = $issue->id;
                }
                // Подготовка полей обращения для печати на формах
                $fields = $this->getIssuePrintFields($issue);
                foreach($outputFiles as $fileName => $needTemplates) {
                    foreach($needTemplates as $template_code) {
                        $out = $templateMaker->getAppliedTemplate($template_code, $fields);
                        $outputs[$fileName] .= ($outputs[$fileName] ? RTF_SYMBOL_PAGE_BREAK : null) . $out;
                    }
                }
            }
            if(count($toworkIssueIds)) {
                $resp = services::Issue()->changeStatusMultiple($this->user->sessionId, $toworkIssueIds, ISSUE_STATUS_INWORK, null, null, null);
            }
            // Если на выходе только один файл, отправляем rtf
            if(count($outputs) == 1) {
                foreach($outputs as $fileName => $fileBody) {
                    // Генерация случайного имени файла
                    $fileName = str_replace('%u', substr(md5(implode('_', $issue_numbers)), 0, 7), $fileName);
                    // Вывод файла пользователю
                    header('Content-type: application/rtf');
                    header("Content-Disposition: attachment; filename={$fileName}");
                    echo $templateMaker->getHeader().$fileBody.$templateMaker->getFooter();
                }
            } else {
                // Eсли на выходе больше одного файла, пакуем их архивом
                header("Content-type: application/octet-stream");
                header("Content-Disposition: attachment; filename=issues.zip");
                header("Content-Description: Files of an applicant");
                // Создаем ZIP архив
                $zip = new ZipFile();
                foreach($outputs as $fileName => $fileBody) {
                    // Генерация случайного имени файла
                    $fileName = str_replace('%u', substr(md5(implode('_', $issue_numbers)), 0, 7), $fileName);
                    // Вывод файла пользователю в браузер
                    $fileBody = $templateMaker->getHeader().$fileBody.$templateMaker->getFooter();
                    $zip->addFile($fileBody, $fileName);
                }
                echo $zip->file();
            }
        }
        catch(Exception $ex) {
            die($ex->getMessage());
        }
    }

    Функция распечатки документов с отчетами по выбранным обращениям

    sciner, 13 Февраля 2013

    Комментарии (1)
  10. Java / Говнокод #12578

    +68

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    @Override
        public void execute() {
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            for (ClientListener listener : listeners) {
                listener.disconnected(this);
            }
        }

    Lure Of Chaos, 12 Февраля 2013

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