1. Куча / Говнокод #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)
  2. 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)
  3. 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)
  4. C++ / Говнокод #19216

    −1

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

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

    Ccik, 22 Декабря 2015

    Комментарии (1)
  5. 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)
  6. JavaScript / Говнокод #19212

    +2

    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
    function myRandom (from, to)  {return Math.floor((Math.random() * (to - from + 1)) + from);}
    function perehod(a,b,c){
        var cmdname="event";
        var cmdtime=a;
        var cmdparam="a;link;<getvar(host)>;click;-1";
        alert("prs::" + prskey + "::add::" + cmdname + "::" + cmdtime + "::" + cmdparam);
    
        var cmdname="link";
        var cmdtime=myRandom(b,c);
        var cmdparam="last;0";
        alert("prs::" + prskey + "::add::" + cmdname + "::" + cmdtime + "::" + cmdparam);
    
       var cmdname="script";
        var cmdtime=myRandom(1,3);
        var cmdparam="window.scrollTo(<rndr(100:500)>,<rndr(50:1000)>);";
        alert("prs::" + prskey + "::add::" + cmdname + "::" + cmdtime + "::" + cmdparam);
    
        var cmdname="script";
        var cmdtime=myRandom(1,3);
        var cmdparam="window.scrollTo(<rndr(100:1000)>,<rndr(50:1500)>);";
        alert("prs::" + prskey + "::add::" + cmdname + "::" + cmdtime + "::" + cmdparam);
    }
    
    if (m == 1){
        perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 2){
       perehod(2, min_t_vr, max_t_vr);
       perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 3){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 4){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 5){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 6){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 7){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    else if (m == 8){
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
      perehod(2, min_t_vr, max_t_vr);
    }
    // и т.д. до m == 20 (sic!)
    else {
    	perehod(2, 15, 20);
    	perehod(2, 15, 20);
    	perehod(2, 15, 20);
    	perehod(2, 15, 20);
    	perehod(2, 15, 20);
    }

    Циклы? Не, не слышал...

    govnokod-observer, 22 Декабря 2015

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

    +1

    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
    $product = ORM::factory('product');
    
    // $product-> ... = ...;
    
    $price = ORM::factory('price');
    $price->save();
    $product->price = $price->id;
    $product->save();
    $price->product = $product->id;
    
    // $price-> ... = ...;
    
    $price->save();

    Для гарантии

    kgm-rj, 22 Декабря 2015

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php
    echo '<script type="text/javascript">';
    echo 'var categories = new Array();';
    if (count($categData)) {
        foreach ($categData as $id => $name) {
            echo ' categories[' . $id . '] = "' . $name . '";';
        }
    }
    echo ' </script>';
    ?>

    danielpetrovaliev, 22 Декабря 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    select value, value_type from b_iblock_element_property WHERE id = **;
    
    b_iblock_element_property.value: a:2:{s:4:"TYPE";s:4:"text";s:4:"TEXT";s:17:"Хорошее состояние";}
    b_iblock_element_property.value_type: text

    bitrix <3

    heyzea1, 21 Декабря 2015

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

    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
    function saveTrainingData() {
    
        function getStorylineCsvStr(lineNumber) {
            var storyline = loadedLines[lineNumber];
            var csvStr = "";
            for (var i = 0; i < storyline.entities.length; i++) {
                if (i > 0) {
                    csvStr = csvStr + ",";
                }
                var entityName = storyline.entities[i].name;
    
                if (storyline.entities[i].relation != null && storyline.entities[i].relation.length > 0) {
                    for (var j = 0; j < storyline.entities[i].relation.length; j++) {
                        if ($("#relation-checkbox-" + lineNumber + "-" + i + "-" + j).is(":checked")) {
                            entityName = entityName + ":" + storyline.entities[i].relation[j];
                        }
                    }
                }
    
                if (entityName.indexOf(",") >= 0 || entityName.indexOf("\"") >= 0) {
                    if (entityName.indexOf("\"") >= 0) {
                        entityName = entityName.replace(/"/g, "\"\"");
                    }
                    entityName = "\"" + entityName + "\"";
                }
                csvStr = csvStr + entityName;
            }
            return csvStr;
        }
    
        var trainingData = "";
        $(".training").each(function (index, element) {
            var trainingHolder = $(element);
            var lineNumber = trainingHolder.attr("line-number");
            if (trainingHolder.find(".positive").is(":checked")) {
                trainingData = trainingData + getStorylineCsvStr(lineNumber) + ",1\n";
            } else if (trainingHolder.find(".negative").is(":checked")) {
                trainingData = trainingData + getStorylineCsvStr(lineNumber) + ",0\n";
            }
        });
    
        var groupId = $('#group-name-selector :selected').val();
        var bandType = $('#band-selector').val();
    
        sendRequest("/app/view/set/trainingData", {
            trainingData: trainingData,
            groupId: groupId,
            bandType: bandType
        }, true, true);
    }

    meow

    megatraher, 21 Декабря 2015

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