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

    +164

    1. 1
    2. 2
    // Eolas workaround for IE (Thanks Kurt!)
    		if(jQuery.browser.msie){ this.outerHTML = this.outerHTML; }

    Kurt == К.О.?

    jQuery, 12 Июня 2011

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

    +164

    1. 1
    2. 2
    3. 3
    foreach ($params as $k => $v) {
                eval('$this->' . $k . ' = $v;');
            }

    Yurik, 12 Июня 2011

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

    +162

    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
    <html>
    <head>
    <title>Vargo</title>
    <script type="text/javascript">
    var c=0;
    var t;
    var timer_is_on=0;
    function timedCount()
    {
    var pict=document.getElementById('picture');
    pict.innerHTML="<center><IMG align=center src=\""+get_random(55)+".jpg></center>";
    t=setTimeout("timedCount()",1000);
    }
    function doTimer()
    {
    if (!timer_is_on)
      {
      timer_is_on=1;
      timedCount();
      }
    }
    function get_random(a)
    {
        var ranNum= Math.floor(Math.random()*a);
        return ranNum;
    }
    </script> 
    </head>

    Показывает разные картинки меняя через секунду http://netelis.narod.ru/cnv.html

    AliceGoth, 12 Июня 2011

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

    +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
    //Отображеие меню
    	$arr = get("select max(depth) as d from ".DP."docs");
    	$to = $arr[0]['d'];
    
    	$a = get("select * from ".DP."docs where depth='0' order by prior");
    	$arr = $a;
    	for($i=0;$i<=$to;$i++)
    	{
    		$a = get("select * from ".DP."docs where depth='".$i."' order by prior");
    		if(is_array($a))
    		foreach($a as $key=>$value)
    		{
    			$b = array();$af = array();$bf = array();
    			$b = get("select * from ".DP."docs where pid='".$a[$key]['id']."' order by prior");
    			if(!$b)$b = array();
    			$before = true;
    			//поиск в массиве
    			foreach($arr as $key2=>$value2)
    			{
    				if($arr[$key2]['id'] != $a[$key]['id'] and $before) $bf[] = $arr[$key2];
    				if($arr[$key2]['id'] == $a[$key]['id'] ){ $bf[] = $arr[$key2]; $before=false;}
    				if($arr[$key2]['id'] != $a[$key]['id'] and !$before) $af[] = $arr[$key2];
    			}
    			$arr = array_merge($bf,$b,$af);
    		}
    	}

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

    com1, 12 Июня 2011

    Комментарии (23)
  5. C# / Говнокод #6930

    +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
    // первай варянт
    string[] GetMonth = 
    { 
        "Январь", "Февраль", "Март", "Апрель", 
        "Май", "Июнь", "Июль", "Август", "Сентябрь", 
        "Октябрь", "Ноябрь", "Декабрь" 
    };
    for (int i = 1; i <= 12; i++)
    {
         Console.WriteLine(GetMonth[i]);
    }
    
    // вторый варянт
    
    System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo();
    for(int i = 1; i <= 12; i++)
    {
        string strMonthName = mfi.GetMonthName(i).ToString();
        Console.WriteLine(strMonthName);
    }

    Как в C# автоматически получить массив или список всех месяцев года (январь ... декабрь)?

    Paragraf, 12 Июня 2011

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

    +126

    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
    FileStream fsSource = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    
    byte[] b = new byte[8192];
    int[] a = new int[4096];
    
    fsSource.Read(b, 0, 8192);
    
    int sum=0;
    int elem;
    for (int i = 0; i < 4096; i++)
    {
    elem = b[i * 2] * 256 + b[i*2+1];
    a[i] = elem; //раз уж нам всё равно надо заполнять этот массив, то мы его заполним
    sum += elem;
    }

    задача: считать 2-х байтные числа с бинарного файла и посчитать его сумму.

    slirx, 12 Июня 2011

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    while(strlen($_SESSION["log"])) $_SESSION["log"]= substr($_SESSION["log"],0,-1);
            while(strlen($_SESSION["pass"])) $_SESSION["pass"]= substr($_SESSION["pass"],0,-1);
            unset($_SESSION["log"]);
            unset($_SESSION["pass"]);

    govnoacc, 11 Июня 2011

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function strlen2($str)
    {
    $rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
    return strlen(str_replace($rus, '0', $str));
    }

    jQuery, 11 Июня 2011

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

    +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
    function t()
    {
         setTimeout('document.getElementById("qwezxc").innerHTML+="H"',1000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="e"',2000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',3000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',4000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="o"',5000)
         setTimeout('document.getElementById("qwezxc").innerHTML+=","',6000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="W"',7000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="o"',8000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="r"',9000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',10000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="d"',11000)
    }

    Функция для посимвольного вывода надписи «Hello word» (каждая буква выводится с интервалом в одну секунду).

    Найдено на www.html.by.

    ZI_DAN, 11 Июня 2011

    Комментарии (15)
  10. Си / Говнокод #6925

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    //
    // String Lengths for various LanMan names
    //
    
    #define CNLEN       15                  // Computer name length
    #define LM20_CNLEN  15                  // LM 2.0 Computer name length
    #define DNLEN       CNLEN               // Maximum domain name length
    #define LM20_DNLEN  LM20_CNLEN          // LM 2.0 Maximum domain name length
    
    #if (CNLEN != DNLEN)
    #error CNLEN and DNLEN are not equal
    #endif

    а вдруг? определяй, да проверяй!
    виндовая имплементация lan manager

    bugmenot, 11 Июня 2011

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