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

    +173

    1. 1
    var magnitude = parseInt('10' + new Array(8).join('0'));

    вот такое встретилось

    Sulik78, 12 Сентября 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $(document).ready(function() {
            var links = $("a[href*='shop.mts.ru']");
            $.each(links, function(i, val) {
                $(val).attr('onclick', "_gaq.push(['_link', '" + $(val).attr('href') + "']); return false;");
            });
            //for ThreeSmallBanners adfox:
            $('a.offer_button').removeAttr('onclick');
        });

    mts.ru

    gost, 11 Сентября 2014

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (form.find('input[name*=payout_max]').val() > 0 || form.find('input[name*=payout_max]').val() > 0) {
        form.find('input[name*=payout_max]').closest('div.form-group').show();
        form.find('input[name*=payout_max]').closest('div.form-group').show();
    } else {
        form.find('input[name*=payout_max]').closest('div.form-group').hide();
        form.find('input[name*=payout_max]').closest('div.form-group').hide();
    }

    код лида. видимо, два раза для пущей убедительности

    tagrim, 08 Сентября 2014

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

    +152

    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
    jQuery(document).ready(function (){
    	var setCookie = function (c_name, value, exdays) {
    		var exdate = new Date();
    		exdate.setDate(exdate.getDate() + exdays);
    		var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    		document.cookie = c_name + "=" + c_value;
    	}
    	var getCookie = function (cname){
    		var name = cname + "=";
    		var ca = document.cookie.split(';');
    		for(var i=0; i<ca.length; i++){
    			var c = ca[i].replace(/^\s+|\s+$/gm,'');
    			if (c.indexOf(name)==0) return c.substring(name.length,c.length);
    		}
    		return "";
    	}
    
    	if (window.location.hash=='#stop' || (!getCookie('crimea_is_ukraine') && jQuery.inArray(codehelper_ip.Country,ciu_countries)>=0)){
    		if (typeof(_gaq)!='undefined'){
    			_gaq.push(['_trackEvent', 'Protest', 'Show', 'Crimea is Ukraine']);
    		}

    http://putlerstop.2-you.info/share/stop_putler.js

    gost, 07 Сентября 2014

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    switch ( keyStroke ) {
    					// Shift pressed
    					case 2228240: // IE
    					case 16:
    						that.hiddenMode = 1;
    						that.line.detach();
    				}

    makc3d, 06 Сентября 2014

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

    +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
    // Цитата №1: массив регулярных выражений из введённых пользователем строк
    var strings = what.filter(function(e){ return e.replace(/s+/g,'').length; }).map(function(e){ var re = new RegExp(e, 'g' + (ignoreCase ? 'i' : '')); return re; });
    
    // Цитата №2: проверяется наличие введённых строк в тексте и выводит результаты
    function processText(pid, cid, text){
      if(strings.every(function(re){
        return re.test(text);
      })){
      
        // совпало
        // тут выводится информация о совпадении для поста/комментария
        // кроме вывода в консоль побочных эффектов нет
        ....
        
      }
    }
    
    // Цитата №3: запуск поиска
    posts.forEach(function(post){
      processText(post.id, null, post.author.name + ' ' + post.text);
      processText(post.id, null, post.author.name + ' ' + post.description);
      post.comments.forEach(function(comment){
        processText(post.id, comment.id, comment.author.name + ' ' + comment.text);
      });
    });

    Цитаты из скрипта поиска по ГК.
    Казалось бы, write-only питушня, работает - не трогать. Но, прочитав, http://govnokod.ru/16577#comment246821, решил поискать упоминания доктора по званию. Открываю найденный пост X, а там не все упоминания найдены. Меняю список постов, в которых искать - для X меняется список найденных комментариев.
    Откуда такая питушня? processText почти чистая, strings, posts не меняется. Может, вывод на консоль как-то влияет?

    Все волосы на жопе вырвал пока нашел в чем ошибка.
    Внимание, вопрос. В чем гавно?
    (c) ursus

    1024--, 05 Сентября 2014

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

    +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
    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
    Generator.prototype.update = function () {
    	var	t = this.timer++,
    		d = this.delay,
    		s = this.samples,
    		m = this.minDistance,
    		w = this.width,
    		h = this.height,
    		g = this.global,
    		c = this.cid,
    		ttl = this.ttl--,
    		l = s.length,
    		rand = Math.random,
    		floor = Math.floor,
    		x,
    		y,
    		r,
    		i,
    		j,
    		d2,
    		n;
    
    	if (ttl > 0) {
    		while (t > d) {
    			r = s[floor(rand() * l)].copy();
    
    			if (m) {
    				i = 1000;
    				while (i--) {
    					x = rand() * w - w * 0.5;
    					y = rand() * h - h * 0.5;
    
    					for (j in this) if (j instanceof Entity) {
    						n = this[i];
    						d2 = (x - n.x) * (x - n.x) + (y - n.y) * (y - n.y);
    
    						if (d2 * d2 > m) {
    							i = 0;
    						}
    					}
    				}
    			} else {
    				x = rand() * w - w * 0.5;
    				y = rand() * h - h * 0.5;
    			}
    
    			r.x = x;
    			r.y = y;
    
    			if (!g) {
    				r.parent = this;
    			}
    
    			this[c] = r;
    			this.cid = c += 1;
    			this.time = t -= d;
    		}
    	} else {
    		delete this.update;
    	}
    };

    асм-диалект яваскрипта

    prezident, 04 Сентября 2014

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

    +124

    1. 1
    2. 2
    // poor man's semaphore
    while (self.fetching) {}

    http://backgridjs.com/ref/extensions/select2-cell.html

    someone, 01 Сентября 2014

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function showHelp() {
        var $is_hidden = document.getElementById('help_btn').style.display == '' ? true : false;
        document.getElementById('help_btn').style.display = $is_hidden ? 'none' : '';
        document.getElementById('help_text').style.display = $is_hidden ? '' : 'none';
        return false;
    }

    Больше тернарников богу тернарников!

    http://83.102.180.29/ (заглушка "Билайна")

    gost, 31 Августа 2014

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function detect_overlap(l1,l2,r1,r2,t1,t2,b1,b2) {
        if (b1<t2) { return false; }
        if (t1>b2) { return false; }
        if (r1<l2) { return false; }
        if (l1>r2) { return false; }
        return true;
    }

    DeRain, 21 Августа 2014

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