1. Куча / Говнокод #3984

    +118

    1. 1
    2. 2
    <td>&nbsp;  </td>
    <td><br/><br/></td>

    До чео техника то дошла. Авно передают и тут и там.

    n0ne, 15 Августа 2010

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

    +156

    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
    while(myBot.loop) {
                    sleep(15);
                    myBot.connect(false);
    
                    while(myBot.loop) {
                            if(myBot.client->recv( 750000 )!=ConnNoError) {
                                   	break;
                            } else {
                                    hostent * record = gethostbyname(myBot.client->server().c_str());
                                   	if(record == NULL) {
                                            break;
                                    }
                           	}
                    }
    
                    myBot.disconnect();
           	}

    Бот на gloox. В строчках с 5 по 14 проверяется, не пропал ли линк, и пытается реконнектится, если, собственно, пропал.

    kainwinterheart, 14 Августа 2010

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void log(string srv, string text) {
                    time_t rawtime; tm * ptm; time ( &rawtime ); ptm = gmtime ( &rawtime );
                    ofstream logfile(LOG, ios::app);
                    logfile << (ptm->tm_year+1900) << "-" << (ptm->tm_mon+1) << "-" << ptm->tm_mday << " "
                            << (ptm->tm_hour+MSD%24) << ":" << ptm->tm_min << ":" << ptm->tm_sec << endl << srv << ":\t" << text << endl << endl;
                    logfile.close();
            }

    Жистоке, брутальне логирование.

    kainwinterheart, 14 Августа 2010

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

    +113

    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
    double x, y;
    
    void InitializeComponent()
    {
        this.MouseClick += new MouseEventHandler(Form1_Click);
        this.Paint += new PaintEventHandler(Form1_Paint);
    }
    
    void Form1_Paint(object sender, PaintEventArgs e)
    {
        PointF p = new PointF(0, 0);
        PointF pp = new PointF((float)x, (float)y);
        e.Graphics.DrawPolygon(new Pen(Color.Black, 3), new PointF[2] { p, pp });
    }
    
    void Form1_Click(object sender, MouseEventArgs e)
    {
        x = e.X;
        y = e.Y;
    
        AsyncDraw(ref x, ref y);
    }
    
    void AsyncDraw(ref double x, ref double y)
    {
        x = x;
        y = y;
    }

    sergylens, 14 Августа 2010

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

    +148

    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
    <?php
    if (!$action){
    	echoheader('addnews', $echo['header']);
    ?>
    
    <form method="post" name="addnews" action="<?=$PHP_SELF; ?>" onsubmit="return process_form(this)">
    
    
    
    <!-- короткая -->
    <fieldset id="short"><legend><?=$echo['short']; ?></legend>
    
    <?
    	echo run_filters('new-advanced-options', 'short');
    ?>
    
    
    <textarea name="short_story" tabindex="4"></textarea>
    </fieldset>
    
    
    
    <!-- кнопки -->
    <fieldset id="actions"><legend><?=$echo['actions']; ?></legend>
    <input type="submit" value="<?=$echo['add']; ?>" accesskey="s">
    </fieldset>
    
    
    
    
    
    <?
    	}
    ?>
    
    <fieldset id="date"><legend><?=$echo['date']; ?></legend>
    <input type="text" name="day" size="10" maxlength="2" value="<?=date('d'); ?>" title="<?=$echo['calendar']['day']; ?>" readonly>
    
    <input type="text" name="month" size="10" maxlength="10" value="<?=date('M'); ?>" readonly>
    
    
    
    <input type="text" name="year" maxlength="4" value="<?=date('y'); ?>" title="<?=$echo['calendar']['year']; ?>" readonly> <input type="text" name="hour" maxlength="2" value="<?=date('H', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['hour']; ?>" readonly>:<input type="text" name="minute" maxlength="2" value="<?=date('i', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['minute']; ?>" readonly>:<input type="text" name="second" maxlength="2" value="<?=date('s', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['second']; ?>" readonly>
    </fieldset>
    
    
    
    </div></fieldset>
    
    <input type="hidden" name="mod" value="addnews">
    <input type="hidden" name="action" value="doaddnews">
    </form>
    
    <?
    	echofooter();
    
    
    // ********************************************************************************
    // Do add News to DB
    // ********************************************************************************
    if ($action == 'doaddnews'){
    	if (($added_time = strtotime($day.' '.$month.' '.$year.' '.$hour.':'.$minute.':'.$second)) == -1){
    		$added_time = (time() + $config_date_adjust * 60);
    	}
    
    	if (!$title){
    		$title = substr($short_story, 0, 10).'...';
    	}
    
    	$id = $sql->last_insert_id('news', '', 'id') + 1;
    
    	run_actions('new-save-entry');
    
    	$sql->insert(array(
    	'table'	 => 'news',
    	'values' => array(
    				'date'	   => $added_time,
    				'author'   => $member['username'],
    				'title'	   => replace_news('add', $title),
    				'short'	   => strlen(replace_news('add', $short_story)),
    				'full'	   => strlen(replace_news('add', $full_story)),
    				'avatar'   => $avatar,
    				'category' => $category,
    				'url'	   => ($url ? my_namespace($url) : my_namespace(totranslit($title))),
    				'hidden'   => (($config_approve_news == 'yes' and $member['level'] > 2) ? true : false)
    				)
    	));
    
    	$sql->insert(array(
    	'table'	 => 'story',
    	'values' => array(
    				'post_id' => $id,
    				'short'	  => replace_news('add', $short_story),
    				'full'	  => replace_news('add', $full_story)
    				)
    	));
    
    	run_actions('new-save-entry');

    dimiork, 14 Августа 2010

    Комментарии (19)
  6. Си / Говнокод #3979

    +136

    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
    #include <stdio.h>
    
    #define declare_generic_func(x)\
    x add_##x(x x1,x x2) \
    {\
    	return x1+x2;\
    }
    #define generic_func(x,name) name##_##x
    
    declare_generic_func(int);
    declare_generic_func(double);
    
    int main()
    {
    	int a,b;
    	double ad,bd;
    	printf("Enter two integer numbers: ");
    	scanf("%d%d",&a,&b);
    	printf("Result: %d\n",generic_func(int,add)(a,b));
    	printf("Enter two real numbers: ");
    	scanf("%lf%lf",&ad,&bd);
    	printf("Result: %lf\n",generic_func(double,add)(ad,bd));
    	return 0;
    }

    Дженерики для труЪ сишников.

    frp, 14 Августа 2010

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

    +143

    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
    void Draw(object sender, PaintEventArgs e)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    
                //X
                e.Graphics.DrawLine(new Pen(Color.Blue, 3), new Point(0, this.Height / 2), new Point(this.Width, this.Height / 2));
    
                //Y
                e.Graphics.DrawLine(new Pen(Color.Red, 3), new Point(this.Width / 2, this.Height), new Point(this.Width / 2, 0));
    
    
                PointF[] p = new PointF[this.Width];
    
                //MessageBox.Show((Math.PI / 180 * 1).ToString());
                for(int i = 0, z = this.Width; i < (this.Height / 2); i++, z++)
                {
                    p[i].X = (float)Math.Cos(z) * this.Width;
                    p[i].Y = (float)Math.Sin(i) * this.Height;
                }
    
                e.Graphics.DrawCurve(new Pen(Color.LightSkyBlue, 2), p, 2);
            }

    sergylens, 13 Августа 2010

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

    +151

    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
    <?php  
    
    // фиксация времени начала генерации страницы  
    $begin = microtime();  
    // матрица начального времени с секундами и миллисекундами  
    $arrbegin = explode(" ",$begin);  
    // Полное начальное время 
    $allbegin = $arrbegin[1] + $arrbegin[0];  
    
    ?>  
    
    <?php  
    
    // фиксация времени останова   
    $stop = microtime();  
    // матрица времени останова с секундами и миллисекундами  
    $arrend = explode(" ",$stop);  
    // Полное время останова 
    $allend = $arrend[1] + $arrend[0];  
    // вычитание из конечного времени начального  
    $alltime = $allend - $allbegin;  
    
    // вывод в браузер времени генерации страницы  
    $format = "Страница сгенерирована за %f секунд"; 
    printf($format,$alltime);  
    
    ?>

    http://acvarif.info/wbsphp/additphp/gener.html
    извращенный подсчет времени генерации

    Morgan, 13 Августа 2010

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

    +112

    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
    private int nextEscaped() {
            int ch = temp[++cursor];
            return ch;
        }
        private int readEscaped() {
            int ch = temp[cursor++];
            return ch;
        }
        private int read() {
            int ch = temp[cursor++];
            if (has(COMMENTS))
                ch = parsePastWhitespace(ch);
            return ch;
        }
        private int peek() {
            int ch = temp[cursor];
            if (has(COMMENTS))
                ch = peekPastWhitespace(ch);
            return ch;
        }

    блин, праздник все-таки - запостю еще один. источник тот же что и в http://govnokod.ru/3975

    3.14159265, 13 Августа 2010

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

    +115

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    for (i = 0; i < count; i++) {
                    int c = buf[i];
                    c = Character.toUpperCase(c);
                    c = Character.toLowerCase(c);
                    tmp[i] = c;
                }
    //в совсем другом месте
                    int cc = Character.toUpperCase(c);
                    cc = Character.toLowerCase(cc);

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

    3.14159265, 13 Августа 2010

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