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

    +1

    1. 1
    _workflowQueue = new Queue<IWorkflowInfo>(_workflowQueue.Where(w => !(w == workflow || w.WorkflowGuid == workflow.WorkflowGuid)));

    Вот как надо делать, если из очереди нужно удалить произвольный элемент.
    Использовать List?! Это для слабаков!

    delph_er, 24 Декабря 2015

    Комментарии (0)
  2. PHP / Говнокод #19224

    +3

    1. 1
    * @return boolean "No! Try not. Do. Or do not. There is no try." - Yoda

    sevenflash, 24 Декабря 2015

    Комментарии (0)
  3. Assembler / Говнокод #19223

    +106

    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
    < !DOCTYPE html >
    < html >
    < head >
    < title >Температура процессора< /title >
    < meta http-equiv="content-type" content="text/html; charset=windows-1251" / >
    < asm >
    mov dx, 295h
    mov al, 4Eh
    out dx, al
    inc dx
    in al, dx
    or al, 1
    out dx, al
    dec dx
    mov al, 50h
    out dx, al
    in al, dx
    mov #temperature, al
    < /asm >
    < /head >
    < body >
    < span id="temperature" >< /span >
    < /body >
    < /html >

    https://otvet.mail.ru/question/185609056

    3_dar, 23 Декабря 2015

    Комментарии (195)
  4. JavaScript / Говнокод #19222

    0

    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
    if (document.querySelector('.instruction-wrapper')) {
      if (!window.requestAnimationFrame) {
    
        window.requestAnimationFrame = (function() {
    
          return window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame
    
        })();
      }
    
      var animator = {
        stageArray: [
          [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
          [14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
        ],
        // min:16,max:25,
        element: document.querySelector('.instruction-wrapper'),
        originalClassName: 'instruction-wrapper',
        currentStage: 1,
        currentStep: 0,
        oldTime: new Date().getTime(),
        timeStep: 1200,
        addStateClass: 'state-', //+stateRange.currentStep
        chaning: true,
        repeat: true,
        debug: true,
        autoplay: true,
        animate: function() {
          requestAnimationFrame(animator.animate);
          if (animator.autoplay) {
            animator.draw();
          }
        },
        classCheckUpdate: function(arg1) {
          this.element.className = this.originalClassName;
          for (var i = 0; i <= arg1; i++) {
            this.element.classList.add(this.addStateClass + '' + i);
          }
        },
        draw: function(arg) {
    
          var time = new Date().getTime();
          // console.log(time - oldTime);
          if (time > this.oldTime + this.timeStep) {
    
    
            if (this.debug) {
              console.log(this.currentStep)
            };
            this.oldTime = time;
    
            if (!arg && !!this.stageArray[this.currentStage][this.currentStep + 1]) {
              console.log('instr-' + 1 + '_' + this.stageArray[this.currentStage][this.currentStep + 1]);
              this.currentStep += 1;
              this.classCheckUpdate(this.stageArray[this.currentStage][this.currentStep])
                // this.element.classList.add(this.addStateClass + '' + this.stageArray[this.currentStage][this.currentStep]);
            } else if (!arg && !this.stageArray[this.currentStage][this.currentStep + 1] && !!this.repeat) {
              this.currentStep = 0;
              console.log('instr-' + 2);
              this.classCheckUpdate(this.stageArray[this.currentStage][this.currentStep])
                // this.element.className = this.originalClassName;
                // this.element.classList.add(this.addStateClass + '' + this.stageArray[this.currentStage][this.currentStep]);
            } else if (!this.stageArray[this.currentStage][this.currentStep + 1] &&
              !this.repeat &&
              this.stageArray[this.currentStage + 1]) {
              this.currentStage += 1;
              console.log('instr-' + 3);
              this.currentStep = this.stageArray[this.currentStage + 1][0];
            } else if (arg > 1) {
              console.log('instr-' + 4);
              this.element.className = this.originalClassName;
              for (var i = 0; i <= arg; i++) {
                this.element.classList.add(this.addStateClass + '' + i);
                this.element.classList.add(this.addStateClass + '' + this.stageArray[this.currentStage][this.currentStep]);
              }
            }
          }
        }
    
      }
      animator.animate();
    }

    Перекулючение классов для анимационного сценария

    mcheguevara2, 23 Декабря 2015

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

    0

    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
    <?
    //Ограничиваем время выполнения скрипта 3-мя минутами
    set_time_limit(180);
    
    //Подключаемся к MySQL, при неудаче выводим ошибку
    mysql_connect("localhost", "torrent", "password") or die("Could not connect to MySQL");
    
    //Выбираем БД, при неудаче выводим ошибку
    mysql_select_db("torrent") or die("Could not select database");
    
    //Переводим все общение с БД в кодировку utf8
    mysql_query("SET NAMES utf8");
    
    //Открываем файл указанный в url переменной "f"
    $fp = fopen($_GET[f], "r");
    
    //Запускаем цикл до конца строк в файле
    while (!feof($fp)) {
            //Считываем строку (да, функцию trim() выполнять не обязательно, но у каждого программиста свои "тараканы")
            $tmp = trim(fgets($fp));
            
            //Преобразуем строку в массив. За разделитель используем ";"
            $torrent = explode('";"', $tmp);
            
            //В первом и последнем элементе удаляем лишние символы "
            $torrent[0] = substr($torrent[0], 1);
            $torrent[6] = substr($torrent[6], 0, (strlen($torrent[6]) - 1));
            
            //Если раскомментировать следующую строку, то можно увидеть как распарсился первый торрент в файле
            //print '<pre>'; print_r($torrent); exit();
            
            //Вставляем данные текущего торрента в таблицу
            mysql_query("INSERT INTO `torrents` 
                (`name`,
                `hash`,
                `date`,
                `size`,
                `topic_id`,
                `cat_id`,
                `cat_name`) 
              VALUES 
                ('" . mysql_real_escape_string($torrent[4]) . "',
                '" . $torrent[3] . "',
                '" . $torrent[6] . "',
                '" . $torrent[5] . "',
                '" . $torrent[2] . "',
                '" . $torrent[0] . "',
                '" . mysql_real_escape_string($torrent[1]) . "')
            ");
    }
    //Закрываем файл
    fclose($fp);
    
    //Выводим сообщение о завершении работы
    print 'complete: ' . $_GET[f];
    ?>

    Импорт CSV в MySQL. Со швабры.

    gost, 23 Декабря 2015

    Комментарии (4)
  6. Куча / Говнокод #19219

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <font size="2" face="Courier New" color="black"><font color="#0000ff"><</font><font
    color="#800000">video</font><font color="#0000ff">></font>   <font
    color="#0000ff"><</font><font color="#800000">source</font> <font
    color="#ff0000">src</font><font color="#0000ff">="movie.mp4"</font> <font
    color="#ff0000">type</font><font color="#0000ff">='video/mp4; codecs="avc1.42E01E,
    mp4a.40.2"'</font> <font color="#0000ff">/></font>   <font color="#0000ff"><</font><font
    color="#800000">source</font> <font color="#ff0000">src</font><font
    color="#0000ff">="movie.webm"</font> <font color="#ff0000">type</font><font
    color="#0000ff">='video/webm; codecs="vp8, vorbis"'</font> <font color="#0000ff">
    /></font> <font color="#0000ff"></</font><font color="#800000">video</font><font
    color="#0000ff">></font></font>>

    «Итак, чтобы видео появилось на вашей веб-страничке пишем следующий код»

    KEKC, 23 Декабря 2015

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

    0

    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
    // channel.h
    
    #pragma once
    
    namespace AMQP {
    
    class Channel
    {
    private:
        std::shared_ptr<ChannelImpl> _implementation;
    
    public:
        Channel(Connection *connection) : _implementation(new ChannelImpl()) 
        {
            // attach the connection to the channel
            _implementation->attach(connection);
        }
        
        Channel(const Channel &channel) = delete;
    
        virtual ~Channel() 
        {
            // close the channel (this will eventually destruct the channel)
            _implementation->close();
        }
    
        //...
    };
    
    // ---------------------------------------------------------
    // amqpcpp.h
    
    /**
     *  AMQP.h
     *
     *  Starting point for all includes of the Copernica AMQP library
     *
     *  @documentation public
     */
    
    #pragma once
    
    // base C++ include files
    #include <vector>
    #include <string>
    #include <memory>
    #include <map>
    //...
    
    // base C include files
    #include <stdint.h>
    #include <math.h>
    
    // forward declarations
    #include <amqpcpp/classes.h>
    
    // utility classes
    #include <amqpcpp/endian.h>
    #include <amqpcpp/buffer.h>
    #include <amqpcpp/bytebuffer.h>
    //...
    
    // amqp types
    #include <amqpcpp/field.h>
    #include <amqpcpp/numericfield.h>
    #include <amqpcpp/decimalfield.h>
    #include <amqpcpp/stringfield.h>
    //...
    
    // envelope for publishing and consuming
    #include <amqpcpp/metadata.h>
    #include <amqpcpp/envelope.h>
    #include <amqpcpp/message.h>
    
    // mid level includes
    #include <amqpcpp/exchangetype.h>
    #include <amqpcpp/flags.h>
    #include <amqpcpp/callbacks.h>
    #include <amqpcpp/deferred.h>
    #include <amqpcpp/deferredconsumer.h>
    #include <amqpcpp/deferredqueue.h>
    #include <amqpcpp/deferreddelete.h>
    #include <amqpcpp/deferredcancel.h>
    #include <amqpcpp/deferredget.h>
    #include <amqpcpp/channelimpl.h>
    #include <amqpcpp/channel.h>
    //...

    https://github.com/CopernicaMarketingSoftware/AMQP-CPP

    scp, 23 Декабря 2015

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

    0

    1. 1
    2. 2
    3. 3
    if ($this->scenario == 'registration' || $this->scenario = 'changePassword') {
    	$this->password = HPasswordHelper::hashPassword($this->password);
    }

    Вот так сравнение сценарий в одном из проектов)))
    И самое странное всегда при сохранении, сценарий "changePassword" )

    ignatenkovnikita, 23 Декабря 2015

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

    −1

    1. 1
    #define GUIDSTR(s) __uuidof(class DECLSPEC_UUID(s) __guid_##__COUNTER__)

    Может можно покороче?

    Ccik, 22 Декабря 2015

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

    0

    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
    if( sync_ip_index < 0 && result() ) {
                QString tmp = tr(", нет синхронизации");
                addResultMessage( false, p->dev(), tmp);
                p->dev()->setState( CDiagramObject::e_Warning );
                setResult( false );
            }
            else if ( sources_from_xml.indexOf( sources_from_ntpq[ sync_ip_index ] ) < 0) {
                // ( ( (sync_ip_index >= 0)  ? ( sources_from_xml.indexOf( sources_from_ntpq[ sync_ip_index ] ) < 0 ) : false ) )  {
                // (p1 ( p2               )    ( p3                      ( f1                                 )                 )
                // p1..3 - predicates
                // Check sync_ip_index >= 0 (p2)
                //  true, then
                //    find sync source ip in list filled from xml config , and if there is finded, (p3) are true, else (p3) are false, and then (p1) will be false
                //  false, then
                //    (p1) will be false
                // This construction for one string check syncronized source ip for host, if host not synchronized
                QString tmp = tr(", хост синхронизирован с источником не указанным в схеме");
                addResultMessage( false, p->dev(), tmp);
                p->dev()->setState( CDiagramObject::e_Warning );
                setResult( false );
            }

    Под конец рабочего дня уже поехала крыша, см. комментарии.

    OlegUP, 22 Декабря 2015

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