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

    +159

    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
    <script>
    	$(function() {
    		$('#current').load('current.php');
    	}
    </script>
    
    // Тем временем в current.php :
    <?
    $result = ... ; // данные как-то вытаскиваются из базы
    ob_start();?>
    <table><?
    foreach($result as $res) {?>
    <tr><td><?=$res[0]?></td><td><?=$res[1]?></td><td><?=$res[2]?></td></tr>
    <?}?>
    </table>
    <?$table = ob_get_clean();?>
    <script>
              $('#current').empty();
              $('#current').append('<?=str_replace(array("\r","\n"),"",$table)?>'); 
    </script>

    Извиняюсь за возможные опечатки: сократил, чтобы оставить только самую мякотку.

    clauclauclau, 23 Октября 2014

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

    +170

    1. 1
    2. 2
    $time_now=date('d');
    $tomorrow =date('d')+'1';

    Кого-то ожидает 32 декабря.

    alxkolm, 23 Октября 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    foreach (array(167, 163) as $low_rise_apartment_id)
    {
            $arParams["SEARCH_DATA"]["articletype"][] = $low_rise_apartment_id;
    }
                
    $arParams["SEARCH_DATA"]["articletype"] = array_unique($arParams["SEARCH_DATA"]["articletype"]);

    solnatus, 22 Октября 2014

    Комментарии (1)
  4. Java / Говнокод #16909

    +86

    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
    public PriceComparator {
    
       private PriceComparator INSTANCE;
    
        public PriceComparator() {
            INSTANCE = this;
        }
    
        public PriceComparator getInstance() {
            return INSTANCE;
        }
    
    ...
    }

    Singleton fail...

    StanDalone, 22 Октября 2014

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

    +43

    1. 1
    2. 2
    3. 3
    for each (ToolStripMenuItem ^item in пользователиToolStripMenuItem->DropDownItems) {
    	item->Enabled = true;
    }

    Это C++, и это работает!

    hdkeeper, 22 Октября 2014

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

    −399

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    id  obj =  [[FHSTwitterEngine sharedEngine] getHomeTimelineSinceID:nil count:100];
    
          if ( ![[[obj class] description] isEqualToString:@"NSError"] &&
              ![[[obj class] description] isEqualToString:@"NSURLError"])
     {
         if ([_categoriesDelegate respondsToSelector:@selector(didGetPostFromMyTW: forFeed:)])
             [_categoriesDelegate didGetPostFromMyTW:obj forFeed:@{@"id":feedId}];
     }
          else
              [SVProgressHUD dismiss];

    оригинальное форматирование сохранено

    heyyou, 22 Октября 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var component_prop = {};
    // create property array
    for (var i = 0; i < object_data.properties.length; i++) {
        component_prop[object_data.properties[i].name] = object_data.properties[i].value;
    }
    // convert property arrays to JSON object for parameters on component create
    component_prop = JSON.parse(JSON.stringify(component_prop));

    может кто-то понимает этот танец?

    kissarat, 22 Октября 2014

    Комментарии (5)
  8. SQL / Говнокод #16905

    −863

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    select top 1 v.Id
       from dbo.Verification v
       where v.ApplicationId = a.Id
        and v.ResultId = 'D69E0B3A-C5CA-42D0-A8CA-FA7FF63BC414'
        and not exists (
         select 1 from Verification vo
         where vo.ApplicationId = v.ApplicationId
          and vo.ResultId = v.ResultId
          and vo.Id != v.Id
          and vo.Position > v.Position
        )

    MS SQL. Видимо, автору не рассказали об order by

    alex123098, 21 Октября 2014

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

    +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
    33. 33
    34. 34
    IEnumerator CalcTimeToEnd()
    		{
    			while (Work.TimeToEnd > 0)
    			{
    				Work.TimeToEnd -= 1;
    				Text timerText = questTimerBg.gameObject.transform.FindChild("Text").GetComponent<Text>();
    				
    				int iHours = 0;
    				int iMunuts = 0;
    				int iSeconds = Quest.TimeToEnd;
    				if (iSeconds > 60)
    				{
    					iMunuts = iSeconds / 60;
    					iSeconds = iSeconds % 60;
    				}
    				if (iMunuts > 60)
    				{
    					iHours = iMunuts / 60;
    					iMunuts = iMunuts % 60;
    				}
    				string strTime = "";
    				if (iHours > 0)
    					strTime = iHours.ToString() + ":";
    				if (iMunuts < 10)
    					strTime += "0"; 
    				strTime += iMunuts.ToString() + ":";
    				if (iSeconds < 10)
    					strTime += "0";
    				strTime += iSeconds.ToString();
    				timerText.text = strTime;
    				yield return new WaitForSeconds(1f);
    			}
    			Work.SetState(EQuestState.eQS_ABORT);
    		}

    перевод времени в текст, на индусском

    govnim, 21 Октября 2014

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

    +155

    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
    <FORM name="searchForm">
    
    .....
    <input onclick="customSubmitSearchForm()" type="button" value="Търси">
    ......
    </form>
    
    <script language="javascript">
    	function customSubmitSearchForm()
    	{
      	// may add additional checks here
      	alert('Няма данни по избраните критерии');
    	}
    </script>

    Bulgarian National Bank - http://www.bnb.bg/AboutUs/AUAdvancedSearch/index.htm

    CappY, 20 Октября 2014

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