1. C# / Говнокод #10474

    +101

    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
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    private void FillLocalService(int SelectedPageIndex)
            {
                //Set category by search
                string search = inputSearch.Value == inputSearchValue ? string.Empty : inputSearch.Value;
                if (inputSearch.Value != inputSearchValue && !string.IsNullOrWhiteSpace(inputSearch.Value))
                {
                    if (inputSearch.Value.StartsWith("landscap", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Landscapers";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("baby sitter", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Baby sitters";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("doctor", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Doctor";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("cleaning service", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Cleaning services";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("pet sitter", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Pet sitters";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("handyman", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Handyman";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("electrical service", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Electrical services";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("tutor", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Tutor";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("dog walker", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Dog walker";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("plumb", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Plumbing";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.StartsWith("Caterer", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Caterers";
                        search = string.Empty;
                    }
                    else if (inputSearch.Value.Equals("misc", StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectedCategory = "Misc";
                        search = string.Empty;
                    }
                }
    
    200+ строк кода
    }

    тот же девелопер, та же .aspx страница)))))

    mangyst, 30 Мая 2012

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $update_result = mysql_query($update) or die("failed");
    	
    	if($update_result != false)
    		header("location: index.php");
    	else
    		die("Something Failed.");

    Rusik58, 30 Мая 2012

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

    −32

    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
    //
    //	std::string wrapper
    //
    namespace priv {
    	class string {
    		std::string &m_s;
    
    		std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
    		std::string &(std::string::*m_pAssign2)( const char * );
    
    	public:
    		string( std::string &str ): m_s(str),
    			m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
    
    		string &assign( const char *s, std::string::size_type n )
    		{
    			(m_s.*m_pAssign1)( s, n ); return *this;
    		}
    		string &assign( const char *s )
    		{
    			(m_s.*m_pAssign2)( s ); return *this;
    		}
    	};
    }

    сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
    наткнулся в одной из либ на вот это

    defecate-plusplus, 30 Мая 2012

    Комментарии (11)
  4. Си / Говнокод #10465

    +123

    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
    #include <stdio.h>
    int getLen(long long num)
    {
        int count=0;
        while (num > 0)
        {
            count++;
            num/=10;
        }
        return count;
    }
    
    int main(void)
    {
        int count = 0;
        for (long long i=1; i<=9; i++)
        {
            long long num = 1;
            int modify=0;
    
            for (int j=1; j<30; j++)
            {
                if (i==7 && j == 5)
                {
                    int a= 1;
                    a++;
                }
                num *= i;
                if (getLen(num) == j-modify)
                {
                    printf("%d^%d=%lld OK  %d\n", i, j, num, count+1);
                    count++;
                }
                if (num > 10000000)
                {
                    num/=10;
                    modify++;
                }
            }
        }
        printf("%d\n", count);
        return 0;
    }

    http://projecteuler.net/problem=63
    http://projecteuler.net/thread=63&page=8



    >I don't want to write again an big number rendering algorithm, so I played a little trick on it and hoped it won't cause any trouble..

    TheHamstertamer, 30 Мая 2012

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

    +112

    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
    switch (SelectedCategory)
                {
                    case "Landscapers":
                        inputSearch.Value = "Landscapers";
                        break;
    
                    case "Baby sitters":
                        inputSearch.Value = "Baby sitters";
                        break;
    
                    case "Doctor":
                        inputSearch.Value = "Doctor";
                        break;
    
                    case "Cleaning services":
                        inputSearch.Value = "Cleaning services";
                        break;
    
                    case "Pet sitters":
                        inputSearch.Value = "Pet sitters";
                        break;
    
                    case "Handyman":
                        inputSearch.Value = "Handyman";
                        break;
    
                    case "Electrical services":
                        inputSearch.Value = "Electrical services";
                        break;
    
                    case "Tutor":
                        inputSearch.Value = "Tutor";
                        break;
    
                    case "Dog walker":
                        inputSearch.Value = "Dog walker";
                        break;
    
                    case "Plumbing":
                        inputSearch.Value = "Plumbing";
                        break;
    
                    case "Caterers":
                        inputSearch.Value = "Caterers";
                        break;
    
                    case "Misc":
                        inputSearch.Value = "Misc";
                        break;
                }

    обычный switch

    mangyst, 30 Мая 2012

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

    −37

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    int LoggingProvider::AddJournalPackingLogRecord(int eventId, const astring& userId, 
                                                  const std::vector<std::string>& journals, int errorId, int devCode,
                                                  int sysCode, const astring& errorArgs)
    {
        std::string strUserId(userId.c_str()), strErrorArgs(errorArgs);
    
        return AddJournalPackingLogRecord(eventId, userId, journals, errorId, devCode, sysCode, strErrorArgs);
    }

    Рекурсия!

    tob1az, 30 Мая 2012

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

    −96

    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
    while true
    do
      if [ $variable -le $null ]; then                                     #### if then 1
        vmm=`expr $vmm + 1`
        if [ $vmm -eq `expr 13` ]; then
         vmm=`expr 1`
        fi
        imm=`expr $imm - 1`
        if [ $imm -eq $null ]; then
         imm=`expr 12` vyy=`expr $vyy + 1`
        fi
        idd=`expr ${month[$imm]} + $variable`
        if [ $idd -gt $null ]; then
         if [ $imm -lt 10 ]; then
          imm=0$imm
         fi
         if [ $idd -lt 10 ]; then
          idd=0$idd
         fi
         calc_date=`expr $current_year - $vyy`$imm$idd
         break;
        else                                                               #### else 1
         variable=`expr ${month[$imm]} + $variable`
        fi
      else
         if [ $imm -lt 10 ]; then
          vmm=0$imm
         else
          vmm=$imm
         fi
       if [ $variable -lt 10 ]; then
        variable=0$variable
       fi
       calc_date=`expr $current_year - $vyy`$vmm$variable
       break;
      fi
    done
    echo $calc_date
    
    #Альтернативный (нормальный) вариант
    calc_date=`perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-'$period*86400';'`

    Дата и время в нужном формате

    paa, 30 Мая 2012

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

    +155

    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
    var nav = document.getElementById('navigation');
    
    var properties = {
    	'display' : 'block',
    	'position' : 'fixed',
    	'top' : '5px',
    	'backgroundColor' : '#F2F0E3',
    	'opacity' : '.6',
            ........
            //Много всяких свойств
            ........
    	'border' : '2px solid #DDDDDD',
    	'borderRadius' : '1em',
    	'padding' : '5px',
    	'zIndex' : '1'
    }
    
    for (var i in properties) {
    	nav.style[i] = properties[i];
    }

    Послать бы автора на три буквы: CSS

    vistefan, 30 Мая 2012

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

    −118

    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
    SELECT x.org_spec_id, (
                    SELECT count(c.id) FROM customers c , government_customers_require gcr               
                    WHERE c.org_spec_id=x.org_spec_id AND gcr.customer_id=c.id                
                ) as bal_ins, 
                sum(x.type_b1) as type_b1, sum(x.type_b2) as type_b2, sum(x.type_b3) as type_b3, sum(x.bus_debit) as bus_debit,
                sum(x.gost_ac1) as gost_ac1, sum(x.gost_ac2) as gost_ac2, sum(x.nav_ac1) as nav_ac1, sum(x.nav_ac2) as nav_ac2,
                \'-\' as price1, \'-\' as price2, \'-\' as price3, \'-\' as price4, sum(x.scope_b1) as scope_b1,
                sum(x.scope_b2) as scope_b2, sum(x.scope_b3) as scope_b3, sum(x.scope_b4) as scope_b4, sum(x.scope_b5) as scope_b5,
                sum(x.scope_b6) as scope_b6, sum(x.add11) as add11, sum(x.add12) as add12, sum(x.add21) as add21, 
                sum(x.add22) as add22, sum(x.add23) as add23, sum(x.add31) as add31, sum(x.add32) as add32, sum(x.add33) as add33
                
                FROM (SELECT c.org_spec_id, b.id , c.id as bal_ins,
                case when bsd.id is not null then 1 else 0 end as bus_debit,
                case when bsd.id is null then case when bm.type_id = 1 then 1 else 0 end else 0 end as type_b1, 
                case when bsd.id is null then case when bm.type_id = 2 then 1 else 0 end else 0 end as type_b2, 
                case when bsd.id is null then case when bm.type_id = 3 then 1 else 0 end else 0 end as type_b3,            
                case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 1 else 0 end else 0 end as gost_ac1,
                case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 0 else 1 end else 0 end as gost_ac2,
                case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 1 else 0 end else 0 end as nav_ac1,
                case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 0 else 1 end else 0 end as nav_ac2,
                case when bsd.id is null AND b.scope_id = 2 then 1 else 0 end as scope_b1,
                case when bsd.id is null AND b.scope_id = 1 then 1 else 0 end as scope_b2,
                case when bsd.id is null AND b.scope_id = 3 then 1 else 0 end as scope_b3,
                case when bsd.id is null AND b.scope_id = 4 then 1 else 0 end as scope_b4,
                case when bsd.id is null AND b.scope_id = 6 then 1 else 0 end as scope_b5,
                case when bsd.id is null AND b.scope_id = 5 then 1 else 0 end as scope_b6,
                case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'on\' then 1 else 0 end else 1 end else 0 end as add11,
                case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add12,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add21,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add22,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add23,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add31,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add32,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add33

    asfalanaft, 29 Мая 2012

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

    +66

    1. 1
    Как вас зовут?

    uiopqwertyasd, 29 Мая 2012

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