1. JavaScript / Говнокод #2918

    +163.4

    1. 1
    $(this).parents('li:first').parents('li:first').parents('li:first').parents('li:first').parents('li:first').attr('class', 'Node ExpandOpen IsLast');

    ну как прикажите до 8го элемента вверх по DOM прогуляться иначе? О_о
    ЗЫ период владение Jquery = 1 дьень и 24 часа из суток

    lener, 02 Апреля 2010

    Комментарии (25)
  2. PHP / Говнокод #2917

    +166

    1. 1
    $limit = (isset($this->params['pass'][1]) == 'news')?null:5;

    балина, и это работает :D

    lener, 02 Апреля 2010

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

    +67.4

    1. 1
    2. 2
    Apache POI
    The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)

    Не говнокод, но официальное название формата доставляет :)

    zlob.jc, 02 Апреля 2010

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

    +144.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
    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
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    /**
     * Helper classes for computing window query on rectangles
     */
    
    class VerticalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentIntersect ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        
        return 1;
      }
    };
    
    class HorisontalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentIntersect ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        return 1;
      }
    };
    
    /**
     * Helper classes for computing containment query on rectangles
     */ 
    
    class VerticalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentContains ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    class HorisontalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentContains ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    // compute the window query on m_GlyphData rectangles
      QVector<PRGlyph> :: iterator windowq = m_Selection.isValid() ?
                                            std::partition ( m_GlyphData.begin(),
                                                             std::partition ( m_GlyphData.begin(), m_GlyphData.end(), VerticalSegmentIntersect ( m_Selection.top(), m_Selection.bottom() ) ),
                                                             HorisontalSegmentIntersect ( m_Selection.left(), m_Selection.right() )
                                                           ) : m_GlyphData.begin();
      // compute the containment query on window query rectangles (the containment query resuls is always subset of window query )
      QVector<PRGlyph> :: iterator containq = std::partition ( m_GlyphData.begin(),
                                                               std::partition ( m_GlyphData.begin(), windowq, VerticalSegmentContains ( m_Selection.top(), m_Selection.bottom() ) ),
                                                               HorisontalSegmentContains ( m_Selection.left(), m_Selection.right() )
                                                             );

    Способ быстренько находить прямоугольники, пересекающиеся с входным и содержимые им же. Применимо для прямоугольных параллелепипедов любой размерности.

    ngry, 01 Апреля 2010

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

    +912.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
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int n;
        cin>>n;
        if(n==1) cout<<"A";
        if(n==2) cout<<"B";
        if(n==3) cout<<"AB";
        if(n==4) cout<<"BAB";
        if(n==5) cout<<"ABBAB";
        if(n==6) cout<<"BABABBAB";
        if(n==7) cout<<"ABBABBABABBAB";
        if(n==8) cout<<"BABABBABABBABBABABBAB";
        if(n==9) cout<<"ABBABBABABBABBABABBABABBABBABABBAB";
        if(n==10) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==11) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==12) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==13) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==14) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==15) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        return 0;
    }

    строки Фибаначи. (=

    winprogrammer, 01 Апреля 2010

    Комментарии (32)
  6. JavaScript / Говнокод #2913

    +169.4

    1. 1
    if (!jQuery) $('<scr' + 'ipt src="/jquery.js" type="text/javascript"></scr' + 'ipt>');

    eval, 01 Апреля 2010

    Комментарии (24)
  7. SQL / Говнокод #2912

    −857

    1. 1
    2. 2
    SELECT * FROM [dbo].[Publications]												
    where [UserId] not like 'NULL'

    UserId, естественно, int

    synapse, 01 Апреля 2010

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

    +148.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var tbl = order.group != 0 ?
       (order.group != 1 ?
        limit :
        closed) :
       open;

    asilmacc, 01 Апреля 2010

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

    +162.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
    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
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    <?php
    
    
    if($_GET['id'] == 10 ){
    
    $location = "/articles/lyustry/lustra-na-kuhne/";
    }elseif($_GET['id'] == 13 and $_GET['id_type'] == 17){
    $location = "/market/interernye_svetilniki/lyustry/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 22 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bolshie_lyustry/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 34 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/lyustry/bolee_6_rozhkov/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 2 ){
    $location = "/market/interernye_svetilniki/podvesnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 40 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/podvesnye/odinochnyj_podves/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 41 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/podvesnye/trojnoj_i_bolee/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 5 ){
    $location = "/market/interernye_svetilniki/nastenno-potolochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 35 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/potolochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 52 ){
    $location = "/market/interernye_svetilniki/vlagozawitnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 51 ){
    $location = "/market/interernye_svetilniki/podsvetka_kartin/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 7 ){
    $location = "/market/interernye_svetilniki/bra/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 37 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/odnorozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 38 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/dvuhrozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 39 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/treh_i_bolee_rozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 1 ){
    $location = "/market/interernye_svetilniki/tochechnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 42 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/odinochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 43 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/dvojnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 44 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/tri_i_bolee/";
    }
    elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 8){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 46 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/ofisnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 47 and $_GET['act'] == 'sub_
    type'){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/prikrovatnye_domashnie_ili_interernye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 6 ){
    $location = "/market/interernye_svetilniki/torshery/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 9 ){
    $location = "/market/ulichnye_svetilniki/";
    }...
    И так далее..

    Клиент поставил нашу CMS, на старой были ссылки типа /?id=10 и т.д. Сделал ему для примера скрипт редиректа с использованием switch case и вот что я увидел через две недели 0_0 Неприкрытый говнокод.

    VeroLom, 01 Апреля 2010

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

    +122.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
    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
    string[] mas_param = a.Split('_');
                this.s_sw_neraspred = mas_param[15];
                s_neraspred.Text = this.s_sw_neraspred;
                int i = a.IndexOf("_", 0, a.Length);
                sw_id = a.Substring(0, i);
                int j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_id = a.Substring(j, i - j);
                //mf1=a.Substring(j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_ed = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                this.s_op = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_ed = a.Substring(j, i - j);
                //mf_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_topsw = a.Substring(j, i - j);
                //s_op_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_op_topsw = a.Substring(j, i - j);
                //s_rm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm_topsw = a.Substring(j, i - j);
                //s_tm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm_topsw = a.Substring(j, i - j);
                //s_sw_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw_topsw = a.Substring(j, i - j);            
            
    
                //ta
    
                ta_id = a.Split('_')[mas_param.Length-1];

    a - строка вида
    {0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_ {10}_{11}_{12}_{13}_{14}_{15}_{16}

    alex_donetsk, 01 Апреля 2010

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