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

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

    −106

    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
    # progress bar
    
    width = 60  # width of bar
    com   = 540 # input data
    
    pr = com * 0.01
    i = 0
    j = width
    
    v = 1
    puts
    while pr <= com
    
      print "\r#{v}% [#{"|"*i}#{" "*j}]"
    
      pr += com * 0.01  
    
      i += width * 0.01
      j -= width * 0.01
    
      v += 1  
      
      sleep(0.01)
      
    end
    puts

    Консольный прогресс-бар.

    delmind, 25 Марта 2011

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

    +164

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    if (VDIC_web_form_address.match(regWFAcustom))
    	{
    	URLDecode(VDIC_web_form_address,'YES');
    	TEMP_VDIC_web_form_address = decoded;
    	TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAcustom, '');
    	}
    else
    	{
    	web_form_vars = 
    	"&lead_id=" + document.vicidial_form.lead_id.value + 
    	"&vendor_id=" + document.vicidial_form.vendor_lead_code.value + 
    	"&list_id=" + document.vicidial_form.list_id.value + 
    	"&gmt_offset_now=" + document.vicidial_form.gmt_offset_now.value + 
    	"&phone_code=" + document.vicidial_form.phone_code.value + 
    	"&phone_number=" + document.vicidial_form.phone_number.value + 
    	"&title=" + document.vicidial_form.title.value + 
    	"&first_name=" + document.vicidial_form.first_name.value + 
    	"&middle_initial=" + document.vicidial_form.middle_initial.value + 
    	"&last_name=" + document.vicidial_form.last_name.value + 
    	"&address1=" + document.vicidial_form.address1.value + 
    	"&address2=" + document.vicidial_form.address2.value + 
    	"&address3=" + document.vicidial_form.address3.value + 
    	"&city=" + document.vicidial_form.city.value + 
    	"&state=" + document.vicidial_form.state.value + 
    	"&province=" + document.vicidial_form.province.value + 
    	"&postal_code=" + document.vicidial_form.postal_code.value + 
    	"&country_code=" + document.vicidial_form.country_code.value + 
    	"&gender=" + document.vicidial_form.gender.value + 
    	"&date_of_birth=" + document.vicidial_form.date_of_birth.value + 
    	"&alt_phone=" + document.vicidial_form.alt_phone.value + 
    	"&email=" + document.vicidial_form.email.value + 
    	"&security_phrase=" + document.vicidial_form.security_phrase.value + 
    	"&comments=" + document.vicidial_form.comments.value + 
    	"&user=" + user + 
    	"&pass=" + pass + 
    	"&campaign=" + campaign +
    	"&phone_login=" + phone_login + 
    	"&original_phone_login=" + original_phone_login +
    	"&phone_pass=" + phone_pass + 
    	"&fronter=" + fronter + 
    	"&closer=" + user + 
    	"&group=" + group + 
    	"&channel_group=" + group + 
    	"&SQLdate=" + SQLdate + 
    	"&epoch=" + UnixTime + 
    	"&uniqueid=" + document.vicidial_form.uniqueid.value + 
    	"&customer_zap_channel=" + lastcustchannel + 
    	"&customer_server_ip=" + lastcustserverip +
    	"&server_ip=" + server_ip + 
    // ...еще строчек 30...
    	"&user_custom_five=" + VU_custom_five + '' +
    	"&preset_number_a=" + CalL_XC_a_NuMber + '' +
    	"&preset_number_b=" + CalL_XC_b_NuMber + '' +
    	"&preset_number_c=" + CalL_XC_c_NuMber + '' +
    	"&preset_number_d=" + CalL_XC_d_NuMber + '' +
    	"&preset_number_e=" + CalL_XC_e_NuMber + '' +
    	"&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' +
    	"&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' +
    	webform_session;
    	
    	var regWFspace = new RegExp(" ","ig");
    	web_form_vars = web_form_vars.replace(regWF, '');
    	var regWF = new RegExp("\\`|\\~|\\:|\\;|\\#|\\'|\\\"|\\{|\\}|\\(|\\)|\\*|\\^|\\%|\\$|\\!|\\%|\\r|\\t|\\n","ig");
    	web_form_vars = web_form_vars.replace(regWFspace, '+');
    	web_form_vars = web_form_vars.replace(regWF, '');
    
    	var regWFAvars = new RegExp("\\?","ig");
    	if (VDIC_web_form_address.match(regWFAvars))
    		{web_form_vars = '&' + web_form_vars}
    	else
    		{web_form_vars = '?' + web_form_vars}
    
    	TEMP_VDIC_web_form_address = VDIC_web_form_address + "" + web_form_vars;
    
    	var regWFAqavars = new RegExp("\\?&","ig");
    	var regWFAaavars = new RegExp("&&","ig");
    	TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAqavars, '?');
    	TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAaavars, '&');
    	}

    7ion, 20 Марта 2011

    Комментарии (1)
  4. JavaScript / Говнокод #6037

    +161

    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
    var BrowseWidth = 0;
    	var BrowseHeight = 0;
    
    	function getInsideBrowse() 
    		{
    		var ns = navigator.appName == "Netscape";
    		if (ns) 
    			{
    			BrowseWidth = window.innerWidth;
    			BrowseHeight = window.innerHeight;
    			}
    		else 
    			{
    			BrowseWidth = document.body.clientWidth;
    			BrowseHeight = document.body.clientHeight;
    			}
    		}
    	function browser_dimensions() 
    		{
    		getInsideBrowse();
    
    		document.vicidial_form.JS_browser_width.value = BrowseWidth;
    		document.vicidial_form.JS_browser_height.value = BrowseHeight;
    		}

    7ion, 20 Марта 2011

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

    +120

    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
    if (clr1 != Color.Black && clr2 != Color.Black)
                {
                    int R1 = clr1.R > clr2.R ? clr1.R - 1 : clr1.R + 1;
                    int R2 = clr1.R < clr2.R ? clr1.R - 1 : clr1.R + 1;
                    int G1 = clr1.G > clr2.G ? clr1.G - 1 : clr1.G + 1;
                    int G2 = clr1.G < clr2.G ? clr1.G - 1 : clr1.G + 1;
                    int B1 = clr1.B > clr2.B ? clr1.B - 1 : clr1.B + 1;
                    int B2 = clr1.B < clr2.B ? clr1.B - 1 : clr1.B + 1;
                    if (R1 > 255) R1 = 255; if (R1 < 0) R1 = 0;
                    if (R2 > 255) R2 = 255; if (R2 < 0) R2 = 0;
                    if (G1 > 255) G1 = 255; if (G1 < 0) G1 = 0;
                    if (G2 > 255) G2 = 255; if (G2 < 0) G2 = 0;
                    if (B1 > 255) B1 = 255; if (B1 < 0) B1 = 0;
                    if (B2 > 255) B2 = 255; if (B2 < 0) B2 = 0;
    
                    outp.b = Color.FromArgb(R1, G1, B1); outp.a = Color.FromArgb(R2, G2, B2);
                }

    Нашёл у себя такого красавца годичной давности - суровое "плавное" целочисленное интерполирование двух цветов для Compact Framework.

    RaZeR, 19 Марта 2011

    Комментарии (1)
  6. PHP / Говнокод #6017

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /*
     * Корректировка даты.
     *	если дата в будущем - то показываем сегодня.
     */
    
    $row['created'] = ( strtotime( date("Y-m-d", strtotime($row['created'])) ) > strtotime( date("Y-m-d") ) )? 
    		date("r")
    		: date("r", strtotime($row['created']));

    4x4 off-road racing...

    istem, 17 Марта 2011

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

    +165

    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
    //ip address checking function
    //for real use should have a return value but example code
    function testipaddress ($nametotest) {
        $ipaddress = $nametotest;
        $ipaddress = gethostbyname($nametotest);
        if ($ipaddress == $nametotest) {
            echo "No ip address for host, so host "
                 . "not currently available in DNS and "
                 . "probably offline for some time<BR>";
        }
        else {
            echo "good hostname, ipaddress = $ipaddress<BR>";
        }
    }

    Пользовательские комментарии на php.net - это тот ещё кладезь.
    http://www.php.net/manual/en/function.gethostbyname.php

    0__1, 10 Марта 2011

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

    +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
    function make_category_select($name,$selected='',$not='',$additional='')
            {
                    global $udb,$admin,$evoLANG,$cat_cache;
                    
                    $this->parent_name = $this->parent_name != "" ? $this->parent_name : $evoLANG['noparent'];
            
                    if ($this->onlyoptions != 1)
                    {
                            $a .= "<select name=\"".$name."\" ".$additional.">\n";
                    }
                    
                    $a .=  '<option value=""> '.$this->parent_name." </option>\n";
                    
     
                    $a .= $this->make_cat_options('0',$selected,1,$not);
     
                    if ($this->onlyoptions != 1)
                    {
                            $a .= '</select>';
                    }
     
                    return $a;
            }

    qbasic, 06 Марта 2011

    Комментарии (1)
  9. Java / Говнокод #5885

    +76

    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
    public void run() {
    		try {
                        System.out.println("START QUOTE RECEIVER SERVER SOCKET..............");
                        try
                        {
                            Thread.sleep(5000);
                        }
                        catch (Exception ex) {}
                        System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    
    			ServerSocket serverSocket = new ServerSocket(port);
    			while (!isInterrupted()) {
    				new RemoteDataReceiver(serverSocket.accept());
    			}
    			serverSocket.close();
    		} catch (IOException e) 
                    {
                        e.printStackTrace();
    		}
    	}

    Русская синхронизация. Бессмысленная и беспощадная...

    papuas_guinea, 04 Марта 2011

    Комментарии (1)
  10. Python / Говнокод #5881

    −91

    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
    #coding=utf8
     
    #Ввод коэффициентов
    def inputVar():
        a=raw_input('Enter a')
        b=raw_input('Enter b')
        c=raw_input('Enter c')
        return a,b,c
    #Вывод исходного уравнения в виде ax^2+bx+c=0
    def printHeader(a,b,c):
        import math
        ax2=str(a)*bool(a)*bool(a-1)+'x^2'*bool(a)+'+'*bool(b+math.fabs(b))*bool(a)
        bx1=str(b)*bool(b)*bool(b-1)+'x'*bool(b)+'+'*bool(c+math.fabs(c))*bool(bool(a)+bool(b))
        cx0=str(c)*bool(c)+'0'*bool(not(bool(bool(a)+bool(b)+bool(c))))
        print '\n\nУравнение:',ax2+bx1+cx0+' = 0'
    #Подсчет и вывод корней уравнения    
    def printRoots(a,b,c):
        D=b**2-4*a*c
        import math
        import cmath
        if a:
            if D>0:
                x1=(-b+math.sqrt(D))/(2*a)
                x2=(-b-math.sqrt(D))/(2*a)
                print "Корни уравнения:\n","x1 =",x1,"\nx2 =",x2
            if D==0:
                x1=(-b)/(2*a)
                x2=x1
                print "Корень уравнения:\n","x1 = x2 =",x1
            if D<0:
                print "Корни уравнения:"
                print 'x1 = '+str((-b)/(2*a))*bool(b)+'+'*bool(b)+str(cmath.sqrt(D)/(2*math.fabs(a)))
                print 'x2 = '+str((-b)/(2*a))*bool(b)+'-'*bool(b)+str(cmath.sqrt(D)/(2*math.fabs(a)))
        elif b:
            x1=-c/b
            x2=x1
            print'Корень уравнения:\n','x =',x1
        elif c:
            print'Уравнение неверно'
        else:
            print'Уравнение верно'
    #Тело программы             
    a,b,c=inputVar()
    a=int(a); b=int(b); c=int(c)
    printHeader(a,b,c)
    printRoots(a,b,c)

    Juris_Kabanis, 04 Марта 2011

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

    +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
    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
    function get_products($category_id=0) {
    /* get all the products under this category */
    
    	$qid = db_query("
    	SELECT
    		 p.id
    		,p.name
    		,p.description
    		,p.price
    		,p.on_special
    		,p.images
                    ,p.big_image
                    ,p.price2
                    ,p.price3 
    		,pc.category_id
    	FROM
    		 products p
    		,products_categories pc
    	WHERE p.id = pc.product_id
    		AND pc.category_id = $category_id
    ORDER BY p.name
    	");
    
    	return $qid;
    }
    ?>
    <h2><? print_category_tree_collection($id)?></h2>
    <table border=0 bordercolor=white>
    <tr><td class=h2>
                      <? if (db_num_rows($qid_c) == 0) { ?>
     			<? while ($cat = db_fetch_object($qid_c)) { ?>
                    <li><a href="../collection/?id=<?=$cat->id?>"><? pv($cat->name) ?></a>
               	<? } ?>
                    <? } ?>
    </td>
    </tr>

    ну где-то так нужно писать :)

    tranquillity, 03 Марта 2011

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