1. JavaScript / Говнокод #12423

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var checkCookie = $.cookie("nav-item");
    	if (checkCookie != "") {
        $('.top_menu  li:eq('+checkCookie+')').addClass('activeli');
      }
      else{
      }
      $('.top_menu  li').click(function(){
    	  var navIndex = $('.top_menu  li').index(this);
          $.cookie("nav-item", navIndex);
      });

    кнопочки.

    Heckfy_top, 15 Января 2013

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

    +51

    1. 1
    2. 2
    3. 3
    4. 4
    function striptags($variables_for_function=array()) {
      if (!isset($variables_for_function[1])) {$variables_for_function[1]='';}
      return strip_tags($variables_for_function[0], $variables_for_function[1]);
     }

    Только сегодня и только для вас, безопасный strip_tags. Теперь с заSHITой от говнокодеров.
    PHP Innovations.

    SunnyMagadan, 15 Января 2013

    Комментарии (2)
  3. Си / Говнокод #12421

    +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
    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
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    void dwflt_to_str(DWORD dw, char *pch, int &nsmb)
    {
      DWORD dw_a = dw;
      char ch_a;
      char tbldec[] = "0123456789";
      nsmb = 0;
      if (dw_a == 0) { pch[0] = '0'; nsmb++; goto lab2; }
      while (dw_a != 0)
      {
        pch[nsmb] = tbldec[dw_a%10]; dw_a /= 10; nsmb++;
      }
      dw_a = nsmb/2;
      while (dw_a)
      {
        ch_a = pch[nsmb - dw_a]; pch[nsmb - dw_a] = pch[dw_a - 1]; pch[dw_a - 1] = ch_a; dw_a--;
      }
    lab2:
      pch[nsmb] = 0;
    }
    
    const int n_fr2 = 7; // - эта константа определяет фиксированное число цифр после точки в выводимой строке, представляющей float.
    
    void float_to_str(float flt, char *pchar, int &nsmb)
    {
      int i, deg, ns_int, ns_frac;
      double frac_dbl;
      DWORD dw_f, mant, intg, fract;
      DW_FL f_flt;
      char szfl_int[16], szfl_frac[16];
      f_flt.fl = flt;
      dw_f = f_flt.dw;
      if (dw_f == 0) { pchar[0] = '0'; pchar[1] = '.'; pchar[2] = '0'; pchar[3] = 0; nsmb = 3; return; }
      if (dw_f & 0x80000000) { pchar[0] = '-'; } else { pchar[0] = '+'; }
      deg = int((dw_f & 0x7F800000) >> 23) - 127;
      mant = (dw_f & 0x007FFFFF) | 0x00800000;
      if (deg == 0) { intg = 1; fract = dw_f & 0x007FFFFF; goto lab_1; }
      if (deg > 0) { intg = mant >> (23 - deg); fract = ((dw_f & 0x007FFFFF) << deg) & 0x007FFFFF; goto lab_1; }
      if (deg < 0) { intg = 0; fract = ((dw_f & 0x007FFFFF) | 0x00800000) >> (-deg); }
    lab_1:
      frac_dbl = double(fract)*1.1920928955078125;// 1.1920928955078125 = 10^n_fr2 / 2^23 = 10^7 / 2^23
      fract = (int)frac_dbl;
    
      dwflt_to_str(intg, szfl_int, ns_int);
      nsmb = 1; i = ns_int; while (i) { pchar[i + 1] = szfl_int[i]; i--; } pchar[1] = szfl_int[0];
      nsmb += ns_int; pchar[nsmb] = '.'; nsmb++;
    
      dwflt_to_str(fract, szfl_frac, ns_frac); szfl_frac[n_fr2] = 0;
      i = ns_frac; while (i) { szfl_frac[6 - ns_frac + i] = szfl_frac[i - 1]; i--; }
      i = n_fr2 - ns_frac; while (i) { szfl_frac[i - 1] = '0'; i--; }
    
      i = n_fr2 - 1; while (i) { pchar[nsmb + i] = szfl_frac[i]; i--; } pchar[nsmb] = szfl_frac[0];
      nsmb += n_fr2; pchar[nsmb] = 0;
    }
    void float_to_str_exp(float flt, char *pchar, int &nsmb)
    {
      int i, deg, poli, ns_int, ns_frac, ns_poli;
      double frac_dbl;
      DWORD dw_f, mant, intg, fract;
      DW_FL f_flt;
      char szfl_int[16], szfl_frac[16];
      f_flt.fl = flt;
      dw_f = f_flt.dw;
      if (dw_f == 0) { pchar[0] = '0'; pchar[1] = '.'; pchar[2] = '0'; pchar[3] = 0; nsmb = 3; return; }
      if (dw_f & 0x80000000) { pchar[0] = '-'; } else { pchar[0] = '+'; }
      deg = int((dw_f & 0x7F800000) >> 23) - 127;
      mant = (dw_f & 0x007FFFFF) | 0x00800000;
      if (deg == 0) { intg = 1; fract = dw_f & 0x007FFFFF; goto lab_1; }
      if (deg > 0) { intg = mant >> (23 - deg); fract = ((dw_f & 0x007FFFFF) << deg) & 0x007FFFFF; goto lab_1; }
      if (deg < 0) { intg = 0; fract = ((dw_f & 0x007FFFFF) | 0x00800000) >> (-deg); }
    lab_1:
      frac_dbl = double(fract)*1.1920928955078125;// 1.1920928955078125 = 10^n_fr2 / 2^23 = 10^7 / 2^23
      fract = (int)frac_dbl;
    
      dwflt_to_str(intg, szfl_int, ns_int);
      dwflt_to_str(fract, szfl_frac, ns_frac); szfl_frac[n_fr2] = 0;
      if (intg != 0)
      {
        nsmb = 1; i = ns_int; while (i) { pchar[i + 2] = szfl_int[i]; i--; } pchar[1] = szfl_int[0];
        pchar[2] = '.'; nsmb += ns_int + 1; poli = ns_int - 1;
      }
      else
      {
        i = ns_frac - 1; while (i) { pchar[2 + i] = szfl_frac[i]; i--; } pchar[1] = szfl_frac[0];
        pchar[2] = '.'; nsmb = 3;//nsmb += ns_frac + 1;
        poli = ns_frac - n_fr2 - 1; goto lab_2;
      }
    
      i = ns_frac; while (i) { szfl_frac[6 - ns_frac + i] = szfl_frac[i - 1]; i--; }
      i = n_fr2 - ns_frac; while (i) { szfl_frac[i - 1] = '0'; i--; }
    
      i = n_fr2 - 1; while (i) { pchar[nsmb + i] = szfl_frac[i]; i--; } pchar[nsmb] = szfl_frac[0];
    lab_2:
      nsmb += n_fr2; pchar[nsmb] = 'E';
    
      int_to_str(poli, &pchar[nsmb + 1], ns_poli);
      nsmb += ns_poli + 1; pchar[nsmb] = 0;
    }

    оттуда

    TarasB, 15 Января 2013

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

    +34

    1. 1
    if (date('dmY', $lmtime) === date('dmY')) {

    Нужно было узнать, не сегодняшний ли день в отметке $lmtime.

    7ion, 15 Января 2013

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

    +13

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void SetInterruptHandler(int id, unsigned int offset) {
            __asm cli;
            unsigned int *idt = (unsigned int*)0;
            idt[id*2+0] = 0x00080000 | (offset & 0x0000FFFF);
            idt[id*2+1] = 0x00008E00 | (offset & 0xFFFF0000);
            __asm sti;
    }

    Как и обещал в http://govnokod.ru/12413#comment166763, выкладываю исходник говнолоадера, запускающего 32-х битный сишный код с дискетки: https://github.com/bormand/tryos, хотя судя по всему никому это не интересно...

    Если кому-то все-таки придет в голову странное желание это собрать - нужна вижуалка (к сожалению код написан лет 5 назад, когда я юзал вижуалку) и nasm. Путь к nasm прописываем в Makefile, запускаем nmake, полученный floppy.dsk можно скормить виртуалбоксу, или же зарезать на дискету, если удастся вспомнить как она выглядит...

    UPD: Скрин http://rghost.ru/43035733.view

    bormand, 14 Января 2013

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    <select name="animals">
    		<option value="1" addTags="<div class='kv'></div>">Медведь</option>
    		<option value="2" addTags="<input type='checkbox' />">Волк</option>
    </select>

    html в js - это прошлый век =)
    http://www.xiper.net/collect/html-and-css-tricks/verstka-form/nice-select-jquery.html

    RedMonkey, 14 Января 2013

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

    −89

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def") {
                    options.ad_started();
                    var fn:Function = function ():void {
                        options.ad_finished();
                    };
                    setTimeout(fn, 100);
                    return;
                }

    сегодня в выпуске - как задизаблить мойшеадс лёгким движением руки в любой флешке, скомпиленной со стандартной либой

    makc3d, 14 Января 2013

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

    −107

    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
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {	
    	return 6;
    }
    
    -(UITableViewCell *) tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	static NSString *kCellIdentifier = @"";
    	switch (indexPath.row) 
    	{
    		case 0:
    			kCellIdentifier = @"SpaceCell";
    			break;
    		case 1:
    			kCellIdentifier = @"LoginCell";
    			break;
    		case 2:
    			kCellIdentifier = @"PasswordCell";
    			break;
    		case 3:
    			kCellIdentifier = @"EmailCell";
    			break;
    		case 4:
    			kCellIdentifier = @"BirhtdayCell";
    			break;
    		default:
    			kCellIdentifier = @"ForgotCell";
    			break;
    	}
    	UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCellIdentifier] autorelease];
    	cell.selectionStyle = UITableViewCellSelectionStyleNone;
    	cell.backgroundColor = [UIColor clearColor];
    	cell.backgroundView.backgroundColor = [UIColor clearColor];
    
    	if (indexPath.row == 1)
    	{
    		[self backgroundCells:cell fileImage:@"top_downlayer.png"];
    		self.loginTextField.text = userName;
    		self.loginTextField.placeholder = @"User Name";
    		self.loginTextField.frame = CGRectMake(10.0f, 10.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.loginTextField];
    	}
    	else if (indexPath.row == 2)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		self.passwordTextField.text = password;
    		self.passwordTextField.placeholder = @"Password";
    		self.passwordTextField.frame = CGRectMake(10.0f, 8.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.passwordTextField];
    	}
    	else if (indexPath.row == 3)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		self.email.text = emailString;
    		self.email.placeholder = @"Email";
    		self.email.frame = CGRectMake(10.0f, 7.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.email];
    	}
    	else if (indexPath.row == 4)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		UIImageView *inputIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"input_login.png"]];
    		inputIV.frame = CGRectMake(20, 8, 280, 28);
    		[inputIV setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    		[cell addSubview:inputIV];
    		[inputIV release];
    						
    		if (![resultsDate.text length])
    		{
    			UILabel *birhtdayLabel = [[UILabel alloc] initWithFrame:CGRectMake(29, 12, 150, 20)];
    			birhtdayLabel.text = @"Birthday";
    			[birhtdayLabel setTextAlignment:UITextAlignmentLeft];
    			[birhtdayLabel setFont: [UIFont fontWithName:@"Arial" size:17.0f]];
    			[birhtdayLabel setTextColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.25]];
    			[birhtdayLabel setHighlightedTextColor:[UIColor whiteColor]];
    			[birhtdayLabel setBackgroundColor:[UIColor clearColor]];
    			[birhtdayLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    			[cell addSubview:birhtdayLabel];
    			[birhtdayLabel release];
    		}
    		else
    			[cell addSubview:resultsDate];
    	}
    	else if (indexPath.row == 5)
    	{
    		[self backgroundCells:cell fileImage:@"down_downlayer.png"];
    		UIImage *buttonBackgroundPressed = [UIImage imageNamed:@"search_btn_act.png"];
    		UIImage *buttonBackground = [UIImage imageNamed:@"search_btn.png"];
    		UIButton *singUpButton = [CustomButton buttonWithTitle:@"SIGN UP" target:self selector:@selector(singUpTouchAction:) frame:CGRectMake(20, 6, 280, 28) image:buttonBackground imagePressed:buttonBackgroundPressed];
    		singUpButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    		singUpButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    		[cell addSubview:singUpButton];
    	}
    	return cell;
    }

    Старый проект. Открыл класс наугад.

    Так кто-то строил форму для регистрации юзера. Каждое поле в форме - уникально.

    QuickNick, 14 Января 2013

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

    +55

    1. 1
    2. 2
    3. 3
    $result["rg"][count($result["rg"])-1]["status"][] = Array();
    $c_res = count($result["rg"][count($result["rg"])-1]["status"])-1;
    $result["rg"][count($result["rg"])-1]["status"][$c_res] = $arr_source_data[$i];

    Им за число строк платят, что ли?

    clauclauclau, 14 Января 2013

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var onClear = function(e)
                {
                    if(e.value == "Логин" || e.value == "Пароль")
                        {
                            e.value = "";
                        }
                }

    <input type="text" name="login" value="Логин" onclick="onClear(this);"/>
    Ох блин...

    Govnisti_Diavol, 14 Января 2013

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