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

    +22

    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
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    static bool GetPathToExecutable( std::wstring & sPath )
    {
    #ifdef WIN32
        std::vector<wchar_t> TmpData;
    #else
        std::vector<char> TmpData;
    #endif
        static const size_t _nResize = 256;
        try
        {
            TmpData.resize( _nResize );
        }
        catch( ... )
        {
            sPath.clear();
            return false;
        }
        while( true )
        {
    #ifdef WIN32
            DWORD iSize = GetModuleFileNameW( NULL, &TmpData[0], (DWORD) TmpData.size() - 1 );
            if( GetLastError() == NO_ERROR )
            {
                sPath.assign( &TmpData[0], iSize );
                return true;
            }
            else if( GetLastError() != ERROR_INSUFFICIENT_BUFFER )
            {
                //
                // Unsupported error
                //
                break;
            }
    #else
            int iSize = readlink( "/proc/self/exe", &TmpData[0], (int) TmpData.size() - 1 );
            if( iSize < 0 )
            {
                //
                // Error is occurred
                //
                break;
            }
            if( iSize < TmpData.size() - 1 )
            {
                //
                // Store value
                //
                return LConv::ConvertCharToWstring( sPath, &TmpData[0] );
            }
    #endif
            try
            {
                TmpData.resize( iSize + _nResize );
            }
            catch(...)
            {
                break;
            }
        }
        sPath.clear();
        return false;
    }

    коллега инициализит строку

    Axrud, 19 Сентября 2012

    Комментарии (10)
  2. Java / Говнокод #11798

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private Listener<BaseEvent> blurListener = new Listener<BaseEvent>() {
    	@Override
    	public void handleEvent(BaseEvent be) {
    		Component item = getComponent(be);
    		if(focusedItem == item) {
    			focusedItem = item;
    		}
    	}
    }

    Даже боюсь предположить, зачем это.

    someone, 19 Сентября 2012

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

    +38

    1. 1
    if (!file_exists($this->filePath)) fopen($this->filePath, 'r');

    норм чё

    dizballanze, 19 Сентября 2012

    Комментарии (10)
  4. SQL / Говнокод #11796

    −166

    1. 1
    select r.nID as id, d.nId as id from Tm_Region as r join Tm_Direction as d where d.strName = r.strName and d.nDepth = 2 and d.nInternational = 1;

    ответ обрабатывается в Java через "forName", так что "as *" стоит спец...сначала все было норм, потом чуть по переименовывал...минут 10 искал эту ошибку

    Dougrinch, 18 Сентября 2012

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

    +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
    #!/bin/bash
    hl=`cat $1`
    wrdl=`cat ~/worlds.txt`
    addr=$PWD'/extra_hosts.txt'
    rm -f $addr && echo "Deleted host list file "$addr
    touch $addr && echo "Created file "$addr
    for address in $hl
    do
    rm $PWD/`basename $address`.txt && echo "Deleted file "$PWD/`basename $address`.txt
    done
    for address in $hl
    do
    #echo $address
    export address
    tmp=$PWD/`basename $address`.txt
    trc=$PWD/`basename $address`.tr.txt
    mytmp=/tmp/`basename $address`.txt
    curl -Ss --retry 2 --trace $trc --tr-encoding --tcp-nodelay $address > $mytmp &
    sleep 10s
    cat $mytmp \
     | grep -e '<a href=\"[^"]*\"' | grep -E -o '[^"]+'\
     | grep htm | perl -pe 's/$ENV{address}//'| \
     perl -pe 's/^\//$ENV{address}\//' | perl -pe 's/text\/html//'|\
      sed -e 's/<[^>]*>//g' -e '/\/http:/d;/^http/p;d;' | sort | uniq >> $addr &
    for wrd in `cat ~/worlds.txt`
    do
    export wrd
    cat -b $mytmp\
    | sed -e 's/<[^>]*>//g' |grep -i $wrd \
     | perl -pe 's/^/$ENV{address}:$ENV{wrd}:/' | tee -a $tmp &
    done
    done
    mkdir -p extra_hosts && echo "Made dir extra_hosts"
    cd extra_hosts
    $0 $addr

    AliceGoth, 18 Сентября 2012

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

    +139

    1. 1
    Assert.That(users.Count(), Is.EqualTo(Enumerable.Empty<User>().Count()));

    rk4n, 18 Сентября 2012

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    final TextField passwordField = UIFactory.createTextField(loginInfo, null);
    passwordField.setWidth(textFieldWidthPx);
    // Yes, they really want the password field to be shown openly.
    // Don't blame me, I'm just following orders!

    Безопасность такая безопасность.

    someone, 18 Сентября 2012

    Комментарии (33)
  8. Куча / Говнокод #11791

    +132

    1. 1
    2. 2
    3. 3
    <style Language="JavaScript">
    ...
    </style>

    WUT

    mr.The, 18 Сентября 2012

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

    +40

    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
    Function DateDiff ($interval,$date1,$date2)
    {
        // получает количество секунд между двумя датами 
        $timedifference = $date2 - $date1;
    
        switch ($interval) {
            case 'w':
                $retval = bcdiv($timedifference,604800);
                break;
            case 'd':
                $retval = bcdiv($timedifference,86400);
                break;
            case 'h':
                $retval =bcdiv($timedifference,3600);
                break
            case 'n':
                $retval = bcdiv($timedifference,60);
                break;
            case 's':
                $retval = $timedifference;
                break;
                
        }
        return $retval;
    
    }

    Не моё, где-то на просторах интернета обнаружил.

    varg242, 18 Сентября 2012

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

    +46

    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
    $confs = array();
    
    		$q = new WP_Query(array('post_type' => 'conference',
    					'posts_per_page' => -1,
    					'meta_key' => 'cd-conference-date-start',
    					'orderby' => 'meta_value_num',
    					'order' => 'DESC'
    					));
    
    		while($q->have_posts()): $q->the_post();
    		$confs[date("Y", get_post_meta($post->ID, 'cd-conference-date-start', true))][] = array('conf_title' => get_the_title(),
    												      'conf_date_start' => get_post_meta($post->ID, 'cd-conference-date-start', true),
    												      'conf_date_end' => get_post_meta($post->ID, 'cd-conference-date-end', true),
    												      'conf_link' => get_permalink(),
    												      'conf_city' => get_post_meta($post->ID, 'cd-conference-city', true),
    												      'conf_icon' => get_the_post_thumbnail()
    												      );
    		endwhile;
    
    		wp_reset_postdata();

    WordPress. Глубже, чем вы себе можете представить.

    varg242, 17 Сентября 2012

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