1. Objective C / Говнокод #7469

    −115

    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
    - (UIImage*)thumbnailImage:(NSString*)fileName:(BOOL)includeInCache
    {
    	NSString *extension=@"png";
    	
    	if(hasRetinaDisplay)
    	{
    		NSString *newFileName=[fileName stringByAppendingString:@"@2x"];
    		newFileName=[newFileName stringByAppendingFormat:@".%@", extension];
    		
    		BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], newFileName]];
    		
    		if(fileExists)
    			fileName=[fileName stringByAppendingString:@"@2x"];
    	}
    	
    	fileName=[fileName stringByAppendingFormat:@".%@", extension]; 
    	
    	UIImage *thumbnail = nil;
    	
    	if(includeInCache)
    		thumbnail=[thumbnailCache objectForKey:fileName];
    	
    	if (thumbnail == nil)
    	{
    		NSString *thumbnailFile = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], fileName];
    		
    		BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:thumbnailFile];
    		
    		if(fileExists)
    		{
    			thumbnail = [UIImage imageWithContentsOfFile:thumbnailFile];
    			
    			if(includeInCache)
    				[thumbnailCache setObject:thumbnail forKey:fileName];
    		}
    	}
    						  
    	return thumbnail;
    }

    велосипедище

    diduz, 06 Августа 2011

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

    −99

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    T, b= 0, []
    While t!=10:
      If t!=6:
        Print ''Чётные числа''
        A = int(raw_input('>> '))
        B.append(a)
      If t!=500:
        Print 'не чётные'
        А = int(raw_input('>> '))
        B.append(a)
    
    #якобы условия для того чтоб ввод был как бы зеброй, четные, не чётные#

    KATAJIU3ATOP, 06 Августа 2011

    Комментарии (6)
  3. Java / Говнокод #7466

    +147

    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
    public class Person {
    	
    	private final int id;
    	private final String name;
    	private final int age;
    	
    	public Person(int i, String s, int a)
    	{
    		id = i;
    		name = s;
    		age = a;
    	}
    	
    	public int getId()
    	{
    		return id;
    	}
    	
    	public String getName()
    	{
    		return name;
    	}
    	
    	public int getAge()
    	{
    		return age;
    	}
    }

    Примерно такой код был найден мною совсем недавно, сразу же скажу это не точный код, это то, как выглядел тот класс.

    redenemy, 05 Августа 2011

    Комментарии (16)
  4. Perl / Говнокод #7465

    −179

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #count pages
    	my $counter; my $pagescount = 0; my $pagesstr;
    	for (my $i = 0; $i <= $count; $i++)
    	{
    		if ($counter == POSTS_PER_PAGE)
    		{
    		    my $a,$b; if ($pagescount == $pagenum) { $a = "["; $b = "]"; } else { $a = ""; $b = ""; }
    			$pagesstr = $pagesstr."$a<a href=\"wakaba.pl?task=mpanel&admin=$admin&page=$pagescount\">".($pagescount +1)."</a>$b" if ($pagescount == 0);
    			$pagesstr = $pagesstr.", $a<a href=\"wakaba.pl?task=mpanel&admin=$admin&page=$pagescount\">".($pagescount +1)."</a>$b" if ($pagescount != 0);
    			$pagescount++; $counter = 0;
    		} else { $counter++; }
    	}

    Вот такой веселый код пишут программисты дватиреча и на этом этот самый имиджборд и работает.

    7ion, 05 Августа 2011

    Комментарии (18)
  5. Куча / Говнокод #7464

    +128

    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
    $w=isset($_POST['w'])?(int)$_POST['w']:time();
        $p=$w-(24*3600)*7;
        $n=$w+(24*3600)*7;
    	mysql_query("set @start=date_format(date_sub(from_unixtime($w), interval weekday(from_unixtime($w)) day), '%m%d'),
    		@end=date_format(date_add(from_unixtime($w), interval 6-weekday(from_unixtime($w)) day), '%m%d')");
        
    	$ste=mysql_fetch_assoc(mysql_query('select @start as s,@end as e'));
    	 if($_SESSION['userinfo']['login']=='Stormsfb') echo "date_format(date_sub(from_unixtime($w), interval weekday(from_unixtime($w)) day), '%m%d') <br>date_format(date_add(from_unixtime($w), interval 6-weekday(from_unixtime($w)) day), '%m%d')<br>".
    							"select *,unix_timestamp(d) as u,
    							date_format(d,'%e %b') as dm,
    							date_format(d,'%m%d') as md,
    							date_format(d,'%d.%m.%y') as mdf from users where 
                        date_format(d, '%m%d') between 
                        ".($_POST['month']!='false'?
    					date('m',$w).'01 and '.date('mt',$w):
    					($ste['s']>$ste['e']?' @start and 1231
    					or date_format(d, "%m%d") between '.date('m',$n).'01 and @end ':' @start and @end '))." order by ".($_POST['month']=='false'?'weekday(d)':'date_format(d,"%m%d")');
    	$q=mysql_query("select *,unix_timestamp(d) as u,
    							date_format(d,'%e %b') as dm,
    							date_format(d,'%m%d') as md,
    							date_format(d,'%d.%m') as mdf from users where 
                        date_format(d, '%m%d') between 
                        ".($_POST['month']!='false'?
    					date('m',$w).'01 and '.date('mt',$w):
    					($ste['s']>$ste['e']?' @start and 1231
    					or date_format(d, "%m%d") between '.date('m',$n).'01 and @end ':' @start and @end '))." order by ".($_POST['month']=='false'?'md':'date_format(d,"%m%d")'),_LINK_) or die(mysql_error(_LINK_)); // || $ste['s']>$ste['e']
    					/*
    					это пиздец
    					"select *,unix_timestamp(d) as u,
    							date_format(d,'%e %b') as dm,
    							date_format(d,'%m%d') as md,
    							date_format(d,'%d.%m') as mdf from users where 
                        date_format(d, '%m%d') between 
                        ".($_POST['month']!='false'?
    					date('m',$w).'01 and '.date('mt',$w):
    					($ste['s']>$ste['e']?' @start and 1231
    					union select *,unix_timestamp(d) as u,
    							date_format(d,"%e %b") as dm,
    							date_format(d,"%m%d") as md,
    							date_format(d,"%d.%m") as mdf from users where 
                        date_format(d, "%m%d") 
    					between '.date('m',$n).'01 and @end ':' @start and @end '))." order by date_format(d, '%m%d')"
    					*/

    после нас хоть трава не расти!

    GoodTalkBot, 05 Августа 2011

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

    +167

    1. 1
    $('.menu-left li:last').parent().parent().attr('class', $('#menu-menu_building li:last').parent().parent().attr('class')+' last');

    К классу последнего li главного ul в выпадающем списке добавляется 'last'.

    EugeneC, 05 Августа 2011

    Комментарии (7)
  7. C# / Говнокод #7462

    +125

    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
    for(int i = 0; i<et.Days.Count; i++)
                {
                if (et.Days[i].WorkDay.Day == colno - 1)
                    {
                    EmplTabelDays etd = et.Days[i];
    
                    switch (colno)
                        {
                        case 0:
                            break;
                        case 1:
                            break;
                        default:
                                {
                                //pinc.TypeIncome = (IncomeItem)
                                //((TreeNodeHelper)(income_grid.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value).Value;
    
                                //etd.WorkStatus = (WorkStatus)((DataGridViewCell)(WorkDaysGrid.Rows[recno].Cells[colno]).Value).Value;
    
                                DataGridViewCell cell = WorkDaysGrid.Rows[recno].Cells[colno];
                                if (SpecialButton.Checked == false)
                                    {
                                    etd.TypeWorkHours = 8;
    //еще 100500 строк гавнокода...
    
                                    if (cell.Value == "8")
                                        etd.WorkStatus.Id = 1;
                                    if (cell.Value == "-")
                                        etd.WorkStatus.Id = 2;
                                    if (cell.Value == "О")
                                        etd.WorkStatus.Id = 3;
                                    if (cell.Value == "Б")
                                        etd.WorkStatus.Id = 4;
                                    if (cell.Value == "Р")
                                        etd.WorkStatus.Id = 5;
                                    if (cell.Value == "П")
                                        etd.WorkStatus.Id = 6;
                                    if (cell.Value == "А")
                                        etd.WorkStatus.Id = 7;
                                    if (cell.Value == "Г")
                                        etd.WorkStatus.Id = 8;
                                    if (cell.Value == "С")
                                        etd.WorkStatus.Id = 9;
    
                                    }

    Найдено в коде программы табель для бухгалтерии.
    Заполнение справочника с типами дней на основе ячеек грида.
    KeyboardInheritance в чистом виде.

    etcshadow, 05 Августа 2011

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function returnFalse() {
    	return false;
    }
    function returnTrue() {
    	return true;
    }

    Не знаю, может было.
    Нашел в jquery http://code.jquery.com/jquery-1.6.2.js
    Может я не шарю, но зачем?

    Denya, 05 Августа 2011

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

    +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
    public function checkStr($s2){
        $s1=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_1234567890";
    
        $result;
        $j=strlen($s2);
        for($i=0;$i<$j;$i++){
        if ((strpos($s1,$s2[$i])))
        $result.=$s2[$i];
        else return false;
        return true;
    }
    
        }

    оригинальный кодинг стайл сохранен!
    вот такое чудо я нашел в тестовом задании, которое прислал соискатель на должность пхп-программиста.
    собственно, там можно постить все тестовое задание, просто это было первым, что бросилось в глаза.

    paulkey, 05 Августа 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    function Plugin_bannerTypeHtml_vastInlineBannerTypeHtml_vastInlineHtml_Delivery_adRender(&$aBanner, $zoneId=0, $source='', $ct0='', $withText=false, $logClick=true, $logView=true, $useAlt=false, $loc, $referer)
    {
        return deliverVastAd('vastInline', $aBanner, $zoneId, $source, $ct0, $withText, $logClick, $logView, $useAlt, $loc, $referer);
    }

    Зачем использовать короткие имена ф-ций если еще не достигнут лимит интерпретатора...

    zurom, 05 Августа 2011

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