1. Лучший говнокод

    В номинации:
    За время:
  2. C# / Говнокод #2364

    +134.5

    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
    static void Main(string[] args)
            {
                if (args.Length < 1)
                    Console.WriteLine("Usage:\n\tprogram <Folder> [output file]");
                else if (args.Length == 1)
                {
                    string outf = args[0] + "\\output.txt";
                    System.IO.File.WriteAllLines
                        (
                            outf,
                            new List<string>
                                (
                                    System.IO.Directory.GetFiles(args[0])
                                )
                                    .Concat(System.IO.Directory.GetDirectories(args[0]))
                                    .ToArray()
                        );
                }
                else if(args.Length == 2)
                {
                    string outf = args[1];
                    System.IO.File.WriteAllLines
                        (
                            outf,
                            new List<string>
                                (
                                    System.IO.Directory.GetFiles(args[0])
                                )
                                    .Concat(System.IO.Directory.GetDirectories(args[0]))
                                    .ToArray()
                        );
                }
            }

    Видите ли, я не знал как это сделать с помощью скриптовых языков виндовс.

    psina-from-ua, 01 Января 2010

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

    −861.7

    1. 1
    2. 2
    3. 3
    select ...
    where ISNULL(e2e.ItemId, -1) = (case when @itemId < 1 then ISNULL(e2e.ItemId, -1) else @itemId end) 
    and ISNULL(e2e.LeftId, -1) = (case when @parentItemId < 1 then ISNULL(e2e.LeftId, -1) else @parentItemId) end

    workgss, 29 Декабря 2009

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

    +161.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $keys = array_keys($_POST);
    $vals = array_values($_POST);
    for($i=0; $i<=count($keys); $i++)
    {
        if($keys[$i]!='act' && $keys[$i]!='mode' && $keys[$i]!='pid')
        {
                $sql->Query('UPDATE `user_services_options` SET `value`=\''.$f->QuoteSql($vals[$i]).'\' WHERE `option`=\''.$f->QuoteSql($keys[$i]).'\' AND `service_id`='.$f->QuoteSql($service_id).' AND user_id='.$f->QuoteSql($user_id));
        }
    }

    кагбе про foreach($_POST as $key => $value) я тогда и не знал.

    nolka4, 18 Декабря 2009

    Комментарии (3)
  5. PHP / Говнокод #2283

    +159.1

    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 dump_link($dump_id)
    {
    $a = date(G);
    $b = date(i);
    $c = date(s);
    $day = date(j);
    $mouth = date(n);
    $year = date(Y);
    $utc = date(Z);
    $int = mktime($a, $b, $c, $mouth, $day, $year);
    
    ...
    
    }

    Наш ответ функции time()!

    thexyz, 15 Декабря 2009

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

    +73.4

    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
    String tempFileName = "someFileName";
    URL url = SomeClass.class.getClassLoader().getResource(".");
    File currentFolder = new File(url.getFile());
    if(currentFolder.isDirectory()){
       File parentFolder = currentFolder.getParentFile();
       for (String file:parentFolder.list()) {
          if(file.equals("temp")){
             File targetFolder = new File(parentFolder.getAbsolutePath()+"\\"+file+"\\"+tempFileName);
             if(!targetFolder.exists()) {
    	targetFolder.mkdir();
             }
             this.pathToTempFile = parentFolder.getAbsolutePath()+"\\"+file+"\\"+tempFileName;
          }
       }
    }

    Поиск директории для создания временных файлов вместо использования File.createTempFile(prefix, suffix)

    eroese, 10 Декабря 2009

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

    +158.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if(isset($_POST['submit']))
      {
         send($_POST['id_rep'],$_POST['name'],$_POST['city'],$_POST['other_city'],$_POST['kod_tel_1'],$_POST['tel_1'],$_POST['kod_tel_2'],$_POST['tel_2'],$_POST['prim'],$_POST['res'],$_POST['category'],$_POST['other_cat'],$_POST['check_uch'],$_POST['check_prep'],$_POST['district_uch'],$_POST['district_prep'],$_POST['stoim'],$_POST['email'],$_POST['icq'],$_POST['whence_came'],$_POST['text_whence_came'],$_POST['one_teacher']);
      }
      else
      {
         form($id_teacher,$_POST['name'],$_POST['city'],$_POST['other_city'],$_POST['kod_tel_1'],$_POST['tel_1'],$_POST['kod_tel_2'],$_POST['tel_2'],$_POST['prim'],$_POST['res'],$_POST['category'],$_POST['other_cat'],$_POST['check_uch'],$_POST['check_prep'],$_POST['district_uch'],$_POST['district_prep'],$_POST['stoim'],$_POST['email'],$_POST['icq'],$_POST['whence_came'],$_POST['text_whence_came'],$_POST['one_teacher']);
      }

    Как на самом деле правильно обрабатывать формы.

    defann, 07 Декабря 2009

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

    +146.7

    1. 1
    if (k.innerHTML=='0') {} else {gtim()}

    fuckyounoob, 02 Декабря 2009

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

    +153.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    echo "<pre {$stat_class}>{$pars}<input id='fast_{$tlists['tid']}' type='checkbox' name='tlsite[]' value='{$tlists['tid']}' />
    <label for='fast_{$tlists['tid']}'> {$tlists['file']} <span style='color:#808080; font-size:10px;'>({$tlists['date']})</span>
     - {$tlists['name']}
    </label> 
    [<a href='edit.php?tid={$tlists['tid']}' onClick=\"popupWin = window.open(this.href, 'contacts', 'width=800,height=600,top=150,left=150'); popupWin.focus(); return false;\" >ed</a>] </pre>";

    нечто

    Frenk1, 01 Декабря 2009

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

    +147.8

    1. 1
    2. 2
    3. 3
    for (var i = 0; i = 20; i++;) {
    	$('minus-', i).hide();
    }

    Плевать на ; в конце (ачепятко), но i = 0 и i = 20... :)

    chu4, 30 Ноября 2009

    Комментарии (3)
  11. Pascal / Говнокод #2197

    +92.1

    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
    mTr.StartTransaction;
    
    mdsMaters.DisableControls;
    DBGridEh1.SaveBookmark;
    try
       DBGridEh1.RestoreBookmark;
       mdsMaters.EnableControls;
    
       [.... обход датасета ....]
    
    finally
      mTr.Commit;
    end;

    Как известно, перед обходом датасета нужно делать DisableControls, а главное, не забыть вызвать EnableControls.

    Чем раньше - тем лучше :)

    LionSoft, 30 Ноября 2009

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