1. Си / Говнокод #5220

    +130

    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
    char unsigned c;
    DWORD m;
    DWORD n;
    int i = 0;
    BOOL b = TRUE;
    
    HANDLE hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    if (hFile == INVALID_HANDLE_VALUE) 
    { 
    	printf("Could not open File");
    	return NULL;
    } 
    // узнаем размер файла
    while (b)
    {
    	b = ReadFile(hFile, &c, 1, &m, NULL);
    	if (m == 0)
    	{
    		printf("STOP ");
    		printf("%i\n", i);
    		break;
    	}
    	i++;
    }

    собственно узнаем размер файла, что тут еще скажешь)

    dIsoVi, 11 Января 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    switch($type) {
    case 0:
    	$r_type = 0;
    	break;
    case 2:
    	$r_type = 2;
    	break;
    case 1:
    	$r_type = 1;
    	break;
    }

    нашел в своем старом коде.

    luethus, 11 Января 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    /// <summary>
    /// I hate you guys.
    /// You guys are assholes.
    /// Especially author of this class.
    /// I hate him the most.
    /// </summary>
    public partial class ProfileEditor

    Semargl, 11 Января 2011

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

    +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
    void Attr::setConvertedValue(std::string pValue)
    {
        /* ............. - BEGIN - Place the HTML code instead of the */
        /* plain values. This is needed since special XML characters      */
        /* might exist.                                                   */
        for(int i = 0; i < pValue.length(); i++)
        {
            int ascii = (int)pValue[i];
    
            if(!( (ascii == 32 ) ||
                  (ascii >= 48 && ascii <= 57) ||
                  (ascii >= 65 && ascii <= 90) ||
                  (ascii >= 97 && ascii <= 122) ) )
            {
                if( ascii < 0 )
                    ascii += 256;
    
                std::ostringstream stream;
                stream << ascii;
    
                std::string newString = stream.str();
                newString = "&#" + newString + ';';
    
                pValue.replace(i, 1, newString);
    
                i += newString.length() - 1;
            }
        }
        /* ............. - END - Place the HTML code instead of the */
        /* plain values. This is needed since special XML characters      */
        /* might exist.                                                   */
        mConvertedValue = pValue;
    }

    я стою на асфальте, ноги в лыжы абуты.

    мы эскайпим значения для ХМЛ.

    вы тут посмейтесь, а я пошел головой об стенку стучатся.

    ЗЫ пысано в Бразилии.

    Dummy00001, 11 Января 2011

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

    +153

    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
    function ini_size_to_bytes($value)
    {
    	$value = trim($value);
    	$retval = intval($value);
    
    	switch(strtolower($value[strlen($value) - 1]))
    	{
    		case 'g':
    			$retval *= 1024;
    			/* break missing intentionally */
    		case 'm':
    			$retval *= 1024;
    			/* break missing intentionally */
    		case 'k':
    			$retval *= 1024;
    			break;
    	}
    
    	return $retval;
    }

    vBulletin 4.0.3 (лицензионка, есть согласие на публикацию)

    Vitaly44, 11 Января 2011

    Комментарии (11)
  6. JavaScript / Говнокод #5215

    +159

    1. 1
    2. 2
    3. 3
    for (i = 1; i < <?php echo count($prog[1])?>; i++){
         if (document.getElementById('module'+i).checked)
            	module_tmp= Math.abs($('#module'+i).val())+module_tmp;

    1_and_0, 11 Января 2011

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

    −85

    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
    private function createPanel(isPlay:String):void
    {
    	if(NativeApplication.supportsSystemTrayIcon){
    		iconMenu.removeAllItems();
    		if(isPlay!='play')
    		{
    			var playCommand:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Воспроизвести")); 
    			playCommand.addEventListener(Event.SELECT, playHandler);
    		}
    		if(isPlay=='play')
    		{
    			var pauseCommand:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Пауза")); 
    			pauseCommand.addEventListener(Event.SELECT, pauseHandler); 
    		}
    		if(isPlay!='stop'){				
    			var stopCommand:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Стоп")); 
    			stopCommand.addEventListener(Event.SELECT, stopHandler);
    		}
    	
    		/*----Volume------*/
    		var vulumeNativeMenu:NativeMenu = new NativeMenu();				
    		var volumeSubMenu:NativeMenuItem = iconMenu.addSubmenu(vulumeNativeMenu,'Громкость');
    		
    		var volume100:NativeMenuItem = vulumeNativeMenu.addItem(new NativeMenuItem("100%")); 
    		volume100.addEventListener(Event.SELECT, volume100Handler);
    
    		var volume75:NativeMenuItem = vulumeNativeMenu.addItem(new NativeMenuItem("75%")); 
    		volume75.addEventListener(Event.SELECT, volume75Handler);
    				
    		var volume50:NativeMenuItem = vulumeNativeMenu.addItem(new NativeMenuItem("50%")); 
    		volume50.addEventListener(Event.SELECT, volume50Handler);
    				
    		var volume25:NativeMenuItem = vulumeNativeMenu.addItem(new NativeMenuItem("25%")); 
    		volume25.addEventListener(Event.SELECT, volume25Handler);
    		/*----End Volume------*/
    				
    		var exitCommand:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Выход")); 
    		exitCommand.addEventListener(Event.SELECT, exinHandler);
    
    	}
    }

    Немного моего айро-высера... Думать было ой как в лом =)

    KirAmp, 11 Января 2011

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

    +160

    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
    <?php
     include '/system/config_bd.php'; // соединение с базой
     
    class pagination_start {
    public $page;
    public $CountListPage=10; 
    public $sql="SELECT * FROM `news`";
    public $start;
    public $limit;
    public $ires;
     
    public function page_settings() {
    $this->page_get();
    $this->start=($this->page-1)*$this->CountListPage; 
    $this->limit=" LIMIT $this->start,$this->CountListPage";
    $this->ires=mysql_query($this->sql.$this->limit);
    }
     
    public function page_get() {
    if(empty($_GET['page'])){$this->page=1;} 
    else {$this->page=$_GET['page'];} 
    }
    }
     
    class pagination_end extends pagination_start{
    public $link_interval;
    public $i;
    public $sp;
     
    public function pagination($class_all,$class_once) {
     $link_page = '';
     $this->page_get();
     $count=mysql_num_rows(mysql_query($this->sql)); 
     if($count>$this->CountListPage){ 
    $CountList=ceil($count/$this->CountListPage); 
     if($this->page > 3 && $CountList > 5){echo '<span class="'.$class_all.'"><a href="?page=1'.$this->link_interval.'">1</a></span><span class="'.$class_all.'">...</span>';} 
    if($this->page > 3 && $CountList > 5){$this->sp=$this->page-2;}else{$this->sp=1;} 
    if($this->page > $CountList-3 && $CountList > 5){$this->sp=$CountList-4; } 
    if($CountList>5)$cpc=5;else $cpc=$CountList; 
    for($this->i=$this->sp;$this->i<$this->sp+$cpc;$this->i++){ 
     
    if($this->i == $this->page){  printf ('<span class="'.$class_once.'">%s</span>',$this->i); }
    else{ $suit=$this->link_interval.$this->i; 
    $links_cent = '<span class="'.$class_all.'"><a href="?page='.$suit.'">'.$this->i.'</a></span>';
     echo $links_cent;  } } 
    $suit=$this->link_interval."?page=".$CountList.""; 
    if($this->page<=$CountList-3 and $CountList>5){echo '<span class="'.$class_all.'">...</span>  <span class="'.$class_all.'"><a href="'.$suit.'">'.$CountList.'</a></span> ';} }
    }
    }
    
    $CountListPage = 5;   // Сколько объектов отображать на странице # по умолчанию 10
    $sql="SELECT * FROM `news` ";  // SQL запрос # по умолчанию "SELECT * FROM `news`"
    $class_all='page_all'; // Css класс всех страниц кроме текущей
    $class_once='class_once'; // Css класс всех страниц кроме текущей
    
    /* Формирование страниц и sql запрос */
    $pagination = new pagination_start();
    $pagination->CountListPage = $CountListPage;
    $pagination->sql = $sql;
    $pagination->page_settings();
    while($ires_result=mysql_fetch_array($pagination->ires))
    {
    echo $ires_result['id']."<br/>";
    } 
    /* Пагенирование */
    $pagination_end = new pagination_end();
    $pagination_end->CountListPage = $CountListPage;
    $pagination_end->sql = $sql;
    $pagination_end->pagination($class_all,$class_once); // От css клас от 2 страници до предпоследней

    qbasic, 11 Января 2011

    Комментарии (238)
  9. Objective C / Говнокод #5212

    −314

    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
    #pragma mark -
    #pragma mark Table view delegate
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	if (indexPath.section == 3 && indexPath.row == 0) {
    		CGSize fitSize = [[item objectForKey:@"note"]
    							sizeWithFont:[UIFont boldSystemFontOfSize:18]
    							constrainedToSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 50, MAXFLOAT)
    							lineBreakMode:UILineBreakModeWordWrap];
    		
    		return fitSize.height;
    	}
    	
    	return [self.tableView rowHeight];
    }

    Я тут на Objective C говнокодить стал, вот моя почти первая аппса
    http://itunes.apple.com/ru/app/qx9pro/id408832020?mt=8

    striker, 11 Января 2011

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

    +37

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    error_log('json_upload(): called');
    error_log('json_upload(): dump $_POST');
    foreach(explode("\n", var_export($_POST, TRUE) ) as $val) error_log('advupload_json_upload() dump: ' . $val);
    error_log('json_upload(): dump $_GET');
    foreach(explode("\n", var_export($_GET, TRUE) ) as $val) error_log('advupload_json_upload() dump: ' . $val);

    отладка аццкого json вызова который вызываецо с клиента для загрузке файла покускам.
    думать было лень. наговнякал :)
    потом tail -f /var/log/apache2/errors.log в консоли и фпирет

    brainstorm, 11 Января 2011

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