1. C# / Говнокод #1790

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public void onApplicationStateChanged(int state)
    {
                if (state == Application.APPSTATE_UNINITIALIZED)
                {
                           // TODO: what to do?
                }
    }

    Чувак начал писать и забыл о чем...

    vassabi, 08 Сентября 2009

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

    −176.1

    1. 1
    ДатаНачалаПериода = НачалоМесяца(Дата(Строка(Формат(ТекущийГод, "ЧГ=0")) + Строка(ТекущийМесяц) + "01"));

    Фрагмент кода от разработчиков конфигурации. Дело в том, что дату начала текущего месяца можно получить как НачалоМесяца(ТекущаяДата()). Даже если предположить, что переменные "ТекущийГод" и "ТекущийМесяц" содержат не актуальные значения (например, при перерасчете прошлых документов), достаточно выполнить НачалоМесяца(Дата(ТекущийГод, ТекущийМесяц, 1))

    polestnize, 08 Сентября 2009

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

    +166.8

    1. 1
    unset($keys[count($keys)-1][count($keys[count($keys)-1])-1]);

    stepushyn, 07 Сентября 2009

    Комментарии (6)
  4. Java / Говнокод #1787

    +75.3

    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
    public static ru.project.subpackage.PersonDTO convertOshPersonDtoToPersonDto(OshPersonDTO person){
            ru.project.subpackage.PersonDTO dto = new ru.project.subpackage.PersonDTO();
            dto.setPersonid(person.getPersonid().longValue());
            dto.setNamelast(person.getNamelast());
            dto.setNamefirst            (person.getNamefirst            ());
            dto.setNamesec              (person.getNamesec              ());
            dto.setInitials             (person.getInitials             ());
            dto.setSex                  (convertSkVocValue(person.getSex()));
            dto.setReason               (person.getReason               ());
            dto.setWorkphone            (person.getWorkphone            ());
            dto.setWorkphonedigit       (person.getWorkphonedigit       ());
            dto.setLocalphone           (person.getLocalphone           ());
            dto.setLocalphonedigit      (person.getLocalphonedigit      ());
            dto.setHomephone            (person.getHomephone            ());
            dto.setHomephonedigit       (person.getHomephonedigit       ());
            dto.setMobilephone          (person.getMobilephone          ());
            dto.setMobilephonedigit     (person.getMobilephonedigit     ());
            dto.setFax                  (person.getFax                  ());
            dto.setFaxdigit             (person.getFaxdigit             ());
            dto.setPager                (person.getPager                ());
            dto.setEmail                (person.getEmail                ());
            dto.setWeb                  (person.getWeb                  ());
            dto.setNamelastdative       (person.getNamelastdative       ());
            dto.setNamefirstdative      (person.getNamefirstdative      ());
            dto.setNamesecdative        (person.getNamesecdative        ());
            dto.setNamelastaccusative   (person.getNamelastaccusative   ());
            dto.setNamefirstaccusative  (person.getNamefirstaccusative  ());
            dto.setNamesecaccusative    (person.getNamesecaccusative    ());
            dto.setNamelastgenitive     (person.getNamelastgenitive     ());
            dto.setNamefirstgenitive    (person.getNamefirstgenitive    ());
            dto.setNamesecgenitive      (person.getNamesecgenitive      ());
            dto.setNamelastinstrumental (person.getNamelastinstrumental ());
            dto.setNamefirstinstrumental(person.getNamefirstinstrumental());
            dto.setNamesecinstrumental  (person.getNamesecinstrumental  ());
            dto.setNamelastprepositional(person.getNamelastprepositional());
            dto.setNamefirstprepositional(person.getNamefirstprepositional());
            dto.setNamesecprepositional (person.getNamesecprepositional ());
            return dto;
        }

    И так далее еще несколько сотен строк. А главное переупаковка из одних объектов в другие и обратно бессмысленна, т.к. можно использовать исходные (они доступны в приложении)

    johnsoft, 07 Сентября 2009

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

    +82.7

    1. 1
    2. 2
    3. 3
    4. 4
    public static boolean isUnix()
        {
            return System.getProperty("file.separator").equals("/");
        }

    johnsoft, 07 Сентября 2009

    Комментарии (16)
  6. Java / Говнокод #1785

    +71.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    /**
         * Возбуждает IllegalArgumentException если аргумент null.
         * Формирует сообщение об ошибке с именем условия.
         *
         * @param argument     проверяемый аргумент
         * @param argumentName имя аргумента
         */
        public static void ensureNotNull(Object argument, String argumentName) {
            if (argument == null) {
                throw new IllegalArgumentException("Null '" + argumentName + "' not allowed.");
            }
        }

    johnsoft, 07 Сентября 2009

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

    +83.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /**
         * проебразует объект <code>o</code> в объект
         *
         * @param o объект
         * @return объект со значением <code>o</code>
         */
        public static Object toObject(Object o) {
            return o;
        }

    Полное отсутствие знаний основ java

    johnsoft, 07 Сентября 2009

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

    +190.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
    // register.php
    
    // ...
    
    $login = $_POST["login"];
       
    // some checks...
       
    $sql = "CREATE TABLE `$login` (
            `city` TINYINT UNSIGNED NOT NULL ,
            // other fields here...
            );";

    Из модуля регистрации в системе удаленного ввода данных через web. После сохранения информации о новом пользователе для него создается новая таблица для хранения вводимых данных...

    Больше слов нет...

    Andrey_Beletsky, 07 Сентября 2009

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

    +127

    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
    /// <summary>
        ///  Retrieve currency rates from an external site to be sure they are up to date.
        /// In this case just checking the one currency (Australian Dollar) so no need to dynamically parse the site.
        /// </summary>
        /// <returns>currency rates or msg indicating an error</returns>
        private String getCurrencyRates()
        {
            string strURL = @"http://www.x-rates.com/d/JPY/table.html";
            HttpWebRequest txtRequest = (HttpWebRequest)WebRequest.Create(strURL);
    
            txtRequest.Method = "GET";
            txtRequest.ContentType = "application/x-www-form-urlencoded";
            string response;
            using (StreamReader streamReader = new StreamReader(txtRequest.GetResponse().GetResponseStream()))
            {
                response = streamReader.ReadToEnd();
                if (response.IndexOf("Australian Dollar") > 0)
                {
                    //parse the returned page for the two values of the currency rate based on the existing design
                    int ind_jpy = (response.IndexOf("/d/AUD/JPY/graph120.html") + 39);
                    int ind_aud = (response.IndexOf("/d/JPY/AUD/graph120.html") + 39);
                    String jpy_aud = response.Substring(ind_jpy, (response.IndexOf("</a>",ind_jpy) - ind_jpy) );
                    String aud_jpy = response.Substring(ind_aud, (response.IndexOf("</a>", ind_aud) - ind_aud));
                    Session["curr_rate"] = "set";
                    Session["JPY"] = jpy_aud;
                    Session["AUD"] = aud_jpy;
                    return aud_jpy + " / " + jpy_aud;
                }
                //else present msg to user that unable to obtain currency rates
            }
            return "";
        }

    Еще один кандидат

    OlgaWolga, 07 Сентября 2009

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

    +135.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
    public string GetDollarKurs(string input)
    {
        string dol = "[.\\s]*<img height=\"11\" alt=\"Доллар США\" hspace=\"2\" src=\"/images/icon_dollar.gif\" width=\"11\" align=\"left\" vspace=\"2\" border=\"0\">Доллар \r\n\t\t\tСША</td>\r\n\t\t<td></td>\r\n\t\t<td class=\"digit\" align=\"right\">[\\s]*\\d+\\,\\d+[.\\s]*";
        MatchCollection Matches = Regex.Matches(input, dol);
        if (Matches.Count == 1)
        {
            string res = Matches[0].Value;
            res = res.Trim();
            res = res.Substring(res.LastIndexOf('>') + 1);
            return res;
        }
        else
            return "";
    }

    Функция для получения курса доллара, в input подаётся хтмл главной страницы сайта cbr.ru и парсится.
    А web-сервисы пусть кто-нибудь другой изучает... :o)

    Ordos, 06 Сентября 2009

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