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

    +163

    1. 1
    2. 2
    3. 3
    function GetPath(path){
     return path;
    }

    Коротко и ясно! Единственный метод в модуле.

    Scorpibear, 01 Декабря 2010

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

    +160

    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
    TINY.accordion=function(){
    	function slider(n){this.n=n; this.a=[]}
    	slider.prototype.init=function(t,e,m,o,k){
    		var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
    		for(i;i<l;i++){
    			var v=n[i];
    			if(v.nodeType!=3){
    				this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
    				if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
    			}
    		}
    		this.l=s
    	};
    	slider.prototype.pr=function(f,d){
    		for(var i=0;i<this.l;i++){
    			var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
    			if((k!=1&&c.d==-1)&&(f==1||i==d)){
    				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
    			}else if(k>0&&(f==-1||this.m||i==d)){
    				c.d=-1; h.className=''; su(c,-1)
    			}
    		}
    	};
    	function su(c){c.t=setInterval(function(){sl(c)},20)};
    	function sl(c){
    		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
    		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
    		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
    	};
    	return{slider:slider}
    }();

    http://installauto.ru/ajax/script.js
    чья-то реализация аккордиона. и почему же оно хреново в ИЕ пашет?

    noRerih, 01 Декабря 2010

    Комментарии (3)
  3. Perl / Говнокод #4798

    −120

    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
    # Find out what mail program to use !! Terrible kludge !!
      $mailprogram = "/usr/bin/mail";
      if (! -x "$mailprogram") {
        if (-x "/bin/mail") {
          $mailprogram = "/bin/mail";
        } else {
          if (-x "/usr/sbin/sendmail") {
            $mailprogram = "/usr/sbin/sendmail";
          } else {
            if (-x "/usr/lib/sendmail") {
              $mailprogram = "/usr/lib/sendmail";
            } else {
              if (-x "/usr/bin/mutt") {
                $mailprogram = "/usr/bin/mutt";
              } else {
                if (-x "/usr/sbin/exim4") {
                  $mailprogram = "/usr/sbin/exim4";
                } else {
                  if (-x "/usr/bin/elm") {
                    $mailprogram = "/usr/bin/elm";
                  } else {
                    print "Cannot find a mail program to use\n";
                  }
                }
              }
            }
          }
        }
      }

    В changelog автор честно признался, что не знал, как реализовать иначе.

    Anderson, 01 Декабря 2010

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

    −145

    1. 1
    2. 2
    $ if [ "0" != "0" ]; then make i8086gui;else echo "GTK GUI is disabled - may be you lack of gtk!";fi;
    GTK GUI is disabled - may be you lack of gtk!

    Странная какая-то проверка наличия GTK в мєйкфайле...

    Anderson, 01 Декабря 2010

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

    +145

    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
    <? 
    // Функция для того, чтобы иЗ***оВаТь текст 
    $str = 'бросайте вы корявить текст'; 
    
    function koryavka ($t){ 
    $c = strlen($t); 
    
    for($i=0;$i<$c;$i++) { 
    $t[$i] = (is_int($i/2)) ? strtoupper($t[$i]) : $t[$i]; 
    $ret[] =  $t[$i];  
    } 
    
    return implode('',$ret); 
    } 
    
    echo koryavka ($str); 
    ?>

    Aligan, 01 Декабря 2010

    Комментарии (52)
  6. SQL / Говнокод #4795

    −858

    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
    create function is_numeric (
    	@a varchar(100)
    ) returns int as begin
    	declare @retval int
    	set @a = replace(@a, '0', '')
    	set @a = replace(@a, '1', '')
    	set @a = replace(@a, '2', '')
    	set @a = replace(@a, '3', '')
    	set @a = replace(@a, '4', '')
    	set @a = replace(@a, '5', '')
    	set @a = replace(@a, '6', '')
    	set @a = replace(@a, '7', '')
    	set @a = replace(@a, '8', '')
    	set @a = replace(@a, '9', '')
    	set @a = replace(@a, '.', '')
    	if len(rtrim(ltrim(@a))) > 0 set @retval = 0
    	else set @retval = 1
    	return @retval
    end

    Вот такая хитрая скалярная функция была найдена в недрах сопровождаемой системы. Согласно ей "...42...42..." -- это число, такие дела.

    Zebr, 01 Декабря 2010

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

    +154

    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
    http://vkontakte.ru/
    <noscript><meta http-equiv="refresh" content="0; URL=/badbrowser.php"></noscript>
    
    
    http://vkontakte.ru/badbrowser.php
    <script type="text/javascript">
    <!--
    
    //window.checkbrowser = true;
    if (window.checkbrowser) {
      try {
        if (new XMLHttpRequest()) {
          location.replace('/');
        }
      } catch(e) {
        try {
          if (new ActiveXObject('Msxml2.XMLHTTP')) {
            location.replace('/');
          }
        } catch(e) {}
        try {
          if (new ActiveXObject('Microsoft.XMLHTTP')) {
            location.replace('/');
          }
        } catch(e) {}
      }
    }
    -->
    </script>

    Вот так суровые вконтактостроители отправляют на йуг пользователей NoScript.

    Vindicar, 30 Ноября 2010

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static function encode($value, $cycleCheck = false, $options = array())
        {
            $encoder = new self(($cycleCheck) ? true : false, $options);
    
            return $encoder->_encodeValue($value);
        }

    Zend Framework, Zend_Json_Encoder

    dr_von_ozgg, 30 Ноября 2010

    Комментарии (17)
  9. Java / Говнокод #4792

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    for (int j = 0; j < fieldsToRemove.size(); j++) {
    	if (fieldsToDelete.getField(j).getKind().equals("GroupField")) {
    		resFieldContr.remove(j--);
    	}
    }

    собственно цикл.
    нашел в рабочем проекте

    tas, 30 Ноября 2010

    Комментарии (21)
  10. Java / Говнокод #4791

    +84

    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
    http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/org/codehaus/groovy/runtime/ArrayUtil.java
    
    /*
     * Copyright 2003-2009 the original author or authors.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    package org.codehaus.groovy.runtime;
    
    public class ArrayUtil {
        private static final Object[] EMPTY = new Object[0]
                ;
    
        public static Object[] createArray() {
            return EMPTY;
        }
    
        public static Object[] createArray(Object arg0) {
            return new Object[]{
                    arg0};
        }
    
        public static Object[] createArray(Object arg0, Object arg1) {
            return new Object[]{
                    arg0, arg1};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2) {
            return new Object[]{
                    arg0, arg1, arg2};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3) {
            return new Object[]{
                    arg0, arg1, arg2, arg3};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
            return new Object[]{
                    arg0, arg1, arg2, arg3, arg4};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
            return new Object[]{
                    arg0, arg1, arg2, arg3, arg4, arg5};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
            return new Object[]{
                    arg0, arg1, arg2, arg3, arg4, arg5, arg6};
        }
    
    ............

    bytes, 30 Ноября 2010

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