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

    −364

    1. 1
    Если (ДатаГод(ДатаДок) < 2010) ИЛИ (ДатаГод(ДатаДок) < 2010 ) Тогда

    Строка кода из типовой конфигурации 1С: Бухгалтерия 7.7, релиз 522
    No comments ...

    manan, 10 Февраля 2011

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

    +124

    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
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
    
    ;;; Copyright (C) 2011, Dmitry Ignatiev <[email protected]>
    
    ;;; Permission is hereby granted, free of charge, to any person
    ;;; obtaining a copy of this software and associated documentation
    ;;; files (the "Software"), to deal in the Software without
    ;;; restriction, including without limitation the rights to use, copy,
    ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
    ;;; of the Software, and to permit persons to whom the Software is
    ;;; furnished to do so, subject to the following conditions:
    
    ;;; The above copyright notice and this permission notice shall be
    ;;; included in all copies or substantial portions of the Software.
    
    ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    ;;; NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    ;;; DEALINGS IN THE SOFTWARE
    
    (in-package #:neural-flow)
    
    ;; Stolen from `trivial-garbage'
    
    #+openmcl
    (defvar *weak-pointers* (cl:make-hash-table :test 'eq :weak :value))
    
    #+(or allegro openmcl lispworks)
    (defstruct (weak-pointer (:constructor %make-weak-pointer))
      #-openmcl pointer)
    
    (declaim (inline make-weak-pointer))
    (defun make-weak-pointer (object)
      #+sbcl (sb-ext:make-weak-pointer object)
      #+(or cmu scl) (ext:make-weak-pointer object)
      #+clisp (ext:make-weak-pointer object)
      #+ecl (ext:make-weak-pointer object)
      #+allegro
      (let ((wv (excl:weak-vector 1)))
        (setf (svref wv 0) object)
        (%make-weak-pointer :pointer wv))
      #+openmcl
      (let ((wp (%make-weak-pointer)))
        (setf (gethash wp *weak-pointers*) object)
        wp)
      #+corman (ccl:make-weak-pointer object)
      #+lispworks
      (let ((array (make-array 1)))
        (hcl:set-array-weak array t)
        (setf (svref array 0) object)
        (%make-weak-pointer :pointer array)))
    
    (declaim (inline weak-pointer-value))
    (defun weak-pointer-value (weak-pointer)
      "If WEAK-POINTER is valid, returns its value. Otherwise, returns NIL."
      #+sbcl (values (sb-ext:weak-pointer-value weak-pointer))
      #+(or cmu scl) (values (ext:weak-pointer-value weak-pointer))
      #+clisp (values (ext:weak-pointer-value weak-pointer))
      #+ecl (values (ext:weak-pointer-value weak-pointer))
      #+allegro (svref (weak-pointer-pointer weak-pointer) 0)
      #+openmcl (values (gethash weak-pointer *weak-pointers*))
      #+corman (ccl:weak-pointer-obj weak-pointer)
      #+lispworks (svref (weak-pointer-pointer weak-pointer) 0))
    
    ;;Red-black tree
    
    (declaim (inline %node %nleft %nright %nparent %nred %ndata %ncode
                     (setf %nleft) (setf %nright) (setf %nparent)
                     (setf %nred) (setf %ndata) (setf %ncode)))
    (defstruct (%node (:constructor %node (data code parent red))
                      (:conc-name %n))
      (left nil :type (or null %node))
      (right nil :type (or null %node))
      (parent nil :type (or null %node))
      (red nil)
      data
      (code 0 :type (integer 0 #.most-positive-fixnum)))
    
    (declaim (inline %tree %tree-root (setf %tree-root)))
    (defstruct (%tree (:constructor %tree ())
                      (:copier %copy-tree))
      (root nil :type (or null %node)))
    
    (declaim (inline rotate-left))
    (defun %rotate-left (tree node)
      (declare (type %tree tree) (type %node node)
               (optimize (speed 3) (safety 0)))
      (let ((right (%nright node)))
        (when (setf (%nright node) (%nleft right))
          (setf (%nparent (%nleft right)) node))
        (if (setf (%nparent right) (%nparent node))
          (if (eq node (%nleft (%nparent node)))
            (setf (%nleft (%nparent node)) right)
            (setf (%nright (%nparent node)) right))
          (setf (%tree-root tree) right))

    Вылезли глаза! Как на этом можно писать?

    vertexua, 10 Февраля 2011

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

    +177

    1. 1
    auto r=disable(reinterpret_cast<void*>(static_cast<Efrag*>(const_cast<Efrig*>(ef))));

    Три мудреца в одном тазу
    Пустились по морю в грозу.
    Будь попрочнее старый таз,
    Длиннее был бы мой рассказ.
    ..............Самуил Маршак

    Говногость, 10 Февраля 2011

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

    +147

    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
    #include <stdio.h>
    int main(int t,int _,char*a)
    {return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
    main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
    )&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
    t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
    ,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
    +k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
    l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
    n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
    ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
    #'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
    :t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
    +1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
    i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

    Консольный вывод этой программы:
    On the first day of Christmas my true love gave to me
    a partridge in a pear tree.

    On the second day of Christmas my true love gave to me
    two turtle doves
    and a partridge in a pear tree.

    ...
    [Все не вместилось]
    ...

    On the tenth day of Christmas my true love gave to me
    ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the eleventh day of Christmas my true love gave to me
    eleven pipers piping, ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    On the twelfth day of Christmas my true love gave to me
    twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
    nine ladies dancing, eight maids a-milking, seven swans a-swimming,
    six geese a-laying, five gold rings;
    four calling birds, three french hens, two turtle doves
    and a partridge in a pear tree.

    Говногость, 10 Февраля 2011

    Комментарии (21)
  5. PHP / Говнокод #5624

    +172

    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
    /* Теперь задаём сами функции перекодировки translita в кириллицу и обратно. Вот код: */
    
    function ruslat ($string) # Задаём функцию перекодировки кириллицы в транслит.
    {
    $string = ereg_replace("ж","zh",$string);
    $string = ereg_replace("ё","yo",$string);
    $string = ereg_replace("й","i",$string);
    $string = ereg_replace("ю","yu",$string);
    $string = ereg_replace("ь","'",$string);
    $string = ereg_replace("ч","ch",$string);
    $string = ereg_replace("щ","sh",$string);
    $string = ereg_replace("ц","c",$string);
    $string = ereg_replace("у","u",$string);
    $string = ereg_replace("к","k",$string);
    $string = ereg_replace("е","e",$string);
    $string = ereg_replace("н","n",$string);
    $string = ereg_replace("г","g",$string);
    $string = ereg_replace("ш","sh",$string);
    $string = ereg_replace("з","z",$string);
    $string = ereg_replace("х","h",$string);
    $string = ereg_replace("ъ","''",$string);
    $string = ereg_replace("ф","f",$string);
    $string = ereg_replace("ы","y",$string);
    $string = ereg_replace("в","v",$string);
    $string = ereg_replace("а","a",$string);
    $string = ereg_replace("п","p",$string);
    $string = ereg_replace("р","r",$string);
    $string = ereg_replace("о","o",$string);
    $string = ereg_replace("л","l",$string);
    $string = ereg_replace("д","d",$string);
    $string = ereg_replace("э","yе",$string);
    $string = ereg_replace("я","jа",$string);
    $string = ereg_replace("с","s",$string);
    $string = ereg_replace("м","m",$string);
    $string = ereg_replace("и","i",$string);
    $string = ereg_replace("т","t",$string);
    $string = ereg_replace("б","b",$string);
    $string = ereg_replace("Ё","yo",$string);
    $string = ereg_replace("Й","I",$string);
    $string = ereg_replace("Ю","YU",$string);
    $string = ereg_replace("Ч","CH",$string);
    $string = ereg_replace("Ь","'",$string);
    $string = ereg_replace("Щ","SH'",$string);
    $string = ereg_replace("Ц","C",$string);
    $string = ereg_replace("У","U",$string);
    $string = ereg_replace("К","K",$string);
    $string = ereg_replace("Е","E",$string);
    $string = ereg_replace("Н","N",$string);
    $string = ereg_replace("Г","G",$string);
    $string = ereg_replace("Ш","SH",$string);
    $string = ereg_replace("З","Z",$string);
    $string = ereg_replace("Х","H",$string);
    $string = ereg_replace("Ъ","''",$string);
    $string = ereg_replace("Ф","F",$string);
    $string = ereg_replace("Ы","Y",$string);
    $string = ereg_replace("В","V",$string);
    $string = ereg_replace("А","A",$string);
    $string = ereg_replace("П","P",$string);
    $string = ereg_replace("Р","R",$string);
    $string = ereg_replace("О","O",$string);
    $string = ereg_replace("Л","L",$string);
    $string = ereg_replace("Д","D",$string);
    $string = ereg_replace("Ж","Zh",$string);
    $string = ereg_replace("Э","Ye",$string);
    $string = ereg_replace("Я","Ja",$string);
    $string = ereg_replace("С","S",$string);
    $string = ereg_replace("М","M",$string);
    $string = ereg_replace("И","I",$string);
    $string = ereg_replace("Т","T",$string);
    $string = ereg_replace("Б","B",$string);
    return $string;
    }

    Нашел сие чудо на: http://protoplex.ru/lib/?showid=89

    code_master, 10 Февраля 2011

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

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    template<class Exception>
    bool GenerateException(const Exception* const e)
    {
    	throw e;
    	delete e;
    	return true;
    }

    Продолжение цикла говнокодов про исключения из того же самого проекта.
    Проблем от неё почти нет, тк в основном исключения генерятся так:

    ExceptionТакойто e;
    GenerateException(&e);

    Говногость, 10 Февраля 2011

    Комментарии (11)
  7. PHP / Говнокод #5622

    +166

    1. 1
    2. 2
    $pif=explode('?',$_SERVER['REQUEST_URI']);
    $tym=explode('=',$pif[1]);

    Вот такой вот способ получить значение переменной из GET запроса вида:
    http://127.0.0.1/component/index.php?name=r37.edoc

    isergey, 10 Февраля 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    $p = array(1,0,0,0,0,0,0,0,0,0); // вероятность 1/10
    $a = array();
    for($i=0; $i<100; $i++) 
    	$a[] = $p[mt_rand(0, count($p)-1)];

    Это — заполнение массива случайными значениями с заданной вероятностью 1 к 10. =)

    Kevin, 10 Февраля 2011

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

    +164

    1. 1
    2. 2
    RewriteRule ^tn_([0-9]*)x([0-9]*)_([a-z]+)_([0-9]*)_([0-9]+)_(.*)_([c]*)_([f]*)_([0-9]*).[a-z]*$ перенос
    /index.php?exception=imageModification&width=$1&height=$2&module=$3&id=$4&time=$5&name=$6&crop=$7&force=$8&query=$9&file_name=%{REQUEST_URI} [L]

    В .htaccess:
    Победа над ресайзом картинок. Чуваки еще не успели ощутить на себе всю мощь ананимуса

    ifeya, 10 Февраля 2011

    Комментарии (3)
  10. SQL / Говнокод #5619

    −178

    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
    SELECT DISTINCT BE.ID as ID,BE.NAME as NAME,BE.IBLOCK_ID as IBLOCK_ID,BE.IBLOCK_SECTION_ID as IBLOCK_SECTION_ID, FPEN0.VALUE as PROPERTY_TYPE_LAMP_VALUE, FPEN0.ID as PROPERTY_TY
    PE_LAMP_ENUM_ID, FPV0.ID as PROPERTY_TYPE_LAMP_VALUE_ID, FPEN1.VALUE as PROPERTY_STYLE_VALUE, FPEN1.ID as PROPERTY_STYLE_ENUM_ID, FPV1.ID as PROPERTY_STYLE_VALUE_ID,BE.PREVIEW_PICTURE as PREVIEW_PICTURE, FPEN2.VALUE as PROPERTY_SERIES_VALUE, FPEN2.ID as PROPERTY_SERIES_ENUM_ID, FPV2.ID as PROPERTY_SERIES_VALUE_ID, FPEN3.VALUE as PROPERTY_COLOR_ARMAT_VALUE, FPEN3.ID as PROPERTY_COLOR_ARMAT_ENUM_ID, FPV3.ID as PROPERTY_COLOR_ARMAT_VALUE_ID, FPEN4.VALUE as PROPERTY_COLOR_PLAFON_VALUE, FPEN4.ID as PROPERTY_COLOR_PLAFON_ENUM_ID, FPV4.ID as PROPERTY_COLOR_PLAFON_VALUE_ID, FPEN5.VALUE as PROPERTY_NEW_VALUE, FPEN5.ID as PROPERTY_NEW_ENUM_ID, FPV5.ID as PROPERTY_NEW_VALUE_ID, FPEN6.VALUE as PROPERTY_SALE_VALUE, FPEN6.ID as PROPERTY_SALE_ENUM_ID, FPV6.ID as PROPERTY_SALE_VALUE_ID , CAT_P1.ID as CATALOG_PRICE_ID_1,  CAT_P1.CATALOG_GROUP_ID as CATALOG_GROUP_ID_1,  CAT_P1.PRICE as CATALOG_PRICE_1,  CAT_P1.CURRENCY as CATALOG_CURRENCY_1,  CAT_P1.QUANTITY_FROM as CATALOG_QUANTITY_FROM_1,  CAT_P1.QUANTITY_TO as CATALOG_QUANTITY_TO_1,  '<C1><E0><E7><EE><E2><E0>
    <FF> <F6><E5><ED><E0>' as CATALOG_GROUP_NAME_1,  'Y' as CATALOG_CAN_ACCESS_1,  'Y' as CATALOG_CAN_BUY_1,  CAT_P1.EXTRA_ID as CATALOG_EXTRA_ID_1, CAT_PR.QUANTITY as CATALOG_QUANTITY,  CAT_PR.QUANTITY_TRACE as CATALOG_QUANTITY_TRACE,  CAT_PR.WEIGHT as CATALOG_WEIGHT,  CAT_VAT.RATE as CATALOG_VAT,  CAT_PR.VAT_INCLUDED as CATALOG_VAT_INCLUDED,  CAT_PR.PRICE_TYPE as CATALOG_PRICE_TYPE,  CAT_PR.RECUR_SCHEME_TYPE as CATALOG_RECUR_SCHEME_TYPE,  CAT_PR.RECUR_SCHEME_LENGTH as CATALOG_RECUR_SCHEME_LENGTH,  CAT_PR.TRIAL_PRICE_ID as CATALOG_TRIAL_PRICE_ID,  CAT_PR.WITHOUT_ORDER as CATALOG_WITHOUT_ORDER,  CAT_PR.SELECT_BEST_PRICE as CATALOG_SELECT_BEST_PRICE
    FROM b_iblock B
    INNER JOIN b_lang L ON B.LID=L.LID
    INNER JOIN b_iblock_element BE ON BE.IBLOCK_ID = B.ID
    LEFT JOIN b_iblock_property FP0 ON FP0.IBLOCK_ID = B.ID AND  FP0.CODE='TYPE_LAMP'
    INNER JOIN b_iblock_property FP1 ON FP1.IBLOCK_ID = B.ID AND  FP1.CODE='STYLE'
    INNER JOIN b_iblock_property FP2 ON FP2.IBLOCK_ID = B.ID AND  FP2.CODE='SERIES'
    LEFT JOIN b_iblock_property FP3 ON FP3.IBLOCK_ID = B.ID AND  FP3.CODE='COLOR_ARMAT'
    LEFT JOIN b_iblock_property FP4 ON FP4.IBLOCK_ID = B.ID AND  FP4.CODE='COLOR_PLAFON'
    LEFT JOIN b_iblock_property FP5 ON FP5.IBLOCK_ID = B.ID AND  FP5.CODE='NEW'
    LEFT JOIN b_iblock_property FP6 ON FP6.IBLOCK_ID = B.ID AND  FP6.CODE='SALE'
    /*... тут еще 14 джоинов ...*/
    INNER JOIN (
    	SELECT DISTINCT BSE.IBLOCK_ELEMENT_ID
    	FROM b_iblock_section_element BSE
    
    	INNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID
    
    	WHERE (((BS.ID = 25)))
    	) BES ON BES.IBLOCK_ELEMENT_ID = BE.ID
    LEFT JOIN b_catalog_price CAT_P1 ON (CAT_P1.PRODUCT_ID = BE.ID AND CAT_P1.CATALOG_GROUP_ID = 1)
    LEFT JOIN b_catalog_product CAT_PR ON (CAT_PR.ID = BE.ID)
    LEFT JOIN b_catalog_iblock CAT_IB ON ((CAT_PR.VAT_ID IS NULL OR CAT_PR.VAT_ID = 0) AND CAT_IB.IBLOCK_ID = BE.IBLOCK_ID)
    LEFT JOIN b_catalog_vat CAT_VAT ON (CAT_VAT.ID = IF((CAT_PR.VAT_ID IS NULL OR CAT_PR.VAT_ID = 0), CAT_IB.VAT_ID, CAT_PR.VAT_ID))
    WHERE 1=1
    AND ( 13:19 
    ((((BE.IBLOCK_ID = '3'))))
    	AND ((((BE.ACTIVE='Y'))))
    	AND (
    		(
    		((((CAT_P1.PRICE >= '386'))))
    		)
    		AND (
    		((((CAT_P1.PRICE <= '4166'))))
    		)
    	)
    	AND ((((CAT_PR.QUANTITY > '0'))))
    	AND ((((FPEN1.VALUE LIKE '<CA><EB><E0><F1><F1><E8><F7><E5><F1><EA><E8><E9>'))))
    	AND ((((FPEN2.VALUE LIKE 'Davoli'))))
    )
    AND (((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL)));

    Bitrix, что еще тут скажешь))

    greevex, 10 Февраля 2011

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