1. JavaScript / Говнокод #14327

    +167

    1. 1
    2. 2
    gl.drawArrays(gl.QUADS, 0, 4);
    // WebGL рисует черный экран с четырьмя точками.

    bormand vs WebGL. Акт второй.

    Как оказалось, в OpenGL ES выпилили GL_QUADS и GL_POLYGON.
    Но т.к. в js несуществующее поле это null, а null это 0, а 0 это GL_POINTS, то рисуются 4 точки ;)

    bormand, 07 Января 2014

    Комментарии (53)
  2. Куча / Говнокод #14325

    +133

    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
    // bormand: Ну что, затестим шейдер в WebGL...
    int iter = 0;
    while (iter < 1000 && length(z) < 2.0) {
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
        iter++;
    }
    // compileShader: 'while' : This type of loop is not allowed
    
    // bormand: WTF?! В обычном OpenGL же работало, ну ок...
    int iter = 0;
    for (; iter < 1000; iter++) {
        if (length(z) < 2.0)
            break;
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
    }
    // compileShader: 'for' : Missing init declaration
    
    // bormand: Да что за херня!?
    for (iter = 0; iter < 1000; iter++) {
    // compileShader: 'for' : Invalid init declaration
    
    // bormand: Подавись, сука!
    int iters = -1;
    for (int iter = 0; iter < 1000; iter++) {
        if (length(z) < 2.0) {
            iters = iter;
            break;
        }
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
    }
    // compileShader: ok.

    bormand vs WebGL

    bormand, 07 Января 2014

    Комментарии (159)
  3. Куча / Говнокод #14324

    +125

    1. 1
    2. 2
    3. 3
    @ECHO OFF
    VESAINF %1
    PAUSE

    Фикс к программе на ассемблере с исходным кодом.
    http://masm32.com/board/index.php?topic=2727.msg29659#msg29659

    LispGovno, 07 Января 2014

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

    +126

    1. 1
    <input type="text" id="tos" name="tos" data-validate="true" class="text-field" tabindex="6"  data-validation-rules="^(https?|ftp):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$" data-validation-msg="Invalid URL" />

    Monkey killing monkey killing monkey
    Over pieces of the ground.
    Silly monkeys give them thumbs,
    They forge a blade,
    And where there's one
    they're bound to divide it,
    Right in two.
    Right in two.


    :'(

    wvxvw, 07 Января 2014

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

    +16

    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
    // https://github.com/mono/moon/blob/master/src/list.h#L87
    
    class Queue {
    protected:
            MoonMutex lock;
            List *list;
            
    public:
            Queue ();
            ~Queue ();
            
            // convenience properties
            bool IsEmpty ();
            int Length ();
            
            // convenience methods
            void Clear (bool freeNodes);
            
            void Push (List::Node *node);
            List::Node *Pop ();
            
            void Lock ();
            void Unlock ();
            
            // accessing the internal linked list directly requires manual Locking/Unlocking.
            List *LinkedList ();
    
            // copies the queue and empties the original
            void  MoveTo (Queue &queue);
    };
    
    // https://github.com/mono/moon/blob/master/src/list.cpp#L391
    
    Queue::Queue ()
      : lock (true)
    {
            list = new List ();
    }
    
    int
    Queue::Length ()
    {
            int length;
            
            Lock ();
            length = list->Length ();
            Unlock ();
            
            return length;
    }
    
    void
    Queue::MoveTo (Queue &queue)
    {
            List::Node *node;
            while ((node = list->First ())) {
                    list->Unlink (node);
                    queue.Push (node);
            }
    }

    Во имя луны!

    Xom94ok, 07 Января 2014

    Комментарии (93)
  6. Pascal / Говнокод #14321

    +148

    1. 1
    2. 2
    3. 3
    Милости прошу опробовать новую модификацию моего прокси-чекера:
    http://rghost.ru/51449039
    пароль на архив - ситэ; конкретно, то место, куда слетают все опубликованные пароли и учетки.

    Выражаю огромную благодарность более опытным товарищам, которые охотно шли мне навстречу, делясь опытом и указывая правильный путь.
    Я не могу не упомянуть имен этих замечательных людей:
    Bormand
    1024-
    Kegdan
    Anonimb

    Stertor, 06 Января 2014

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

    +27

    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
    int enumDevices(DevInfo* &lst) {
        int count = 0;
        DevInfo* tmp = NULL;
        Device device;
        for (int i = 0; i < MAXDEVICES; i++)
            if (device = OpenDevice(i)) {
                count++;
                realloc(tmp, sizeof(DevInfo)*count);
                ReadInfo(device, &tmp[count-1]
            }
        if (count == 0) return 0;
        lst = new DevInfo[count];
        for (int i = 0; i < count; i++)
            lst[i] = tmp[i];
        free(tmp);
        return count;
    }
    
    //................
    
    DevInfo* list;
    int devcount = enumDevices(list);
    /* работаем со списком */
    delete[] list;

    Самому стыдно.

    Vindicar, 06 Января 2014

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    // Сначала было 
    $result['routes'][0]['legs'][0]['start_address'].split(',');
    // Повтыкал с минуту, исправил на 
    $result['routes'][0]['legs'][0]['start_address'].explode(',');

    NodeJS головного мозга...

    nonamez, 06 Января 2014

    Комментарии (11)
  9. Pascal / Говнокод #14318

    +80

    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
    procedure WriteString(ST: Ansistring);
    var
      leng: dword;
      I: dword;
      ss: Ansistring;
      stk: Ansistring;
    begin
      leng := Length(ST);
      for I := 1 to leng do
      begin
        ss := Copy(ST, I, 1);
        stk := stk + ss;
      end;
      filestream1.Write(stk[1], Length(stk));
    end;

    Процедура записи строки в файл.
    Использование:

    var
    filestream1: TfileStream;

    begin
    filestream1 := TfileStream.Create('file.dat', fmcreate);
    WriteString('bla bla bla');
    filestream1.Destroy;
    end;

    ka3ax, 06 Января 2014

    Комментарии (216)
  10. Objective C / Говнокод #14315

    −87

    1. 1
    2. 2
    3. 3
    while ([self string:[commentText copy] containsString:@"<br>"]) {
                        commentText = [commentText stringByReplacingOccurrencesOfString:@"<br>" withString:@"/n"];
                    }

    No comments :)

    itruf, 04 Января 2014

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