1. ActionScript / Говнокод #15403

    −123

    1. 1
    2. 2
    3. 3
    4. 4
    var player:c2Player = world.getPlayer();
    var block:c2Block = world.getBlock(player);
    
    player.x = (player.xpos - block.xpos)*(player.angle + block.angle * Math.cos(player.angle/180*Math.PI)*(10-10+1-1+0);

    Оригинальная и полезная формула.

    Bletraut, 09 Марта 2014

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

    +123

    1. 1
    Mage::run();

    С этого места начинается боль и мучения.

    DrugMan, 09 Марта 2014

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

    +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
    <?php
    
     $dataProvider = new CActiveDataProvider('User', array(
                'criteria'=>array(
                    'condition' => 'id = ' . $id,
                ),
            ));
    
    $regdata = $dataProvider->getData();
    if (is_array($regdata)) $regdata = current($regdata);
    //....
    $this->redirect(Yii::app()->createUrl('user/profile'));

    Как не стоит писать на Yii

    JiLiZART, 09 Марта 2014

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

    +130

    1. 1
    DECLARE (A, B INIT ((5)0,(5)1)) DIM (0:9) FLOAT;

    LispGovno, 08 Марта 2014

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    function get_md5($filename){
    return md5_file($filename)
    }
    echo "get_md5($_POST)";
    ?>

    Только начал php, посоветуйте литературу Х)

    VityaPW, 08 Марта 2014

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

    +37

    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
    int hamming(int i, int j, vector<state>& net) //returns Hamming distance between i and j nodes
    {
    	int res = 0;
    	if (net[i].nodes[0] != net[j].nodes[0])
    	{
    		res++;
    	}
    	if (net[i].nodes[1] != net[j].nodes[1])
    	{
    		res++;
    	}
    	if (net[i].nodes[2] != net[j].nodes[2])
    	{
    		res++;
    	}
    	if (net[i].nodes[3] != net[j].nodes[3])
    	{
    		res++;
    	}
    	if (net[i].nodes[4] != net[j].nodes[4])
    	{
    		res++;
    	}
    	if (net[i].nodes[5] != net[j].nodes[5])
    	{
    		res++;
    	}
    	if (net[i].nodes[6] != net[j].nodes[6])
    	{
    		res++;
    	}
    	if (net[i].nodes[7] != net[j].nodes[7])
    	{
    		res++;
    	}
    	if (net[i].nodes[8] != net[j].nodes[8])
    	{
    		res++;
    	}
    	if (net[i].nodes[9] != net[j].nodes[9])
    	{
    		res++;
    	}
    	if (net[i].nodes[10] != net[j].nodes[10])
    	{
    		res++;
    	}
    	if (net[i].nodes[11] != net[j].nodes[11])
    	{
    		res++;
    	}
    	if (net[i].nodes[12] != net[j].nodes[12])
    	{
    		res++;
    	}
    	return res;
    }

    Человеку срочно нужно узнать про существование циклов.

    galarr, 08 Марта 2014

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

    −122

    1. 1
    find $WORK/LOG -name "*.log" | grep "^app_"

    и писали же вроде это не в 2 утра...

    Dummy00001, 07 Марта 2014

    Комментарии (0)
  8. bash / Говнокод #15389

    −126

    1. 1
    2. 2
    3. 3
    4. 4
    while [ 1 ]
    do
      # ....
    done

    Прикололо. Не уверен что автор даже знает почему/как именно это работает.

    Dummy00001, 07 Марта 2014

    Комментарии (8)
  9. bash / Говнокод #15387

    −124

    1. 1
    2. 2
    out=`$SOME_PROPRIETARY_TOOL $LOTS_OF_PARAMETERS 2>&1`
    out=`echo $out | awk '{print $23}'`

    из официального скрипта. и мне вот ту $SOME_PROPRIETARY_TOOL надо править. пальцев до 23х считать не хватает.

    Dummy00001, 07 Марта 2014

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

    +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
    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
    if($(".picture-column.gallery").size()) {
    		$(".minigal-nav .counter").text("1 из " + $(".picture-column.gallery").find("li").size());
    
    		if (window.isWindowsPhone){
    			$(".minigal-nav li.next").attr("onclick", 'var index = $(".picture-column.gallery li.current").index(); index++; if(index > $(".picture-column.gallery").find("li").size() - 1) {index = 0;};switchImage(index);');
    			$(".picture-column.gallery img").attr("onclick", '$(".minigal-nav li.next").trigger("click");');
    			$(".minigal-nav li.prev").attr("onclick", 'var index = $(".picture-column.gallery li.current").index();index--;if(index < 0) {index = $(".picture-column.gallery").find("li").size() - 1;};switchImage(index);');
    		} else {
    			$(".minigal-nav li.next").on("click", function() {
    				var index = $(".picture-column.gallery li.current").index();
    				index++;
    				if(index > $(".picture-column.gallery").find("li").size() - 1) {
    					index = 0;
    				}
    				switchImage(index);
    			});
    			$(".picture-column.gallery img").on("click", function() {
    				$(".minigal-nav li.next").trigger("click");
    			});
    			$(".minigal-nav li.prev").on("click", function() {
    				var index = $(".picture-column.gallery li.current").index();
    				index--;
    				if(index < 0) {
    					index = $(".picture-column.gallery").find("li").size() - 1;
    				}
    				switchImage(index);
    			});
    		}
    
    		var switchImage = function(index) {
    			$(".picture-column.gallery li.current").fadeOut(function() {
    				$(this).removeClass("current");
    				$(".picture-column.gallery").find("li").eq(index).fadeIn().addClass("current");
    			});
    
    			$(".minigal-texts li.current").fadeOut(function() {
    				$(this).removeClass("current");
    				$(".minigal-texts").find("li").eq(index).fadeIn().addClass("current");
    			});
    
    			$(".minigal-nav .counter").text(index + 1 + " из " + $(".picture-column.gallery").find("li").size());
    		}
    	}

    Это что-то типа адаптивный слайдер))))

    farit_slv, 07 Марта 2014

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