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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    # coffee script
    d = 1 - Math.pow(d,n) * Math.pow((1/d -1),n)
    
    // java script
    d = 1 - Math.pow(d, n) * Math.pow(1 / d(-1), n);

    почему не любят кофескрипт, выпуск -дцатьпервый. потому что нельзя просто скопипастить формулу и не поймать Uncaught TypeError: number is not a function

    makc3d, 22 Ноября 2014

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

    +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
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    if ((new Date(2014, 0, 1)).getHours() != 0 || new Date(2015, 0, 7).getHours() != 0) {
      // Переопределяем конструктор
      Date = (function (NativeDate) {
        var NewDate = function (Y, M, D, h, m, s, ms) {
          var length = arguments.length;
          var date = length === 1 && String(Y) === Y ? // isString(Y)
              new NativeDate(NewDate.parse(Y)) :
                  length >= 7 ? new NativeDate(NativeDate.UTC(Y, M, D, h, m, s, ms)) :
                  length >= 6 ? new NativeDate(NativeDate.UTC(Y, M, D, h, m, s)) :
                  length >= 5 ? new NativeDate(NativeDate.UTC(Y, M, D, h, m)) :
                  length >= 4 ? new NativeDate(NativeDate.UTC(Y, M, D, h)) :
                  length >= 3 ? new NativeDate(NativeDate.UTC(Y, M, D)) :
                  length >= 2 ? new NativeDate(NativeDate.UTC(Y, M)) :
                  length >= 1 ? new NativeDate(Y) :
              new NativeDate();
          if (length == 0) {
            date = new NativeDate(+date - date.getTimezoneOffset() * 60000);
          }
          date.constructor = NewDate;
          return this instanceof NativeDate ? date : date.toString();
        };
    
        if (NativeDate.now) {
          NewDate.now = function () {
            return new NewDate().getTime();
          };
        }
        if (NativeDate.UTC) {
          NewDate._UTC = NativeDate.UTC;
          NewDate.UTC = function (Y, M, D, h, m, s, ms) {
            var _date = new NewDate(NewDate._UTC.apply(this, arguments));
            return +_date - _date.getTimezoneOffset() * 60000;
          };
        }
        NewDate.prototype = NativeDate.prototype;
        NewDate.prototype.constructor = NewDate;

    И так далее, "фикс" для кривых таймзон в JS на винде http://habrahabr.ru/post/243685/

    asavartsov, 21 Ноября 2014

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var obj=document.getElementsByClassName('check-distr');
    var a=0;
    for(i=0; i < obj.length; i++) {
    a=a+1;
    }

    без комментариев:)
    Нашел такое вот, судя по аннотации чел уже уволился и разделить сие не с кем, говнокожу сюда)))

    Patapon, 20 Ноября 2014

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

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // replace old contents with new sorted
     if(!msie_browser){
      table.innerHTML = header + whitelist + blacklist;
     } else {
      // On f...ed Internet Explorer table.innerHTML is read only !!!
      // and we need to replace the whole table ...
      document.getElementById("for_msie").innerHTML =
       table_head + header + whitelist + blacklist + "</table>";
      table = document.getElementById("main_table");
     }

    Ultra Defragmenter report sorting engine.

    DIX315, 19 Ноября 2014

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

    +159

    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
    function get() {
      var a, g, d = app.vk.friend.OSS;
      1 > db.contacts.length && VK.api( "friends.get", {fields: "photo_rec,contacts"}, function ( j )
      {
        if ( j.response )
        {
          try
          {
            app.vk.friend.inited = !1;
            g = j.response.length;
            var e = [], b, f = null, m = null;
            for ( a = 0; a < g; a++ )
            {
              b = j.response[a].mobile_phone || "";
              var m = f = null, c = b.match( /\d/g );
              if ( !c || !(7 == c.length && "9" == c[0] || 10 == c.length || 11 == c.length) )
              {
                b = null;
              }
              b && 11 == c.length && (b = "bbbccccccc".replace( "a", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "b", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ).replace( "c", c[10] ));
              b && 10 == c.length && (b = "bbbccccccc".replace( "b", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "c", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ));
              b && (7 == c.length && "9" == c[0]) && (b = null);
              b && 10 == c.length && (f = c[0] + c[1] + c[2]);
              b && 11 == c.length && (f = c[1] + c[2] + c[3]);
              b && (e[e.length] = b);
              m = d[null != f ? 2 : 0];
              db.contacts[db.contacts.length] = {uid: j.response[a].uid, first_name: j.response[a].first_name, last_name: j.response[a].last_name, name: j.response[a].first_name + " " + j.response[a].last_name, photo: j.response[a].photo || j.response[a].photo_rec || j.response[a].photo_big, phoneOrig: j.response[a].mobile_phone || "", phone: b, mask: f, oper: m, oper_i: m == d[1] ? 2 : m != d[0] ? 1 : 0, app_status: 0}
            }
            var p, i = app.scnet.form.checkNumbers( e );
            g = i.SUBSCRIBER && i.SUBSCRIBER.length ? i.SUBSCRIBER.length : i.SUBSCRIBER ? 1 : 0;
            1 == g && (i.SUBSCRIBER = [i.SUBSCRIBER]);
            for ( a = 0; a < g; a++, p = null )
            {
              1 == i.SUBSCRIBER[a].SELF && (p = db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN )), p && (db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper = d[1], db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper_i = 2);
            }
            document.all ? setTimeout( app.vk.friend.getAppFri, 1E3 ) : document.all || app.vk.friend.getAppFri()
          }
          catch ( t )
          {}
        }
      } )
    }

    Здесь прекрасно всё, и как картины Босха можно рассматривать эту лапшу бесконечно.

    bodeaux, 19 Ноября 2014

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    setInterval(
       setTimeout(){
          function(){
            updater();
          },
         10
       }
    ,2000);

    Просто увидел в коде

    kit, 18 Ноября 2014

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

    +156

    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
    // ==UserScript==
    // @name AutoConfirm
    // @namespace test
    // @include http://[CENSORED]/reviewboard/*
    // @version 1
    // @grant none
    // ==/UserScript==
    
    setTimeout(
    function(){
    window.confirm = function(msg){return true;};
    document.getElementById("shipit-link").click();
    },
    2000
    );

    Ускорение code review

    kit, 18 Ноября 2014

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

    +158

    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
    var result = {success: true};
    	
    	var arr = sumParam(info, null, null, /<td[^>]+class="rate"[^>]*>([\s\S]*?)<\/td>/ig, replaceTagsAndSpaces, html_entity_decode);
    	//Доллар/Гривна
    	AnyBalance.trace(arr[0]);
    	AnyBalance.trace(arr[1]);
    	AnyBalance.trace(arr[2]);
    	AnyBalance.trace(arr[3]);
    	//Евро/Гривна
    	AnyBalance.trace(arr[4]);
    	AnyBalance.trace(arr[5]);
    	AnyBalance.trace(arr[6]);
    	AnyBalance.trace(arr[7]);
    	//Рубль/Гривна
    	AnyBalance.trace(arr[8]);
    	AnyBalance.trace(arr[9]);
    	AnyBalance.trace(arr[10]);
    	AnyBalance.trace(arr[11]);
    	
    	result.USDpok = parseFloat(arr[2].replace(',', '.'));
    	result.USDpro = parseFloat(arr[3].replace(',', '.'));
    	result.EURpok = parseFloat(arr[6].replace(',', '.'));
    	result.EURpro = parseFloat(arr[7].replace(',', '.'));
    	result.RUBpok = parseFloat(arr[10].replace(',', '.'));
    	result.RUBpro = parseFloat(arr[11].replace(',', '.'));
    	AnyBalance.setResult({
    		success: true,
    		USDpok: result.USDpok,
    		USDpro: result.USDpro,
    		EURpok: result.EURpok,
    		EURpro: result.EURpro,
    		RUBpok: result.RUBpok,
    		RUBpro: result.RUBpro
    	});

    Провайдер для одного балансового приложения, я просто не сдержался, пришлось даже зарегистрироваться)

    Starksoft, 17 Ноября 2014

    Комментарии (14)
  9. JavaScript / Говнокод #17116

    +166

    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
    function chekemailandpas(e) {
      var email1val = $('#email1').val();
      var pas1val = $('#password1').val();
      var name1val = $('#name1').val();
      var famil2val = $('#famil2').val();
      name1val = del_spaces(name1val);
      famil2val = del_spaces(famil2val);
      email1val = del_spaces(email1val);
      pas1val = del_spaces(pas1val);
      email1 = email1val.length;
      pas1 = pas1val.length;
      if(!e) {
       e = event || window.event; 
      }
      if(e == '[object MouseEvent]' || e.keyCode == 13 && email1val !== '' &&  pas1val !== '') {
        if(email1 < 5) {
          setTimeout(function() {
            $('#email1').css('background', 'rgba(240,128,128, 0.1)');
            setTimeout(function() {
              $('#email1').css('background', 'rgba(240,128,128,0.2)');
              setTimeout(function() {
                $('#email1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#email1').css('background', 'rgba(240,128,128,0.4)');
                  setTimeout(function() {
                    $('#email1').css('background', 'rgba(240,128,128,0.5)');
                  }, 50);
                }, 50);
              }, 50);
            }, 50);
          }, 500);
          if($('#email1').css('background', 'rgba(240,128,128,0.5)')) {
            setTimeout(function() {
              $('#email1').css('background', 'rgba(240,128,128, 0.4)');
              setTimeout(function() {
                $('#email1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#email1').css('background', 'rgba(240,128,128,0.2)');
                  setTimeout(function() {
                    $('#email1').css('background', 'rgba(240,128,128,0.1)');
                    setTimeout(function() {
                      $('#email1').css('background', 'rgba(240,128,128,0.0)');
                    }, 50);
                  }, 50);
                }, 50);
              }, 50);
            }, 500);
          }
        }
        if(pas1 < 2) {
          setTimeout(function() {
            $('#password1').css('background', 'rgba(240,128,128, 0.1)');
            setTimeout(function() {
              $('#password1').css('background', 'rgba(240,128,128,0.2)');
              setTimeout(function() {
                $('#password1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#password1').css('background', 'rgba(240,128,128,0.4)');
                  setTimeout(function() {
                    $('#password1').css('background', 'rgba(240,128,128,0.5)');
                  }, 50);
                }, 50);
              }, 50);
            }, 50);
          }, 500);
          if($('#password1').css('background', 'rgba(240,128,128,0.5)')) {
            setTimeout(function() {
              $('#password1').css('background', 'rgba(240,128,128, 0.4)');
              setTimeout(function() {
                $('#password1').css('background', 'rgba(240,128,128,0.3)');
                setTimeout(function() {
                  $('#password1').css('background', 'rgba(240,128,128,0.2)');
                  setTimeout(function() {
                    $('#password1').css('background', 'rgba(240,128,128,0.1)');
                    setTimeout(function() {
                      $('#password1').css('background', 'rgba(240,128,128,0.0)');
                    }, 50);
                  }, 50);
                }, 50);
              }, 50);
            }, 500);
          }
        }
        if(email1 > 4 && pas1 > 1) {
          var pagename = 'email='+email1val+'&password='+pas1val+'&name='+name1val+'&famil='+famil2val;
          sendRequest(pagename);
    
        }
      }
    }

    dannikonov, 16 Ноября 2014

    Комментарии (34)
  10. JavaScript / Говнокод #17111

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    var list = [ ];
    
    // hidden elements
    list[ NaN ] = 'this-element-always-is-last'; // max index
    list[ Number.MAX_VALUE ] = 'this-is-smallest';
    list[ Infinity ] = 'this-just-infinity';
    
    // list.length == 0; // true

    Делать нечего в селе, мы сидим навеселе. Всех с пятницей!

    bot, 14 Ноября 2014

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