1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #23601

    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
    if (!App.detection.browser_mobile && !App.detection.browser_tablet) {
      $('.hint', service_list_element)
      .on('mouseover', function() {
    
        var item = $(this),
        text = $('.text', item).text();
    
        if (text !== '' && !tooltip.visible) {
          tooltip.setTarget(item);
    
          tooltip.setData({
            'content' : text
          });
    
          tooltip.show();
        }
      })
      .on('mouseleave', function() {
        if (tooltip.visible) {
          tooltip.hide();
        }
      });
    }
    else {
      $('.hint', service_list_element)
      .on('pep_tap', function() {
        var item = $(this),
        text = $('.text', item).text();
    
        if (text !== '' && !tooltip.visible) {
          tooltip.setTarget(item);
    
          tooltip.setData({
            'content' : text
          });
    
          tooltip.show();
        }
      });
    }

    Если это десктоп, то при клике на иконку всплывает подсказка, но если это мобильник или планшет, то копипастим код с той же логикой, только с другим событием, которое эмулирует клик.

    Кажется парню платили за количество строк в коде =/

    MrFranke, 19 Декабря 2017

    Комментарии (1)
  3. PHP / Говнокод #23596

    −2

    1. 1
    2. 2
    <?php 
    while((!isset($i) ? $i = 1 : $i++ < rand(5, 10)) && $res = implode('-', $i%2==0 ? range($i, 1) : range(1, $i)) . "\n") echo $res;

    Прочитав статью https://habrahabr.ru/post/116842/, решил поговнокодидь

    Выводит:

    1
    2-1
    1-2-3
    4-3-2-1
    1-2-3-4-5
    6-5-4-3-2-1

    Это очень странно но я ухитрился засунуть все вычисления в условие цикла))

    slexx1234, 18 Декабря 2017

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

    0

    1. 1
    if (!($('.check-silver').css('display') == 'none' ))

    VoiceOfFate, 14 Декабря 2017

    Комментарии (1)
  5. Куча / Говнокод #23550

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    (* We open this module at the top of module generating rules, to make sure they don't do
       Io manually *)
    module No_io = struct
      module Io = struct end
    end

    https://github.com/janestreet/jbuilder/blob/0c2228e7bc7f5667a4ca2c982feb76130156ec99/src/import.ml#L524


    Монадки нинужны, говорили они

    roman-kashitsyn, 18 Ноября 2017

    Комментарии (1)
  6. PHP / Говнокод #23541

    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
    function numeral($s, $t1, $t3, $t5)
    {
    	$s = intval($s) % 100;
    	$z2 = intval($s / 10);
    	$z3 = $s % 10;
    	return ($z3 == 0) || ($z3 > 4) || ($z2 == 1)
    	       ? $t5
    	       : (($z3 > 1) && ($z3 < 5) ? $t3 : $t1);
    }
    
    function fileSizeInKB($size)
    {
        if ($size < 1024) {
            return intval($size) . '&nbsp;' . numeral($size, 'байт', 'байта', 'байтов');
        } else {
            $size /= 1024;
            if ($size < 1024)
                return intval($size) . '&nbsp;КБ';
            else
                return intval($size / 1024) . '&nbsp;МБ';
        }
    }

    high top pluralization method

    SeniorShaurman, 16 Ноября 2017

    Комментарии (1)
  7. Java / Говнокод #23533

    +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
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    ...
        private enum CSPTitle {
            CONTENT_SECURITY_POLICY, X_CONTENT_SECURITY_POLICY, X_WEBKIT_CSP;
    
            public String getName() {
                return WordUtils.capitalizeFully(this.name(), new char[] { '_' }).replace('_', '-');
            }
        }
    ...
       public Map<String, String> getHeaders(boolean disableXWebkitCspHeader, StringBuilder cspHeaderBodyBuilder){
            Map<String, String> cspHeaders = new HashMap<>();
            for (CSPTitle cspTitle : CSPTitle.values()) {
                if (disableXWebkitCspHeader && CSPTitle.X_WEBKIT_CSP.equals(cspTitle)) {
                    continue;
                }
    
                String cspHeaderBody = cspHeaderBodyBuilder.toString();
                if (CSPTitle.X_CONTENT_SECURITY_POLICY.equals(cspTitle)) {
                    cspHeaderBody = processXCSPHeader(cspHeaderBody);
                }
                cspHeaders.put(cspTitle.getName(), cspHeaderBody.trim());
            }
            return cspHeaders;
      }
    ....

    reizy, 14 Ноября 2017

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public ReadFile(string path)
    {
          byte[] BinFile = File.ReadAllBytes(path);
          if (((IEnumerable<byte>) BinFile).Count<byte>() <= 25)
            return;
          this._Version = BinFile[0].ToString() + "." + BinFile[1].ToString() + "." + BinFile[2].ToString();
    }

    Я вам тут израильского инжиниринга принёс. Читаем файл, читаем версию.
    В этом коде прекрасно всё...

    PsychoTeras, 14 Ноября 2017

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

    −2

    1. 1
    PHP - самое большое говно которое я встречал. Стив Джобс

    samopisiets, 09 Ноября 2017

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

    −6

    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
    #include <stdio.h>
    //аналог стрингбилдеру который есть в java!!!
    
    #define NUM 1000 //максимальный размер строки
    
    typedef struct {
    	char str[NUM];
    } StringBuilder;
    
    void append(StringBuilder *sb, char *str) //добавление строки
    {
    	sprintf(sb->str, "%s%s", sb->str, str); //гениально и просто хули
    }
    
    void setLength(StringBuilder *sb, int s)
    {
    	if(s > NUM || s < 0) return; //жуть
    	sb->str[s]='\0'; //гениальнетибл!
    }
    
    int main()
    {
    	StringBuilder sb;
    	sprintf(sb.str, "Привет америкосам");
    	printf("%s\n", sb.str);
    	append(&sb, ", я вас уделаю!");
    	printf("%s\n", sb.str);
    	setLength(&sb, 2);
    	printf("%s\n", sb.str);
    	setLength(&sb, 0);
    	printf("%s\n", sb.str);
    	return 0;
    }

    понос или не понос вот в чем вопрос

    pawn-master, 04 Ноября 2017

    Комментарии (1)
  11. Python / Говнокод #23458

    +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
    import os
    import argparse
    import sys
    parser = argparse.ArgumentParser(description='tree')
    parser.add_argument('path',type=str,)
    parser.add_argument('-fo','--folders_only',action='store_true',)
    parser.add_argument('-i','--include',type=str,action='store',)
    parser.add_argument('-e','--exclude',type=str,action='store',)
    parser.add_argument('-a','--all',action='store_true',)
    parser.add_argument('-f','--full_name',action='store_true',)
    args = parser.parse_args()
    print(sys.argv[1])
    if args.include:
        itext = args.include
    if args.exclude:
        etext = args.exclude
    def divine_crutch(path, n):
        dir = os.listdir(path)
        for i in range(len(dir)):
            if os.path.isfile(path + '\\' + dir[i]):
                if not(args.folders_only):
                    if not(args.include and itext not in dir[i]):
                        if not(args.exclude and etext in dir[i]):
                            if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
                                print(n*' ', dir[i])
                            elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
                                print(n*' ' ,path + '\\' + dir[i])
            if os.path.isdir(path + '\\' + dir[i]):
                if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
                    print(n*' ', dir[i])
                elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
                    print(n*' ' ,path + '\\' + dir[i])
                n += 4
                divine_crutch(path + '\\' + dir[i], n)
                n -= 4
    divine_crutch(sys.argv[1], 4)

    Рекурсивный велосипед на костыльной тяге. Сей экземпляр является "аналогом системной утилиты tree под линукс". При подходящей фазе луны и выполнении условий ритуала чёрной магии, способен захавать 16 гигов оперативки и крашнуть систему. Прекрасный способ выстрелить в ногу на питоне. Достойное место в моей кунсткамере.

    Caladrius, 26 Октября 2017

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