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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private bool validDir(DirectoryInfo dir)
    {
    	return dir.Attributes == FileAttributes.Directory &&
    	dir.Attributes != FileAttributes.Hidden &&
    	dir.Attributes != FileAttributes.NotContentIndexed &&
    	dir.Name != "Windows";
    }

    GoodTalkBot, 04 Мая 2011

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

    +68

    1. 1
    2. 2
    3. 3
    #KPACHblu {COLOR:#FF0000 !IMPORTANT;}
    #KPACHblu .CuHuu {COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;}
    #KPACHblu .3EJlEHblu {COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;}

    stuffort, 04 Мая 2011

    Комментарии (24)
  3. PHP / Говнокод #6545

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function unlinkFile($filename) {
      if(unlink($filename)) {
        return true;
      }
    }
    	
    function unsetVar($varname) {
      unset($varname);
      return true;
    }

    Одна из "библиотек" крупного зарубежного коммерческого проекта.

    Ring, 04 Мая 2011

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

    +112

    1. 1
    2. 2
    3. 3
    4. 4
    foreach (int i in new int[] {1, 2, 3, 4, 5}) 
    {
         //Какие-то действия
    }

    Правильный for в C#
    http://2lx.ru/2010/03/pravilnyj-for-v-c/

    zheka, 04 Мая 2011

    Комментарии (22)
  5. Си / Говнокод #6543

    +132

    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
    static int
    find_entry (int store, int entry, int *buffer)
      {
        int
    	i,
    	next;
    
        if ((entry <= 0) || (entry > Headers[store].size))
          {
    	*buffer = EOL;
    	return (ST_NOENTRY);
          }
    
        if (entry < (Headers[store].size/2))
          {
    		/* search forwards through store */
    		next = Headers[store].first;
    		for (i=1; i<entry; i++)
    			next = Buffers[next].next;
    		*buffer = next;
          }
    	  else
          {
    		/* search backwards through store */
    		next = Headers[store].last;
    		for (i=Headers[store].size; i>entry; i--)
    			next = Buffers[next].prev;
    		*buffer = next;
          }
    
        return (SUCCESS);
      }

    древний и заведомо рабочий код. а ищем-то что?

    ilardm, 04 Мая 2011

    Комментарии (12)
  6. Си / Говнокод #6542

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    const bool ejected = (device_type.is_new_protocol() ? device_status.status.stop : (!device_status.status.in_preset && !device_status.status.in_preset)) != 0;
    ...
    if (  (p_ddevice && p_ddevice->preset_state.in_progress ())
       || (p_edevice && p_edevice->preset_state.in_progress ())
       )
       return (CTRL_WAIT);
    ...

    я не повторяюсь никогда никогда

    ilardm, 04 Мая 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if(!$price){
        $price = 'ФОЛСУ РАВЕН';
    }
    ...
    {
    ...
        $_SESSION['BASKET']['ITEMS'][$id]['PRICE'] = $price['PRICE'];
    }

    egych, 04 Мая 2011

    Комментарии (12)
  8. Си / Говнокод #6540

    +102

    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
    if (nchan == 1)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 2)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 3)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 4)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 5)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 6)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 7)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],sub_window_length,main_window_length,out_dir,decon_c);
      }
    ...
      }
      if (nchan >= 14)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],chan_list[7],chan_list[8],chan_list[9],chan_list[10],chan_list[11],chan_list[12],chan_list[13],sub_window_length,main_window_length,out_dir,decon_c);
      }

    Тяжело в сях работать со строками и переменным числом параметров...

    Eyeless, 04 Мая 2011

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

    −850

    1. 1
    -- Таблица в БД имеет колонку Visible, при этом значение 0 означает "Видим", а 1 - "Не видим"

    Ordos, 04 Мая 2011

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

    +134

    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
    function ()	
            local res = false
    
    	for j = 1, hE do
    		if () then
    		elseif () or () then
    		elseif () or () then
    		else
    			res = true
    		end
    	end
    	if not res then
    		return res
    	end
    	return true
    end

    Код взят из миниигры в разрабатываемой казуалке.
    Первое непонятно накуя выпендриваться с кучей условий с пустыми телами, если результат получим только в одном случае.
    Второе вообще убивает: накуя танцы с переменной res в конце тела ф-ции?

    MAGnit, 04 Мая 2011

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