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

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

    +117

    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
    if (!authorized)
    {
        // No, "I'm a teapot" is not what we really want, but the BuildMaster security module will
        // replace it with a 401 (which we actually want)
        context.Response.StatusCode = 418;
        context.Response.Write("Not authorized");
        context.Response.AddHeader("WWW-Authenticate", "Basic realm=\"BuildMaster URL Trigger\"");
        context.ApplicationInstance.CompleteRequest();
        return;
    }
    
    ...
    
    context.EndRequest += (s,e) =>
    {
        HttpApplication app = (HttpApplication)s;
        if (app.Context.Response.StatusCode == 418)
            app.Context.Response.StatusCode = 401;
    }

    http://blog.inedo.com/2010/10/12/http-418-im-a-teapot-finally-a-%E2%80%9Clegitimate%E2%80%9D-use/

    Костыль для обхода "шибко умного" поведения ASP.NET Forms Authentication, который меняет код 401 на 302-перенаправление на форму логина. А разработчику нужен именно 401.

    someone, 04 Июля 2013

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

    +15

    1. 1
    2. 2
    3. 3
    typedef std::intptr_t difference_type;
    //...
    const difference_type index_relative_unsigned=std::abs(index_relative);

    LispGovno, 04 Июля 2013

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <table width="630" border="1" class="main">
    
    <!-- Распирай. Властвуй. Унижай. -->
    <table border="1" width="800" class="main">
                
    <tr align="center"><td class="tds"> 
    ....
    </td></tr>
    </table></table>

    Цель была- просто впихнуть широкую таблицу, когда "голова", и кусок основной таблицы сайта (то, что до "распирай") отдаются скриптом. Дабы не вносить существенных поправок в движковую часть, и страницы- пришлось наговнокодить.

    lionovsky, 03 Июля 2013

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

    +130

    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
    * g o a t s e x * g o a t s e x * g o a t s e x *
    g                                               g  
    o /     \             \            /    \       o
    a|       |             \          |      |      a
    t|       `.             |         |       :     t
    s`        |             |        \|       |     s
    e \       | /       /  \\\   --__ \\       :    e
    x  \      \/   _--~~          ~--__| \     |    x  
    *   \      \_-~                    ~-_\    |    *
    g    \_     \        _.--------.______\|   |    g
    o      \     \______// _ ___ _ (_(__>  \   |    o
    a       \   .  C ___)  ______ (_(____>  |  /    a
    t       /\ |   C ____)/      \ (_____>  |_/     t
    s      / /\|   C_____)       |  (___>   /  \    s
    e     |   (   _C_____)\______/  // _/ /     \   e
    x     |    \  |__   \\_________// (__/       |  x
    *    | \    \____)   `----   --'             |  *
    g    |  \_          ___\       /_          _/ | g
    o   |              /    |     |  \            | o
    a   |             |    /       \  \           | a
    t   |          / /    |         |  \           |t
    s   |         / /      \__/\___/    |          |s
    e  |           /        |    |       |         |e
    x  |          |         |    |       |         |x
    * g o a t s e x * g o a t s e x * g o a t s e x *

    Stertor, 29 Июня 2013

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

    +29

    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
    //thirteen
            Cluster cl;
            Cluster empty;
            I--;
            if(distances.size()){
                for (int i = 0; i < (Lmax < distances.size() ? Lmax : distances.size()); ++i){
                    cl.X(( clusters.at(distances.at(i).first.first).X()*clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).X()*clusters.at(distances.at(i).first.second).Points().size())/(clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Points().size()));
                    cl.Y(( clusters.at(distances.at(i).first.first).Y()*clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Y()*clusters.at(distances.at(i).first.second).Points().size())/(clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Points().size()));
                    if(clusters.at(distances.at(i).first.second).Number() != -1 && clusters.at(distances.at(i).first.first).Number() != -2){
                        cl.Points() = clusters.at(distances.at(i).first.second).Points();
                        clusters.at(distances.at(i).first.second) = cl;
                        clusters.at(distances.at(i).first.second).Number(-1);
                        for (std::vector<Point>::iterator j = clusters.at(distances.at(i).first.first).Points().begin(); j != clusters.at(distances.at(i).first.first).Points().end(); ++j)
                        {
                        	clusters.at(distances.at(i).first.second).Points().push_back(*j);
                        }
                        clusters.at(distances.at(i).first.first) = empty;
                        n_c--;
                    }
                }
                for (std::vector<Cluster>::iterator i = clusters.begin(); i != clusters.end(); ++i){
                    if(i->Number() == -2){
                        i = clusters.erase(i);
                    }
                    i->Number(i - clusters.begin());
                    if(I)i->Points().clear();
                    if(i == clusters.end())break;
                }
            }
            //fourteen

    Кусок алгоритма isodata

    Abbath, 28 Июня 2013

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

    +150

    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
    //
        getMode: function(nMode) {
            switch (nMode) {
                case this.MODES.LEFT_BOOKEND:
                    return this.aModes[nMode];
                case this.MODES.RIGHT_BOOKEND:
                    return this.aModes[nMode];
                case this.MODES.BOTH_BOOKENDS:
                    return this.aModes[nMode];
                case this.MODES.NONE:
                default:
                    return this.aModes[this.MODES.NONE];
            }
        },

    Наверное уже боян, но вот же он, опять!

    https://github.com/scirelli/ExtjsBreadCrumbs/blob/master/js/ux/breadCrumbs.js

    Elvenfighter, 11 Июня 2013

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

    +63

    1. 1
    //START ADDING CODE HERE TODAY.  !!

    Прямо посреди класса

    myzone, 10 Июня 2013

    Комментарии (4)
  9. Куча / Говнокод #13105

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    try
    	HeapSize += 268435456 -- +100500 могучих байт в кучу во имя производительности
    catch (
    	try
    		HeapSize += 67108864 -- жалкая попытка добавить хоть что - то
    	catch
    		GIMS.Core.SystemMgr.ThrowError "init error" "Cannot extend the heap :(" -- сглотнуть обиду, поднасрав в лог
    )

    GC, you shall not pass!
    Первая ступень попыток ускорить тормозной MAXScript

    3Doomer, 04 Июня 2013

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    switch ($isBlank) {
        case true:
            $seconds_to_cache = 1;
            break;
        case false:
            $seconds_to_cache = 100000000;
            break;
    }

    еще default: не хватает для полной красоты...

    DemoniacDeath, 03 Июня 2013

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

    −105

    1. 1
    if(ignoreSelection?[atml extraCharges]!=NULL:[atml extraCharges]&&![atml selectedAttribute])

    Лесенки для слабаков!!

    Psionic, 31 Мая 2013

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