1. Список говнокодов пользователя 3.14159265

    Всего: 150

  2. JavaScript / Говнокод #10293

    +176

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function getAnchor(link){
    	var url=( (!link) ? window.location : link).toString();
    	var idx = url.indexOf("#");
    	return (idx != -1 ? url.substring(idx+1) : '');	
    }
    function setAnchor(anchor){
    	var url=(window.location).toString();
    	var idx = url.indexOf("#");
    	return ( window.location= 
    		(idx != -1 ? url.substring(0,idx+1) : url+'#')+anchor
    	);
    }

    3.14159265, 16 Мая 2012

    Комментарии (1)
  3. JavaScript / Говнокод #9639

    +199

    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
    _bc_do_compare: function (n1, n2, use_sign, ignore_last) {
                var n1ptr, n2ptr; // int
        var count; // int
        /* First, compare signs. */
        if (use_sign && (n1.n_sign != n2.n_sign)) {
            if (n1.n_sign == libbcmath.PLUS) {
                return (1); /* Positive N1 > Negative N2 */
            } else {
                return (-1); /* Negative N1 < Positive N1 */
            }
        }
    
        /* Now compare the magnitude. */
        if (n1.n_len != n2.n_len) {
            if (n1.n_len > n2.n_len) { /* Magnitude of n1 > n2. */
                if (!use_sign || (n1.n_sign == libbcmath.PLUS)) {
                    return (1);
                } else {
                    return (-1);
                }
            } else { /* Magnitude of n1 < n2. */
                if (!use_sign || (n1.n_sign == libbcmath.PLUS)) {
                    return (-1);
                } else {
                    return (1);
                }
            }
        }
    
        if (count !== 0) {
            if (n1.n_value[n1ptr] > n2.n_value[n2ptr]) { /* Magnitude of n1 > n2. */
                if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                    return (1);
                } else {
                    return (-1);
                }
            } else { /* Magnitude of n1 < n2. */
                if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                    return (-1);
                } else {
                    return (1);
                }
            }
        }
    
        /* They are equal up to the last part of the equal part of the fraction. */
        if (n1.n_scale != n2.n_scale) {
            if (n1.n_scale > n2.n_scale) {
                for (count = (n1.n_scale - n2.n_scale); count > 0; count--) {
                    if (n1.n_value[n1ptr++] !== 0) { /* Magnitude of n1 > n2. */
                        if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                            return (1);
                        } else {
                            return (-1);
                        }
                    }
                }
            } else {
                for (count = (n2.n_scale - n1.n_scale); count > 0; count--) {
                    if (n2.n_value[n2ptr++] !== 0) { /* Magnitude of n1 < n2. */
                        if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                            return (-1);
                        } else {
                            return (1);
                        }
                    }
                }
            }
    }

    Свежий подход к написанию бульщитов от создателей phpjs.

    3.14159265, 10 Марта 2012

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

    +200

    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
    for (k = 0; k < xl; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
            d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
            c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
            b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
            a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
            d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
            c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
            b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
            a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
            d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
            c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
            b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
            a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
            d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
            c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
            b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
            a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
            d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
            c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
            b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
            a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
            d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
    <40 строк поспипано>
            b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
            a = addUnsigned(a, AA);
            b = addUnsigned(b, BB);
            c = addUnsigned(c, CC);
            d = addUnsigned(d, DD);
    }

    http://phpjs.org/downloads/phpjs.commonjs.js.
    Там оказалось реально много жира. Я сначала подумал, что сеть Фейштеля, но потом-таки разглядел MD5.
    Говносути это конечно не меняет.

    3.14159265, 07 Марта 2012

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

    +197

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.an)!==-1;},ctype_alpha:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.al)!==-1;},ctype_cntrl:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.ct)!==-1;},ctype_digit:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.dg)!==-1;},ctype_graph:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.gr)!==-1;},ctype_lower:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.lw)!==-1;},ctype_print:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pr)!==-1;},ctype_punct:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pu)!==-1;},ctype_space:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.sp)!==-1;},ctype_upper:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.up)!==-1;},ctype_xdigit:function(text){if(typeof text!=='string'){return false;}

    При беглом просмотре бросился мне тут в глаза кусочек из http://phpjs.org/downloads/php.common.min.js

    3.14159265, 06 Марта 2012

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

    +209

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    const evalScript = "with (__win__.__scope__.vars) { with (__win__.__scope__.api) { with (__win__.__scope__.userVars) { with (__win__) {" +
        "try {" +
            "__win__.__scope__.callback(eval(__win__.__scope__.expr));" +
        "} catch (exc) {" +
            "__win__.__scope__.callback(exc, true);" +
        "}" +
    "}}}}";

    http://code.google.com/p/fbug/source/browse/branches/firebug1.2/content/firebug/commandLine.js?r=444

    3.14159265, 03 Марта 2012

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

    +121

    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
    public static boolean isAssignable(Class cls, Class toClass, boolean autoboxing) {
        if (toClass == null) {
            return false;
        }
        // have to check for null, as isAssignableFrom doesn't
        if (cls == null) {
            return !(toClass.isPrimitive());
        }
        //autoboxing:
        if (autoboxing) {
            if (cls.isPrimitive() && !toClass.isPrimitive()) {
                cls = primitiveToWrapper(cls);
                if (cls == null) {
                    return false;
                }
            }
            if (toClass.isPrimitive() && !cls.isPrimitive()) {
                cls = wrapperToPrimitive(cls);
                if (cls == null) {
                    return false;
                }
            }
        }
        if (cls.equals(toClass)) {
            return true;
        }
        if (cls.isPrimitive()) {
            if (toClass.isPrimitive() == false) {
                return false;
            }
            if (Integer.TYPE.equals(cls)) {
                return Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
            }
            if (Long.TYPE.equals(cls)) {
                return Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
            }
            if (Boolean.TYPE.equals(cls)) {
                return false;
            }
            if (Double.TYPE.equals(cls)) {
                return false;
            }
            if (Float.TYPE.equals(cls)) {
                return Double.TYPE.equals(toClass);
            }
            if (Character.TYPE.equals(cls)) {
                return Integer.TYPE.equals(toClass)
                    || Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
            }
            if (Short.TYPE.equals(cls)) {
                return Integer.TYPE.equals(toClass)
                    || Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
            }
            if (Byte.TYPE.equals(cls)) {
                return Short.TYPE.equals(toClass)
                    || Integer.TYPE.equals(toClass)
                    || Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
            }
            // should never get here
            return false;
        }
        return toClass.isAssignableFrom(cls);
    }

    org.apache.commons.lang.ClassUtils

    3.14159265, 01 Марта 2012

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

    +192

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public Matrix3d(double m00,
                    double m01,
                    double m02,
                    double m10,
                    double m11,
                    double m12,
                    double m20,
                    double m21,
                    double m22)

    [color=blue]http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/vecmath/Matrix3d.html[color]

    3.14159265, 10 Февраля 2012

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

    +1003

    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
    namespace ExtensionMethods
    {
        public static class MyExtensions
        {
            public static int WordCount(this String str)
            {
                return str.Split(new char[] { ' ', '.', '?' }, 
                                 StringSplitOptions.RemoveEmptyEntries).Length;
            }
        }   
    }
    ....
    string s = "Hello Extension Methods";
    int i = s.WordCount();

    http://msdn.microsoft.com/en-us/library/bb383977.aspx

    In your code you invoke the extension method with instance method syntax. However, the intermediate language (IL) generated by the compiler translates your code into a call on the static method. Therefore, the principle of encapsulation is not really being violated. In fact, extension methods cannot access private variables in the type they are extending.

    Синтаксический сахар. Бессмысленный и беспощадный.
    Ждк, когда шарпоблядки уже начнут дохнуть от диабета.

    3.14159265, 26 Ноября 2011

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

    −108

    1. 1
    select 7-(8-datepart(weekday,getDate())) % 7

    Написал для конвертации дней недели начинающихся с SUNDAY=1, в привычные Пн-1, Вс-7

    3.14159265, 23 Ноября 2011

    Комментарии (6)
  11. Java / Говнокод #8175

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) {
            if (defaultLookAndFeelDecorated) {
                SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
            } else {
                SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
            }
    }

    http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/swing/javax/swing/JFrame.java.htm

    3.14159265, 12 Октября 2011

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