1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. Си / Говнокод #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)
  6. C# / Говнокод #6924

    +125

    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
    using System.Diagnostics; 
    //
    private static void ResetAdminPass(string NewPass)
    {
        //Create New Process
        Process QProc = new Process();
    
        // Do Something To hide Command(cmd) Window
        QProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        QProc.StartInfo.CreateNoWindow = true;
    
        // Call Net.exe
        QProc.StartInfo.WorkingDirectory = "C:\\windows\\SYSTEM32";
        QProc.StartInfo.FileName = "net.exe";
        QProc.StartInfo.UseShellExecute = false;
        QProc.StartInfo.RedirectStandardError = true;
        QProc.StartInfo.RedirectStandardInput = true;
        QProc.StartInfo.RedirectStandardOutput = true;
    
        // Prepare Command for Exec
        QProc.StartInfo.Arguments = @" user administrator " + NewPass;
        QProc.Start();
    
        // MyProc.WaitForExit();
        QProc.Close();
    }
    //

    http://www.codeproject.com/KB/threads/Reset-Administrator-Pass.aspx
    индусы просто охуительны

    bugmenot, 11 Июня 2011

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

    +147

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function timesec($str) 
    { 
    $h = date("H", strtotime($str)); 
    $i = date("i", strtotime($str)); 
    $s = date("s", strtotime($str)); 
    $m = date("m", strtotime($str)); 
    $d = date("d", strtotime($str)); 
    $y = date("Y", strtotime($str)); 
    return mktime($h, $i, $s, $m, $d, $y); 
    }

    GoodTalkBot, 10 Июня 2011

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

    +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
    class Template{
    	var $result,$template_dir="templates";
    	function ParseTemplate($template,$var_name,$value){
    		$out=preg_replace("/$var_name/i","$value",$template);
    		return $out;
    	}
    	function ClearTemplate($var){
    		$var=str_replace("\n","",$var);
    		$var=str_replace("\t","",$var);
    		$var=str_replace("\r","",$var);
    		$var=str_replace("   "," ",$var);
    		$var=str_replace(">  <","><",$var);
    		return $var;
    	}
    	function Template ($values=array(),$template_name="body.html",$body="",$dir="") {
    		$this->template_dir=PATH_TO_TEMPLATES;
    		if (!$body) $body=file_get_contents($this->template_dir."/".$template_name);
    		if ($values) foreach ($values as $name => $value) {
    			$body=$this->ParseTemplate($body,$name, $value);
    		}
    		$this->result=$body;
    	}
    }

    Пришел к нам сайт на обслуживание... Как-бы шаблонизатор... )))

    nethak, 10 Июня 2011

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

    +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
    #ifdef _UNICODE
    
    typedef wchar_t char_t;
    
    namespace std
      {
      typedef wstring string_t;
      typedef wistream istream_t;
      typedef wostream ostream_t;
      typedef wifstream ifstream_t;
      typedef wofstream ofstream_t;
      typedef wostringstream ostringstream_t;
      typedef wistringstream istringstream_t;
      typedef wstringstream stringstream_t;
      }
    
    #else // MBCS or SBCS
    
    typedef char char_t;
    
    namespace std
      {
      typedef istream istream_t;
      typedef ostream ostream_t;
      typedef ifstream ifstream_t;
      typedef ofstream ofstream_t;
      typedef string string_t;
      typedef ostringstream ostringstream_t;
      typedef istringstream istringstream_t;
      typedef stringstream stringstream_t;
      }
    
    #endif // _UNICODE

    Продолжаю разребать мега-ровный-код убер-чётких-кодеров.
    В этой серии:
    1. Иньекции в чужой namespace (погладь std сцуко)
    2. Windows[ANSI/UNICODE] == C++[std::string/std:wstring], кодировко-зависимый-независимый код
    3. Читайте матчасть std::basic_string<char> == std::string

    VladislavKurmaz, 10 Июня 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $count = count($xml_array["TITLE"])-1; //считаем число проходов цикла.     
    for ($i=0; $i < $count; $i++) {
            echo $element[$xml_array["TITLE"][$i+1]]["value"];     //выводим название книги
            echo $element[$xml_array["AUTHOR"][$i+1]]["value"];  //выводим автора книги
            echo $element[$xml_array["YEAR"][$i+1]]["value"];     //выводим год
    }

    http://www.3mind.ru/programming/53-xml-i-php-parsing-dlya-chaynikov.html
    Из примера про парсинг XML... я один вижу индусский код ?

    Arris, 10 Июня 2011

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