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

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

    +137.6

    1. 1
    w = (GtkWidget*)(*((int*)(lw->data)));

    Объект для медитаций

    mutanabbi, 13 Февраля 2010

    Комментарии (20)
  3. C++ / Говнокод #943

    +137.6

    1. 1
    struct X{template<class T>X(T);X g(){X(this->*&X::g);}};

    Короткая программа валит MSVC8 при компиляции

    guest, 24 Апреля 2009

    Комментарии (4)
  4. C# / Говнокод #906

    +137.6

    1. 1
    public static readonly int    daysIn2Weeks = 14;

    guest, 20 Апреля 2009

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

    +137.5

    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
    void TWindowTID::SetStyle(GtkWidget* widget, const char *form, gint Red_, gint Green_, gint Blue_)
    {
        struct _GtkStyle *style;
        GdkColor bg;
        style=gtk_style_new();
        bg.red = Red_;
        bg.blue = Blue_;
        bg.green = Green_;
        if (form=="TEXT")
        {
            style->fg[GTK_STATE_NORMAL]=bg; //TEXT
        }
        else
            if (form=="BORDER")
            {
                style->base[GTK_STATE_NORMAL]=bg; //BORDER
            }
            else
                if (form=="ALL")
                {
                    style->bg[GTK_STATE_NORMAL]=bg;
                    style->base[GTK_STATE_NORMAL]=bg; //BORDER
                    style->fg[GTK_STATE_NORMAL]=bg; //TEXT
                }
                else
                    if (form=="button")
                    {
                        style->bg[GTK_STATE_PRELIGHT]=bg;
                        style->base[GTK_STATE_PRELIGHT]=bg; //BORDER
                        style->bg[GTK_STATE_SELECTED]=bg;
                        style->base[GTK_STATE_SELECTED]=bg; //BORDER
                    }
                    else
                    {
                        style->bg[GTK_STATE_NORMAL]=bg;
                    }
        style->font = gdk_font_load("-adobe-helvetica-*-r-*-*-12-*-*-*-*-*-*-*");
        if ((GtkWidget *)widget!=NULL) gtk_widget_set_style((GtkWidget *)widget, style);
    }

    Сравнение строк умиляет

    mutanabbi, 12 Февраля 2010

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

    +137.5

    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
    function get($id,$lang_id)
         {
           // начнем транзакцию
           $bresult=ConnectionManager::begin();
           if (!$bresult)
            {
              ConnectionManager::rollback();
              return false;
            }
           $result=$this->db_main->getTPLRow(QUERY_ADMIN_CELLMETHOD_GET, array('id'=>$id,'lang_id'=>$lang_id));
           if (!is_array($result))
            {
              ConnectionManager::rollback();
              return false;
            }
           /*$operators=$this->db_main->getTPLData(QUERY_ADMIN_CELLMETHOD_OPETATORS_GET, array('id'=>$id));
           if (!is_array($operators))
            {
              ConnectionManager::rollback();
              return false;
            }
           $result['operator'] = $operators;*/
           // закончим транзакцию
           $cresult=ConnectionManager::commit();
           if (!$cresult)
            {
              ConnectionManager::rollback();
              return false;
            }
           if (count($result))
            return $result;
           else
            return true;
         }

    Метод получает данные из таблицы. getTPLRow делает выборку из таблицы, обратите внимание, что при этом делается begin, commit и rollback

    guest, 16 Апреля 2009

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

    +137.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
    private ArrayList GetSubscribers(string condition)
            {
               ArrayList subscribers = new ArrayList();
               ArrayList lst =  new user_category_notification().Factory.GetItems(condition, "user_category_notification.id_user");
                ArrayList distinc_lst = new ArrayList();
                ArrayList distinc_lst_ids = new ArrayList();
                ArrayList lst_ids = new ArrayList();
                for (int i = 0; i < lst.Count; i++)
                {
                    lst_ids.Add(((user_category_notification) lst[i]).id_user);
                }
                for (int i = 0; i < lst_ids.Count;i++ )
                {
                    if (distinc_lst_ids.Contains(lst_ids[i])) continue;
                    else
                    {
                        distinc_lst.Add(lst[i]);
                        distinc_lst_ids.Add(lst_ids[i]);
                    }
                }
                foreach (user_category_notification _un in distinc_lst)
                {
                    user _current = (user)new user().Factory.GetByID(_un.id_user);
                    subscribers.Add(_current);
                }
                
                return subscribers;
            }

    Филтрация :)

    bugotrep, 02 Октября 2009

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

    +137.1

    1. 1
    2. 2
    3. 3
    if (Skin == null || ((Skin != null && Skin.Value == null) || (Skin != null && Skin.Value != null && Skin.Value.Length == 0))) {
    				Skin = new LocalString("...");
    			}

    проверочко.. ^_^

    fade, 10 Августа 2009

    Комментарии (5)
  9. Си / Говнокод #18196

    +137

    1. 1
    printk(KERN_CRIT "AAA\n");

    Ебу и патчу.

    codemonkey, 18 Мая 2015

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

    +137

    1. 1
    2. 2
    3. 3
    static const uint32_t frequencies[] = {
    #include "frequencies.h"
    };

    codemonkey, 21 Апреля 2015

    Комментарии (27)
  11. C++ / Говнокод #17964

    +137

    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
    #include <iostream>
    
    template <typename T>
    struct Symbol {};
    
    template <>
    struct Symbol<int> {
        static constexpr const char value = 'd';
    };
    template <>
    struct Symbol<float> {
        static constexpr const char value = 'f';
    };
    
    template<std::size_t N, typename T>
    constexpr bool check_arg_part(const char (&s)[N], size_t i, T d)
    {
        if (i == N)
            return true;
    
        if (i < N - 1) {
            if (s[i] == '%') {
                if (s[i + 1] != Symbol<T>::value)
                    return false;
            }
        }
        return check_arg_part(s, i + 1, d);
    }
    
    template<std::size_t N, typename T>
    constexpr bool check_arg(const char (&s)[N], T d) {
        return check_arg_part(s, 0, d);
    }
    
    int main(int , char*[]) {
        std::boolalpha(std::cout);
    
    
        constexpr bool r = check_arg("foo is int: %d", 1);
        std::cout << "Argument integer is correct: " << r << std::endl;
        constexpr bool r1 = check_arg("foo is float:  %f", 1.0f);
        std::cout << "Argument float is correct: " << r1 << std::endl;
        constexpr bool r2 = check_arg("foo is float: %f", 1);
        std::cout << "Argument int is correct: " << r2 << std::endl;
    
        return 0;
    }

    По мотивам http://govnokod.ru/17925:

    Функция в compile time проверяет соответствие типов. Работает на clang и почему-то валится на gcc.

    gorthauer87, 09 Апреля 2015

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