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

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

    +96

    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
    if (IsPostBack)
                {
                    string PostBackerID = Request.Form.Get("__EVENTTARGET");
                    string PostBackerArg = Request.Form.Get("__EVENTARGUMENT");
    
                    if (PostBackerID == "ctl00$cphMainContent$pagerID")
                    {
                        CurrentReviewPage = int.Parse(PostBackerArg);
                        FillReviews();
                    }
                    else if (PostBackerID == "ctl00$cphMainContent$Like")
                    {
                        FillLike();
                    }
                    else if (PostBackerID == "ctl00$cphMainContent$review")
                    {
                        AddReview(PostBackerArg);
                    }
                    else if (PostBackerID == "ctl00$cphMainContent$Follow")
                    {
                        FillFollow();
                    }
                    else if (PostBackerID == "ctl00$cphMainContent$WebResultpagerID")
                    {
                        CurrentWebResultPage = int.Parse(PostBackerArg);
                        FillWebResults();
                    }
                    else if (PostBackerID == "ctl00$cphMainContent$WebResultCluster" || PostBackerID == "ctl00$cphMainContent$HiddenButton")
                    {
                        CurrentWebResultPage = 0;
                        int SelectedClusterID = int.Parse(PostBackerArg);
                        if (AllClusters != null && AllClusters.ContainsKey(SelectedClusterID))
                        {
                            SelectedClusterName = AllClusters[SelectedClusterID];
                            FillWebResults();
                        }
                    }
                }

    компактная логика всей страницы...

    mangyst, 17 Мая 2012

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

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    OdbcCommand dist_cmd = ifx_conn.CreateCommand();
                    dist_cmd.CommandText = string.Format(@"select  -1 as districtid, '-=ВСІ=-' as districtname from systables where  tabname = 'systables'                               union all 
                                            select id as districtid , cpz_name as districtname from  post_cpz where directorate_id = {0} and id != 0 ORDER BY 2", (String.IsNullOrEmpty(DDL_obl.SelectedValue))?"-1":DDL_obl.SelectedValue);
                    reader = dist_cmd.ExecuteReader();

    в процессе рефакторинга, убирая NHibernate код был заменен на это

    bercerker, 17 Мая 2012

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

    +96

    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
    List<LocalBusiness> sortedLocalBusinesses = new List<LocalBusiness>();
    foreach (LocalBusiness business in foundLocalBusinesses)
    {
    	if (!business.Logo.UrlSmall.Equals("/images/local_business_default_logo.png"))
    	{
    		sortedLocalBusinesses.Add(business);
    	}
    }
    foreach (LocalBusiness business in foundLocalBusinesses)
    {
    	if (business.Logo.UrlSmall.Equals("/images/local_business_default_logo.png"))
    	{
    		sortedLocalBusinesses.Add(business);
    	}
    }

    Сортировка - первыми должны быть объекты с не дефолтными картинками.

    mastermindCsharp, 11 Мая 2012

    Комментарии (5)
  5. Java / Говнокод #10026

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public void setWeather(WeatherData[] weather) {
    		weatherInfo.setWeather(weather[0]);
    		weatherInfo.setTomorrowWeather(weather[1]);
    		weatherInfo.setDayAfterTomorrowWeather(weather[2]);
    		weatherInfo.setDayAfterDayAfterTomorrowWeather(weather[3]);
    		weatherInfo.setDayAfterDayAfterDayAfterTomorrowWeather(weather[4]);
    		weatherInfo.setDayAfterDayAfterDayAfterDayAfterTomorrowWeather(weather[5]);
    	}

    Студенты такие студенты....

    b3er, 23 Апреля 2012

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

    +96

    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
    // expressions to parse
    		$input_pars = array(
    			's:2'=>'(sort(\d+)/?)?', 				//1-2
    			'id:2'=>'((\d+)/?)?',  			 		//3-4
    			'utkonos_id-shop_id:2-2'=>'(u(\d+)(s(\d+))?/)?', 	//5-6 7-8
    			'iid:1'=>'([0-9a-zA-Z_]+)/?', 				//9
    			'page:2'=>'(pg(\d+)/)?', 				//10-11
    			'chpsize:2'=>'(chp(\d+)/)?', 				//12-13
    			'chlist:2'=>'(chlist_(grid|list)/)?', 				//14-15
    			'p_other:1'=>'(.*)',					//16
    		);
    		if(!$class)unset($input_pars['iid:1']);
    		$m = array();
    		$i=0;
    
    		if(isset($_REQUEST['p_'])&&preg_match('[^'.implode('',$input_pars).'$]',$_REQUEST['p_'],$m)) {
    			//vd($m);
    			foreach($input_pars as $key=>$line) {
    				list($par_name,$num) = explode(':', $key);
    				$par_name_arr = explode('-',$par_name);
    				$num_arr = explode('-',$num);
    				if(count($par_name_arr)>1) {
    					foreach($par_name_arr as $kluch => $par_name) {
    						$i += $num_arr[$kluch];
    						$_REQUEST[$par_name] = $m[$i];
    					}
    				}else{
    					$i += $num;
    					$_REQUEST[$par_name] = $m[$i];
    				}
    			}
    			$_REQUEST['id'] += 0;
    			if ($_REQUEST['s'] === '0') {
    				$_REQUEST['s'] = 0;
    			}
    			if ($_REQUEST['chpsize'] === '0') {
    				$_REQUEST['chpsize'] = 0;
    			}
    			vd($_REQUEST);
    		}else{
    			$_REQUEST['s'] = grv('s',-1);						/// Сортировка
    			$_REQUEST['id'] = grv('id',0);
    			$_REQUEST['shop_id'] = grv('shop_id',0);
    			$_REQUEST['page'] = grv('page',0);
    			$_REQUEST['chpsize'] = (int)grv('chpsize',-1);
    		}

    ggg, 23 Апреля 2012

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

    +96

    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
    WM_KEYDOWN: begin
            if GetAsyncKeyState(VK_CONTROL) <> 0 then case W of
              integer('X') : SendMessage(H, WM_CUT,   0, 0);
              integer('C') : SendMessage(H, WM_COPY,  0, 0);
              integer('V') : SendMessage(H, WM_PASTE, 0, 0);
              integer('Z') : SendMessage(H, WM_UNDO , 0, 0);
              integer('Y') : ReDo(H);
              integer('A') : SelectAll(H);
              VK_INSERT    : SendMessage(H, WM_COPY,  0, 0);
              VK_PRIOR     : MoveCaretLine   (H, -1000000);  
              VK_NEXT      : MoveCaretLine   (H,  1000000);
              VK_DELETE    : SendMessage(H, WM_CLEAR, 0, 0);
          //  end else if GetAsyncKeyState(VK_ALT) then case W of
          //    VK_BACK      : SendMessage(H, WM_UNDO , 0, 0);
            end else if GetAsyncKeyState(VK_SHIFT) <> 0 then case W of
              VK_DELETE    : SendMessage(H, WM_CUT  , 0, 0);
              VK_INSERT    : SendMessage(H, WM_PASTE, 0, 0);
            end else case W of
              VK_SHIFT     : SDown(H);
              VK_LEFT      : MoveCaretSymbol (H, -1);
              VK_RIGHT     : MoveCaretSymbol (H,  1);
              VK_UP        : MoveCaretLine   (H, -1);
              VK_DOWN      : MoveCaretLine   (H,  1);
              VK_PRIOR     : MoveCaretLine   (H, -MaxLinesInScreenByH(H));
              VK_NEXT      : MoveCaretLine   (H,  MaxLinesInScreenByH(H));
              VK_DELETE    : DeleteSymbol(H, False);
            end;
            DrawText(H);
            Exit;
          end;

    Пишу свой винапи-класс типа Edit.
    Так сделаны горячие клавиши.

    TarasB, 10 Января 2012

    Комментарии (25)
  8. Pascal / Говнокод #8658

    +96

    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
    MediaPlayer1.FileName := './data/gong.wav';
      MediaPlayer1.Open;
      g1 := timetostr(time);
      g2 := timetostr(strtotime('0:00:00'));
      g3 := timetostr(strtotime('3:00:00'));
      g4 := timetostr(strtotime('6:00:00'));
      g5 := timetostr(strtotime('5:00:00'));
      g6 := timetostr(strtotime('12:00:00'));
      g7 := timetostr(strtotime('15:00:00'));
      g8 := timetostr(strtotime('18:00:00'));
      g9 := timetostr(strtotime('21:00:00'));
      if g1 = g2 then
        MediaPlayer1.Play
      else
        Label2.Caption := 'не работает тварь...';

    этнический таджик, а в душе - индокитаец

    bugmenot, 27 Ноября 2011

    Комментарии (15)
  9. Pascal / Говнокод #8423

    +96

    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
    program lucky;
    var a0,a1,a2,a3,a4,a5,a6: integer;
    begin
      for a0:= 0 to 9 do
        for a1:= 0 to 9 do
          for a2:= 0 to 9 do
            for a3:= 0 to 9 do
              for a4:= 0 to 9 do
                for a5:= 0 to 9 do
                  if (a0+a1+a2)=(a3+a4+a5) then
                    begin
                      writeln(a0,a1,a2,a3,a4,a5);
                      break;
                    end;
      readln;
    end.

    Поиск всех возможных счастливых билетов (у которых сумма первых трех чисел совпадает с суммой последних трех)

    Schrodinger, 04 Ноября 2011

    Комментарии (72)
  10. Pascal / Говнокод #7408

    +96

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    procedure TForm1.Timer1Timer(Sender: TObject);//интервал 1 минута
    var
      f: file of byte;
      c: byte;
    begin
      assignfile(f, 'c:\0.dsk');
      if fileexists('c:\0.dsk') then reset(f) else rewrite(f);// :)
      c := 0;
      write(f, c);
      closefile(f);
    end;

    Процедура "дёрганья" диска ))

    eoln, 01 Августа 2011

    Комментарии (15)
  11. Java / Говнокод #7210

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public boolean isProductActionDtoListEmpty() {
            boolean noEmpty = false;
            boolean isEmpty = productActionDtoList.isEmpty();
            if(isEmpty == true){
                return isEmpty;
            }
            return noEmpty;
    }

    джуниор закомитил, плакали все :)

    Kompot, 08 Июля 2011

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