1. PHP / Говнокод #17817

    +156

    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
    private static function _convertMatrixReferences($formula) {
    // тут  код......... 
    		 ($openCount > 0) {
    					return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '}'");
    				} else {
    					return $this->_raiseFormulaError("Formula Error: Unexpected '}' encountered");
    				}
    			} elseif ($openCount > $closeCount) {
    				if ($closeCount > 0) {
    					return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '{'");
    				} else {
    					return $this->_raiseFormulaError("Formula Error: Unexpected '{' encountered");
    				}
    			}
    		}
    
    		return $formula;
    	}	//	function _convertMatrixReferences()

    кусок PHPExcel
    Удивительно но _raiseFormulaError метод объекта.

    И чего теперь делать ума не приложу.

    Vasiliy, 18 Марта 2015

    Комментарии (13)
  2. C++ / Говнокод #17816

    +144

    1. 1
    2. 2
    info->cipher_oid = oid_to_string(p->header2->header3->header4->header5->cipher_oid);
    info->hash_oid = oid_to_string(p->header2->header3->header4->header5->hash_oid);

    Вчера наговнокодил.

    bormand, 18 Марта 2015

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $(".fast-view .slide a").click(function() {
    			$(this).parent().parent().parent().parent().parent().parent().parent().find(".fast-view-list .tab").css("display", "none");
    			$(this).parent().parent().parent().parent().parent().parent().parent().find($(this).attr("href")).css("display", "block");
    			return false;
    		});

    lennar, 18 Марта 2015

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

    +79

    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
    builder.append(" SELECT ");
            for(int i=7;i>0;i--){            	
            	int month = cal.get(Calendar.MONTH) + 1;
                    int year = cal.get(Calendar.YEAR);
            	cal.add(Calendar.MONTH, -1);
            	builder.append(" IFNULL(SUM(IF((MONTH(FEED.feed_date)= "+ month +" && YEAR(FEED.feed_date)="+year+"),"+measurementByColumn+",0)),0) AS M"+i+ " , ");
            }
    builder.append(" IFNULL(MAX(IF((YEAR(FEED.feed_date)="+currentyear+" and FEED.feed_date=FEEDYEARDATA.curYearMaxFeedDate),"+measurementByColumn+",null)),0) AS CUR_YEAR_DATA, ");
    builder.append(" IFNULL(MAX(IF((YEAR(FEED.feed_date)="+lastyear+" and FEED.feed_date=FEEDYEARDATA.lastYearMaxFeedDate ),"+measurementByColumn+",null)),0) AS LAST_YEAR_DATA , ");
    builder.append(" FEED.pa_code,FEED.sub_pa_code ");
    builder.append(" FROM lm_dealer_info_data_feed FEED ");
    builder.append(" inner join ( SELECT pa_code,sub_pa_code, ");
    builder.append(" MAX(IF(YEAR(feed_date)="+currentyear+",feed_date,NULL)) as curYearMaxFeedDate, ");
    builder.append(" MAX(IF(YEAR(feed_date)="+lastyear+",feed_date,NULL)) as lastYearMaxFeedDate " );
    builder.append(" FROM lm_dealer_info_data_feed  " );
    builder.append(" GROUP BY pa_code,sub_pa_code  ) as FEEDYEARDATA " );
    builder.append(" ON FEED.pa_code =FEEDYEARDATA.pa_code and FEED.sub_pa_code = FEEDYEARDATA.sub_pa_code " );
    builder.append(" GROUP BY FEED.pa_code,FEED.sub_pa_code ");
    return builder.toString();

    Формируем чоткий запрос :)

    vetal, 18 Марта 2015

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public void setSkyboxName(String skyboxName) {
        if (skyboxName != null && skyboxName.length() > 2) {
          this.setSkybox(new SkyBox(skyboxName));
        } else {
          this.setSkybox(null);
        }
      }

    если имя неба длинна > 2 значит создать новое небо,
    а иначе неба не будет вообще

    dmli, 18 Марта 2015

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

    +2

    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
    public static DateTime DateStringConvert(string dateString)
            {
                var dd = dateString.Substring(0, dateString.IndexOf('-'));
                var mm = dateString.Substring(dateString.IndexOf('-') + 1).Substring(0, dateString.IndexOf('-'));
                var yyyy = dateString.Substring(dateString.IndexOf('-') + 1).Substring(dateString.IndexOf('-') + 1)
                    .Substring(0, dateString.Substring(dateString.IndexOf('-') + 1)
                    .Substring(dateString.IndexOf('-') + 1).IndexOf(' '));
                var time = dateString.Substring(dateString.IndexOf('-') + 1).Substring(dateString.IndexOf('-') + 1)
                    .Substring(dateString.Substring(dateString.IndexOf('-') + 1)
                    .Substring(dateString.IndexOf('-') + 1).IndexOf(' ') + 1);
    
                var hh = time.Substring(0, time.IndexOf(':'));
                var MM = time.Substring(time.IndexOf(':') + 1);
                return new DateTime(
                    Convert.ToInt16(yyyy),
                    Convert.ToInt16(mm),
                    Convert.ToInt16(dd),
                    Convert.ToInt16(hh),
                    Convert.ToInt16(MM),
                    0);
            }

    Вот что происходит, когда не знаешь, как парсить string в DateTime. Говнокод получен от украинских фрилансеров.

    RaTT, 18 Марта 2015

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

    +54

    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
    std::list<CCPoint> GameMap::stringToCCPArray(std::string points_string, float _x, float _y)
    {
    	points_string.push_back(' ');
    	std::list<CCPoint> CCPList = list<CCPoint>();
    	float x = 0.0f;
    	float y = 0.0f;
    	unsigned int len = 0;
    	bool isCurrentX = true;
    	for(std::string::iterator it = points_string.begin(); it != points_string.end(); ++it){
    		int q = 0;
    		len > 0 ? 
    			--len: (isdigit(*it) ? 
    				(q = atoi(&(*it)), len = countNumbersInInt(q), 
    				isCurrentX ?
    					x = atoi(&(*it)): y = atoi(&(*it))) : 
    				*it == ',' ? 
    					(isCurrentX = false): (CCPList.push_back(ccp(x,(-1 * y))), x = 0.0f, y = 0.0f, isCurrentX = true)) ;
    	}
    
    	return CCPList;
    }

    t0rmund, 18 Марта 2015

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int count = 0;
    while (condition) {
        if (count == 5) { // Kind of like sleeping for 0.2 milliseconds
            Sleep(1);
            count = 0;
        }
        // Do whatever.
        count++;
    }

    Последний ответ, показывает способ усыпить комп на 0.2 ms. И это после ответов со всякими сокетами, boost-таймерами и прочей мутью. Ответ такой типа, эй, чуваки вы ничо не понимаете, вот как надо, удобно же че бы нет))
    http://stackoverflow.com/questions/85122/how-to-make-thread-sleep-less-than-a-millisecond-on-windows/11456112#11456112

    vitaly, 17 Марта 2015

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    $a = true;
    $b = $a xor true;
    
    var_dump($b);

    ПЫХОПРОБЛЕМЫ

    http://ideone.com/cRMQor

    bool(true)

    someone, 17 Марта 2015

    Комментарии (97)
  10. Си / Говнокод #17808

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    /*
     * BIG UGLY WARNING! This is so damn ugly I wanna puke.  Unfortunately, some
     * macros that use ASN1_const_CTX still insist on writing in the input
     * stream.  ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --
     * Richard Levitte      
     */

    OpenSSL...

    bormand, 17 Марта 2015

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