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

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

    +67

    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
    //разделяем даты на день, месяц, год
    $date_one=$_POST['date_one'];
    $date_two=$_POST['date_two'];
    
    $mounth_one=substr($date_one,0,2);
    $day_one=substr($date_one,3,2);
    $year_one=substr($date_one,6,4);
    $mounth_two=substr($date_two,0,2);
    $day_two=substr($date_two,3,2);
    $year_two=substr($date_two,6,4);
    //смотрит какая дата больше чтоб передать функции в правильном порядке
    if ($year_one>$year_two || ($year_one==$year_two &&$mounth_one>$mounth_two)||($year_one==$year_two&&$mounth_one==$mounth_two&&$date_one>$date_two)){
        echo 'первая дата больше<br/>';
        counting_days($date_one,$date_two);
    }else{
        echo 'вторая дата больше<br/>';
        counting_days($date_two,$date_one);
    }

    забыл что сравнить даты можно гораздо проще

    loki, 06 Февраля 2013

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

    +63

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int i = (int)Math.pow(10, (n - 1)); 
              int max = i*5;
              int count = 0;
                
              for (i = i; i < max; i++) {  // i = i ??              
                 if (isUnique(i, i*2, n)) { 
                    count++;
                    System.out.printf("%s %s \n", i, i*2);
                 }

    Как обойтись без такого кулхацкерного самоприсваивания?

    Govnocoder#0xFF, 02 Февраля 2013

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

    +50

    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
    <?php
    
    //    ...
    
    if(!empty($_GET['hit']))
    {
    $tovar2 = mysql_query("select * from `product` where `hit`='1' ORDER BY `weight` DESC, `id` asc ");
    }else{
    if(!empty($_POST['cena']) && !empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `kat`='".$_POST['meh']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && !empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `kat`='".$_POST['meh']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && !empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `kat`='".$_POST['meh']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && !empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `kat`='".$_POST['meh']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    
    //    ...
    
    ?>

    Make me unsee it!

    Sarkian, 30 Января 2013

    Комментарии (8)
  5. Java / Говнокод #12497

    +79

    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
    public static void loadSWT() {
    		try {
    			File file = null;
    			if (PlatformUtils.IS_WINDOWS) {
    				file = new File("lib/swtwin32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtwin64.jar"); // x64
    				}
    			} else if (PlatformUtils.IS_OSX) {
    				file = new File("lib/swtmac32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtmac64.jar"); // x64
    				} else if (PlatformUtils.OS_ARCH.startsWith("ppc")) {
    					file = new File("lib/swtmaccb.jar"); // carbon
    				}
    			} else if (PlatformUtils.IS_LINUX) {
    				file = new File("lib/swtlin32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtlin64.jar"); // x64
    				}
    			}
    			if ((file == null) || !FileUtils.isExistingFile(file)) {
    				file = new File("lib/swt.jar"); // old system
    			}
    			final Method method = URLClassLoader.class.getDeclaredMethod(
    					"addURL", new Class[] { URL.class });
    			method.setAccessible(true);
    			method.invoke(ClassLoader.getSystemClassLoader(), file.toURI()
    					.toURL());
    		} catch (final Exception e) {
    			e.printStackTrace();
    		}
    	}

    вот так приколачиваем SWT в систему.
    особенное веселье в строках 25-28.

    Lure Of Chaos, 29 Января 2013

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

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class ClientSourceTranslator implements ITranslator
    {
      public Object map(Object input)
      {
        return String.valueOf(12);
      }
    }

    askell, 29 Января 2013

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

    +71

    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
    private String getSecondsToTimeFormat(long startTime, long finishTime) {
    
            int secs = Math.round((finishTime - startTime) / 1000);
    
            int hours = secs / 3600,
                    remainder = secs % 3600,
                    minutes = remainder / 60,
                    seconds = remainder % 60;
    
            StringBuilder result = new StringBuilder();
    
            if (hours > 0) {
                result.append((hours < 10 ? "0" : "") + hours).append(":");
            }
    
            if (minutes > 0 || hours > 0) {
                result.append((minutes < 10 ? "0" : "") + minutes).append(":");
            }
    
            if (seconds > 0 || hours > 0 || minutes > 0) {
                result.append((seconds < 10 ? "0" : "") + seconds);
            }
    
            if (hours == 0 && minutes == 0) {
                if (seconds == 1) {
                    result.append(" second");
                } else {
                    result.append(" seconds");
                }
            }
    
            return result.toString();
        }

    Задача - перевести из секунд в человеческий формат

    nafania217518, 29 Января 2013

    Комментарии (8)
  8. Куча / Говнокод #12489

    +133

    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
    .wrapper#container {
        background-color: #ffffff;
        border-style: hidden;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        margin: 0 auto 0;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        padding: 15px 20px 20px 30px;
    }

    Из сорса страницы Evernote, вообще там порядка 8к строк для 4 дивов....

    nonamez, 28 Января 2013

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

    +48

    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
    $title = get_the_title();
    if ( $title == "Portfolio")  $data['sl_portfolio_style'] = "2 Columns Portfolio";
    if ( $title == "3 Columns Portfolio")  $data['sl_portfolio_style'] = "3 Columns Portfolio";
    if ( $title == "4 Columns Portfolio")  $data['sl_portfolio_style'] = "4 Columns Portfolio";
    if ( $title == "6 Columns Portfolio")  $data['sl_portfolio_style'] = "6 Columns Portfolio";
    if ( $title == "Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=4&paged=' . $paged );
    if ( $title == "4 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=8&paged=' . $paged );
    if ( $title == "6 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "3 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=6&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Right Sidebar")  $data['portfolio_sidebar_position'] = "Right Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['portfolio_sidebar_position'] = "Left Sidebar";
    
    if ( $title == "Portfolio Left Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );

    "switch - case" - Не не слышал!
    И это в покупной теме для wordpress на тимфоресте.
    Стоимость темы - 45 уе...

    tsybulskyserg, 22 Января 2013

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

    −113

    1. 1
    http://lab.madscience.nl/oo.sh.txt

    ООП-фаги, набигайте!

    byss, 17 Января 2013

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

    +52

    1. 1
    2. 2
    3. 3
    4. 4
    $new_addresses = $_POST['friendE1']."\n".$_POST['friendE2']."\n".$_POST['friendE3']."\n".$_POST['friendE4']."\n".$_POST['friendE5']
        ."\n".$_POST['friendE6']."\n".$_POST['friendE7']."\n".$_POST['friendE8']."\n".$_POST['friendE9']."\n".$_POST['friendE10'];
    
    $list = explode( "\n", $new_addresses);

    Отакое счастье в очередном проекте :-)

    tsybulskyserg, 11 Января 2013

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