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

    +148

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

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

    Stertor, 06 Января 2014

    Комментарии (32)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. Pascal / Говнокод #14314

    +84

    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
    function Okruglenije(cislo: Currency; skolkonulei: Integer): string;
    var
    
      outs: string;
      rst, cel, zn: string;
      p: integer;
    begin
      outs := FloatToStr(cislo);
    
      p := Pos(',', outs) + 1;
    
      zn := Copy(outs, p, skolkonulei);
    
      cel := FloatToStr(trunc(cislo));
    
      if p > 1 then
        rst := Trim(cel + ',' + zn)
    
      else
        rst := Trim(cel);
    
      Okruglenije := rst;
    
    end;

    Процедура округления

    ka3ax, 04 Января 2014

    Комментарии (81)
  9. Objective C / Говнокод #14313

    −95

    1. 1
    [dic setObject:[NSNumber numberWithInt:TWITTER] forKey:@"source"];

    Как можно простые вещи сделать сложными.
    Эквивалентно: dict[@"source"] = @(TWITTER);

    Dmitriy, 03 Января 2014

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

    −104

    1. 1
    return (loginLength * passwordLength) > 0 ? YES:NO;

    А вдруг?

    Dmitriy, 03 Января 2014

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