1. 1C / Говнокод #10171

    −179

    1. 1
    2. 2
    3. 3
    Если Не КВыгрузке Тогда
        КВыгрузке = НЕ КВыгрузке;
    КонецЕсли;

    inspired, 03 Мая 2012

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

    −3

    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
    sscanf_s(buf,
    		"%f%f%f%f%f%d%d%d%d%d%d"
    		"%f%f%f%f%f%d%d%d%d%d%d"
    		"%f%f%f%f%f%d%d%d%d%d%d"
    		"%f%f%f%f%f%d%d%d%d%d%d",
    		&_race_state._car[0]._x, &_race_state._car[0]._y, &_race_state._car[0]._vx,
    		&_race_state._car[0]._vy, &_race_state._car[0]._angle, &_race_state._car[0]._nitro_time,
    		&_race_state._car[0]._oiled_bus, &_race_state._car[0]._nirtos, &_race_state._car[0]._bonus,
    		&_race_state._car[0]._lap, &_race_state._car[0]._next_seg,
    		&_race_state._car[1]._x, &_race_state._car[1]._y, &_race_state._car[1]._vx,
    		&_race_state._car[1]._vy, &_race_state._car[1]._angle, &_race_state._car[1]._nitro_time,
    		&_race_state._car[1]._oiled_bus, &_race_state._car[1]._nirtos, &_race_state._car[1]._bonus,
    		&_race_state._car[1]._lap, &_race_state._car[1]._next_seg,
    		&_race_state._car[2]._x, &_race_state._car[2]._y, &_race_state._car[2]._vx,
    		&_race_state._car[2]._vy, &_race_state._car[2]._angle, &_race_state._car[2]._nitro_time,
    		&_race_state._car[2]._oiled_bus, &_race_state._car[2]._nirtos, &_race_state._car[2]._bonus,
    		&_race_state._car[2]._lap, &_race_state._car[2]._next_seg,
    		&_race_state._car[3]._x, &_race_state._car[3]._y, &_race_state._car[3]._vx,
    		&_race_state._car[3]._vy, &_race_state._car[3]._angle, &_race_state._car[3]._nitro_time,
    		&_race_state._car[3]._oiled_bus, &_race_state._car[3]._nirtos, &_race_state._car[3]._bonus,
    		&_race_state._car[3]._lap, &_race_state._car[3]._next_seg );

    парсим строчку...

    rip, 03 Мая 2012

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

    +91

    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
    //Постраничная навигация
    $result77 = mysql_query("SELECT str FROM ..."); 
    $myrow77 = mysql_fetch_array($result77);
    $num = $myrow77["str"];
    
    // Извлекаем из URL текущую страницу
    @$page = $_GET['page'];
    
    // Определяем общее число сообщений в базе данных
    $result00 = mysql_query("SELECT COUNT(*) FROM ...");
    $temp = mysql_fetch_array($result00);
    $posts = $temp[0];
    
    // Находим общее число страниц
    $total = (($posts - 1) / $num) + 1;
    $total =  intval($total);
    
    // Определяем начало сообщений для текущей страницы
    $page = intval($page);
    // Если значение $page меньше единицы или отрицательно
    // переходим на первую страницу
    // А если слишком большое, то переходим на последнюю
    if(empty($page) or $page < 0) $page = 1;
    if($page > $total) $page = $total;
    // Вычисляем начиная с какого номера
    // следует выводить сообщения
    $start = $page * $num - $num;
    // Выбираем $num сообщений начиная с номера $start                                     
    $result_gb1 = mysql_query("SELECT * FROM . ORDER BY id DESC LIMIT $start, $num");
    $myrow_gb1 = mysql_fetch_array($result_gb1);
    $list = 1;
    
    switch($page)
    {
        case "2":
        $list = $num + 1;
        break;
        case "3":
        $list = $num * 2 + 1;
        break;
        case "4":
        $list = $num * 3 + 1;
        break;
        case "5":
        $list = $num * 4 + 1;
        break;
        case "6":
        $list = $num * 5 + 1;
        break;
        case "7":
        $list = $num * 6 + 1;
        break;
        case "8":
        $list = $num * 7 + 1;
        break;
    }

    Навигация по страницам, написанная человеком с гуманитарным складом ума...

    Мартин, 02 Мая 2012

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

    +71

    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
    public class ... {
    
    public Double toDoubleValue(String s){
    	Double value;
    	if (s!=""){
    		value = Double.valueOf(s);
    		return value;
    	}
    	else {
    		value = 0.00;
    		return value;
    	}
            ....
            toDoubleValue(row.getColumnValue(col.getId()).toString());
    }

    1. На null не проверяется
    2. Можно было тоже самое написать короче, не объявляя дополнительный метод, с помощью ?:

    -EZ-, 02 Мая 2012

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

    +90

    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
    if(!empty($_POST))
    {
    	include("dbconnect.php");
    
    	$shown_name=$_POST['shown_name'];
    	$username=$_POST['username'];
    	$header=$_POST['header'];
    	$text=$_POST['text'];
    
    	$date_array=getdate(time());
    
    	$date=$date_array['hours'].":".$date_array['minutes'].":".$date_array['seconds']." ".$date_array['weekday']." ".$date_array['mday']." ".$date_array['month']." ".$date_array['year'];
    
    
    	$filename=$date_array['hours']."-".$date_array['minutes']."-".$date_array['seconds']."-".$date_array['mday'].$date_array['month']."-".$date_array['year']."-".$username.".php";
    
    	$path="posts/".$filename;
    
    	$addpost="INSERT INTO posts(author, header, text, date, path) VALUES ('$shown_name', '$header', '$text', '$date', '$path')";
    	$add=$db->prepare($addpost);
    	$add->execute();
    
    
    
    
    	$file=fopen($path, 'w');
    	$content="<?php \$shown_name=\"".$shown_name."\"; \$header=\"".$header."\"; \$text=\"".$text."\";  include(\"template.html\"); ?>";
    
    	$write=fwrite($file, $content);
    
    	fclose($file);
    
    
    	header('Location: index.php');
    	$db=null;
    }

    Добавление поста в блог. Радует каждая строчка.

    nucleartux, 02 Мая 2012

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

    +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
    if ( ($cache = isset($this->cache[0]) ? $this->cache[0] : null) != null ) {
            $isNeedCache = $cache->isNeedCache($plug);
        }
        
        if ( !$isNeedCache || !$cache->getPlugCache($plug, $plugInfo) ) {
          
          /** processing: running plug */
          $this->dispatcher->processPlug($request, $response);
          
          if ($isNeedCache)
            $cache->setPlugCache($plug, $plugInfo);
        }

    hwtech, 02 Мая 2012

    Комментарии (14)
  7. ActionScript / Говнокод #10165

    −204

    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
    // avm+ specific utility method
     public static function throwError(type:Class, index:uint, ... rest)
     {
         // This implements the same error string formatting as the native
         // method PrintWriter::formatP(...) any changes to this method should
         // also be made there to keep the two in sync.
         var i=0;
         var f=function(match, pos, string)
         {
             var arg_num = -1;
             switch(match.charAt(1))
             {
                 case '1':
                     arg_num = 0;
                     break;
                 case '2':
                     arg_num = 1;
                     break;
                 case '3':
                     arg_num = 2;
                     break;
                 case '4':
                     arg_num = 3;
                     break;
                 case '5':
                     arg_num = 4;
                     break;
                 case '6':
                     arg_num = 5;
                     break;
             }
             if( arg_num > -1 && rest.length > arg_num )
                 return rest[arg_num];
             else
                 return "";
         }
         throw new type(Error.getErrorMessage(index).replace(/%[0-9]/g, f), index);
     }

    http://hg.mozilla.org/tamarin-redux/file/fdf1416a3536/core/Error.as
    Проблемы с устным счетом, да и не только...

    wvxvw, 02 Мая 2012

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

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    inline uint32 pow(uint32 arg1, int agr2)
    {
        for (int i = 0; i < agr2; ++i)
            arg1 *= arg1;
        return arg1;
    }

    Возведение в степень.

    a553r7fa1L3d, 01 Мая 2012

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

    −20

    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
    void MainWindow::justDoIt(){
    ui->textEdit->clear();
    bool b[16];
    for (int i = 0; i < 16; ++i) {
        b[i] = false;
    }
        ui->textEdit->append("$$ \n \\begin{cases}");
        QString a;
        a += (ui->lineEdit->text().toDouble() == 0 ? "": (b[0] = true, ui->lineEdit->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_1" :ui->lineEdit->text().remove("+") + "x_1"));
        a += (ui->lineEdit_2->text().toDouble() == 0 ? "" : (b[1] = true,ui->lineEdit_2->text().toDouble() < 0 || (!b[0])? "":"+") +(ui->lineEdit_2->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_2" : ui->lineEdit_2->text().remove("+")+"x_2"));
        a += (ui->lineEdit_3->text().toDouble() == 0 ? "" : (b[2] = true,ui->lineEdit_3->text().toDouble() < 0 || (!b[0] && !b[1]) ? "":"+") +(ui->lineEdit_3->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_3" :ui->lineEdit_3->text().remove("+")+"x_3"));
        a += (ui->lineEdit_4->text().toDouble() == 0 ? "" : (b[3] = true,ui->lineEdit_4->text().toDouble() < 0 || (!b[0] && !b[1] && !b[2])? "":"+") +(ui->lineEdit_4->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_4" :ui->lineEdit_4->text().remove("+")+"x_4"));
        if(b[0] || b[1] || b[2] || b[3]){
            a += "=";
            a += ui->lineEdit_5->text();
            a += "\\\\\n";
        }
    /*еще такой же код*/ 
        a += (ui->lineEdit_24->text().toDouble() == 0 ? "" : (b[12] = true,ui->lineEdit_24->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_1" :ui->lineEdit_24->text()+"x_1"));
        a += (ui->lineEdit_21->text().toDouble() == 0 ? "" : (b[13] = true,ui->lineEdit_21->text().toDouble() < 0 || (!b[13])? "":"+") +(ui->lineEdit_21->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_2" :ui->lineEdit_21->text().remove("+")+"x_2"));
        a += (ui->lineEdit_23->text().toDouble() == 0 ? "" : (b[14] = true,ui->lineEdit_23->text().toDouble() < 0 || (!b[13]&&!b[14])? "":"+") +(ui->lineEdit_23->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_3" :ui->lineEdit_23->text().remove("+")+"x_3"));
        a += (ui->lineEdit_22->text().toDouble() == 0 ? "" : (b[15] = true,ui->lineEdit_22->text().toDouble() < 0 || (!b[13]&&!b[14]&&!b[15])? "":"+") +(ui->lineEdit_22->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_4" :ui->lineEdit_22->text().remove("+")+"x_4"));
        if(b[12] || b[13] || b[14] || b[15]){
            a += "=";
            a += ui->lineEdit_25->text();
        }
    
    ui->textEdit->append(a);
    ui->textEdit->append("\\end{cases} \n$$");
    }

    Превращает матрицу 4х5 в СЛАР на LaTeX

    Abbath, 01 Мая 2012

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

    +90

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $obj_type = $blog->getType();
    $obj_id = $blog->getIdentity();
    $obj_task ="add";
    
    if ($obj_type && $obj_id && $obj_task == 'add') {
    ...
    }

    $obj_task - та так... на всякий случай...

    lantian, 01 Мая 2012

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