1. C++ / Говнокод #13256

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    int wordLen(const char* word) 
    { 
        int i=-1; 
        while(word[++i]!='\0'&&word[i]!='\n'); 
        return i; 
    }

    Типичная лаба, но как же смешно это увидеть спустя некоторое время

    iofjuupasli, 29 Июня 2013

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    public function parse_url($url)
    {
            return parse_url($url);
    }

    Модель из моего диплома... Всё по фен-шуй!

    nonamez, 28 Июня 2013

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

    +29

    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
    //thirteen
            Cluster cl;
            Cluster empty;
            I--;
            if(distances.size()){
                for (int i = 0; i < (Lmax < distances.size() ? Lmax : distances.size()); ++i){
                    cl.X(( clusters.at(distances.at(i).first.first).X()*clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).X()*clusters.at(distances.at(i).first.second).Points().size())/(clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Points().size()));
                    cl.Y(( clusters.at(distances.at(i).first.first).Y()*clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Y()*clusters.at(distances.at(i).first.second).Points().size())/(clusters.at(distances.at(i).first.first).Points().size() + clusters.at(distances.at(i).first.second).Points().size()));
                    if(clusters.at(distances.at(i).first.second).Number() != -1 && clusters.at(distances.at(i).first.first).Number() != -2){
                        cl.Points() = clusters.at(distances.at(i).first.second).Points();
                        clusters.at(distances.at(i).first.second) = cl;
                        clusters.at(distances.at(i).first.second).Number(-1);
                        for (std::vector<Point>::iterator j = clusters.at(distances.at(i).first.first).Points().begin(); j != clusters.at(distances.at(i).first.first).Points().end(); ++j)
                        {
                        	clusters.at(distances.at(i).first.second).Points().push_back(*j);
                        }
                        clusters.at(distances.at(i).first.first) = empty;
                        n_c--;
                    }
                }
                for (std::vector<Cluster>::iterator i = clusters.begin(); i != clusters.end(); ++i){
                    if(i->Number() == -2){
                        i = clusters.erase(i);
                    }
                    i->Number(i - clusters.begin());
                    if(I)i->Points().clear();
                    if(i == clusters.end())break;
                }
            }
            //fourteen

    Кусок алгоритма isodata

    Abbath, 28 Июня 2013

    Комментарии (4)
  4. PHP / Говнокод #13253

    +151

    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
    class geo extends db {
           
            public function ip2Country($ip, $id=false)
            {
                    $result=$this->doQuery("SELECT `eng`, `ID_parent`, `type`, `id` FROM cngeo_geo WHERE id=(
                                                            SELECT ID_geo FROM cngeo_ip WHERE IP_bi <= INET_ATON(?) ORDER BY IP_bi DESC LIMIT 1)", array('0' => array('s' => $ip)), array(0 => 'ID_parent', 1 => 'type', 2 => 'nac', 3 => 'id'));
                    if($result!=NULL)
                    {
                            while($result[0][2]!='c')
                            {      
                                    $result=$this->doQuery("SELECT `eng`, `ID_parent`, `type`, `id` FROM cngeo_geo WHERE `id`=?", array('0' => array('i' => $result[0][1])), array(0 => 'ID_parent', 1 => 'type', 2 => 'nac', 3 => 'id'));
                                    if($result==NULL) break;
                            }
                            //echo $result[0][0];
                            if( $id )
                                    return $result[0][3];
                            return $result[0][0];
                    }
            }
           
    }

    dimkich, 28 Июня 2013

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

    +73

    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
    public boolean isModified() {
    	return
    			!pluginEnabled.isSelected() == getSettings().pluginEnabled
    					|| !pathToContainerTextField.getText().equals(getSettings().pathToProjectContainer)
    					|| !pathToUrlGeneratorTextField.getText().equals(getSettings().pathToUrlGenerator)
    					|| !symfonyContainerTypeProvider.isSelected() == getSettings().symfonyContainerTypeProvider
    					|| !objectRepositoryTypeProvider.isSelected() == getSettings().objectRepositoryTypeProvider
    					|| !objectRepositoryResultTypeProvider.isSelected() == getSettings().objectRepositoryResultTypeProvider
    
    					|| !twigAnnotateRoute.isSelected() == getSettings().twigAnnotateRoute
    					|| !twigAnnotateTemplate.isSelected() == getSettings().twigAnnotateTemplate
    					|| !twigAnnotateAsset.isSelected() == getSettings().twigAnnotateAsset
    					|| !twigAnnotateAssetTags.isSelected() == getSettings().twigAnnotateAssetTags
    
    					|| !phpAnnotateTemplate.isSelected() == getSettings().phpAnnotateTemplate
    					|| !phpAnnotateService.isSelected() == getSettings().phpAnnotateService
    					|| !phpAnnotateRoute.isSelected() == getSettings().phpAnnotateRoute
    					|| !phpAnnotateTemplateAnnotation.isSelected() == getSettings().phpAnnotateTemplateAnnotation
    
    					|| !yamlAnnotateServiceConfig.isSelected() == getSettings().yamlAnnotateServiceConfig
    			;
    }

    Плагин для Intellij Idea...

    kostoprav, 28 Июня 2013

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

    +159

    1. 1
    $sess_data = $this->getZamkadCurrent();

    Opencart: /catalog/model/shipping/moscow.php line 25

    deep, 27 Июня 2013

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

    +69

    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
    while not recived do
         begin
           Application.ProcessMessages;
    //       do_log('Reciving CS response');
           p:=pos('</ROW>',ss);
           if p>1 then recived:=true else
           begin
           s := CS.Socket.ReadLn+#10#13;
    //       do_log(s);
           ss:=ss+s;
           end;
           if cs.Socket.ReadLnTimedout then cs.Socket.Close;
           if not cs.Connected then recived:=true;
         end;
        do_log('RECIVING done ');
        cs.Free;
        ss:=UTF8ToStrSmart(ss);
        do_log(ss);

    HTTP 1.1
    отправляет запрос, получает ответ в XML
    Вы видите условие выхода из цикла?
    я нет.
    параллельный трид отсчитывает 3 секунды и принудительно закрывает сокет. с учетом keep-alive это дает полтора года мозго..6ли
    аутсорс фрилансерам он такой...

    RomaShka, 27 Июня 2013

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

    +73

    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 Rectangle2D fit(final Rectangle2D in, final Rectangle2D out) {
    		final Rectangle2D.Double fit = new Rectangle2D.Double();
    		if (in.getWidth() > in.getHeight()) {
    			fit.width = out.getWidth();
    			fit.height = (out.getHeight() * in.getHeight()) / in.getWidth();
    			fit.x = out.getX();
    			fit.y = out.getY() + ((out.getHeight() - fit.height) / 2);
    		} else {
    			fit.width = (out.getWidth() * in.getWidth()) / in.getHeight();
    			fit.height = out.getHeight();
    			fit.x = out.getX() + ((out.getWidth() - fit.width) / 2);
    			fit.y = out.getY();
    		}
    		// if ((in.getWidth() / in.getHeight()) != (fit.width / fit.height)) {
    		// throw new RuntimeException();
    		// }
    		// if (!fit.contains(fit)) {
    		// throw new RuntimeException();
    		// }
    		return fit;
    	}

    #14-19 - инлайн тесты!
    а вы говорите - юнит-тесты...

    Lure Of Chaos, 27 Июня 2013

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

    +24

    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
    any<
        mpl::vector<
            copy_constructible<>,
            typeid_<>,
            incrementable<>,
            ostreamable<>
        >
    > x(10);
    ++x;
    std::cout << x << std::endl; // prints 11
    
    
    
    The library provides concepts for most C++ operators, but this obviously won't cover all use cases; we often need to define our own requirements. Let's take the push_back member, defined by several STL containers.
    BOOST_TYPE_ERASURE_MEMBER((has_push_back), push_back, 1)
    
    void append_many(any<has_push_back<void(int)>, _self&> container) {
        for(int i = 0; i < 10; ++i)
            container.push_back(i);
    }

    Я ждал этого! В С++ добавили dynamic из сишарпика.

    LispGovno, 27 Июня 2013

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

    +140

    1. 1
    2. 2
    А что можно создать с помощью компилятора
    Borland JBuilder?

    Что можно создать на этом компиляторе?

    Stertor, 27 Июня 2013

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