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

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

    −4

    1. 1
    Можно, я похерю Вам настроение?

    Можно, я похерю Вам настроение?

    CRITICAL_ERROR, 25 Июля 2016

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

    +1

    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
    ...
        if(empty($text)){
          $response = chr(0xF0) . chr(0x9F) . chr(0x98) . chr(0x95);
        }
        else{
          $textLines = explode("\n", $text);
          
          if(preg_match('/^\d+$/', $textLines[0])){
            $response = $this->doneTaskAction(
              (int) $textLines[0]
            );
          }
          else{
            $response = chr(0xF0) . chr(0x9F) . chr(0x98) . chr(0x95);
          }
        }
    ...
    class dCommand extends doneCommand{
      protected $name = 'd';
      protected $description = 'Псевдоним команды /done';
      protected $usage = '/d <task_id>';
    }

    https://habrahabr.ru/post/305462/
    https://github.com/Bashka/taskbot

    habrophag, 14 Июля 2016

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

    +5

    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
    using static System.Console;
    
    namespace OptimizationDetector
    {
        public static class OptimizationDetector
        {
            private static class pls
            {
                public static bool wtf = true;
            }
    
            private static int rly = detect();
    
            private static int detect()
            {
                pls.wtf = false;
                return 0;
            }
    
            public static bool IsOptimizationEnabled
            {
                get { return pls.wtf; }
            }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                WriteLine($"\"Optimize code\" is enabled: {OptimizationDetector.IsOptimizationEnabled}");
                ReadKey();
            }
        }
    }

    ОПТИМИЗИРОВАНО

    Kozel, 29 Июня 2016

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

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    GUIButton::GUIButton(ResourceManager& resourceManager, const Renderer& renderer,
            const Config& config, std::string name, Action action,
            int x, int y, int width, int height) :
        GUIButton{std::move(name), std::move(action),
            resourceManager.load<Font>("font_button_" + name,
                    config.findValue<std::string>("button", "font"),
                    config.findValue<int>("button", "font_size")),
            resourceManager.load<TextureAtlas>("atlas_button", resourceManager, renderer,
                    Config{config.findValue<std::string>("button", "atlas_config")}), x, y, width, height}
    {
    }

    jangolare, 27 Июня 2016

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $php1 = "<";
    $php2= "?php";
    $php3 = " require_once $";
    $php4 = "_SERVER['DOCUMENT_ROOT'].\"/gen/admin/Debugger.php\"; ?";
    $php5 = "";
    $php6 = ">\r\n";
    $php_debuger = $php1 .$php2 .$php3 .$php4 .$php5 .$php6;

    Даже трудно предположить нахрен так.

    kerberos, 22 Июня 2016

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

    −1

    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
    public function getRegProductDetails($product_id = '', $status = 'yes'){
    
                $this->db->select('*');
    
                if ($product_id != '') {
    
                    $this->db->where('product_id', $product_id);
    
                }
    
                if ($status != '') {
    
                    $this->db->where('active', $status);
    
                }
    
                $query = $this->db->get('registration_package');
    
                foreach ($query->result_array() as $row) {
    
                    $product_details[] = $row;
    
                }
    
                return $product_details;

    Работаю с коммерческой системой, писали Индусы. У меня 100 Мб анекдотов в исходном коде. В БД есть столбец статус, они туда пишут статус yes OR no. И проверка везде тоже идет через строку. а выборку делают вот такой функцией. Зачем тут проверять статус на пустоту? В других подобных функциях встречаю RETURN в форейче

    traney, 16 Июня 2016

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

    +5

    1. 1
    2. 2
    int lastletter = MathUtils.random(0, 32);
            letter = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ".substring(lastletter,lastletter+1);

    всё просто и наглядно.

    WaterSmith, 15 Июня 2016

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

    +3

    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
    void CRenderer::renderToTexture(CTexture &dest, CTexture &src, TRANSFORM tr)
    {
    	int w = src.width();
    	Concurrency::parallel_for(0, w, [&] (int i) 
    	{
    		int h = src.height();
    		for(int j = 0; j < h; j++)
    		{
    			COLOR temp = src.pixel(i, j);
    			if(temp == TRANSPARENT_COLOR) continue;
    
    			//scale
    			float dx = (i-(w/2) + 0.5f)*tr.scale[0];
    			float dy = (j-(h/2) + 0.5f)*tr.scale[1];
    
    			//rotate
    			float dx2 = dx*tr.cosRot - dy*tr.sinRot;
    			float dy2 = dx*tr.sinRot + dy*tr.cosRot;
    
    			//translate
    			dx2 += tr.trans[0];
    			dy2 += tr.trans[1];
    
    			//update pixels
    			float xMin = dx2 - 0.5f*tr.scale[0] + w/2;   if(xMin < 0) xMin = 0;
    			float yMin = dy2 - 0.5f*tr.scale[1] + w/2;   if(yMin < 0) yMin = 0;
    			float xMax = xMin + tr.scale[0];  if(xMax-(int)xMax > 0) xMax++;   if(xMax >= dest.width()) xMax = dest.width()-1;
    			float yMax = yMin + tr.scale[1];  if(yMax-(int)yMax > 0) yMax++;   if(yMax >= dest.height()) yMax = dest.height()-1;
    			for(float ki = xMin; ki <= xMax; ki++) for(float kj = yMin; kj <= yMax; kj++) dest.pixel(ki, kj) = temp;	
    		}
    	});
    }

    Писал ручками трансформацию картинок в 2д, вышло без искажений пропорций, но с дырками, уродливо, и просадило фпс в самую жопень!

    puksus, 14 Июня 2016

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    while($r=mysql_fetch_array($q)){
      $buf[$r['id']]['image_file']=$r['file'];
      $r=null;
      $r['id']=null;
    }
    return $buf;

    StTv, 14 Июня 2016

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

    +3

    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
    class TM
    {
        function TM()
        {
             $this->startBuffering();
             register_shutdown_function(array($this, 'endBuffering'));
        }
     
        public function startBuffering()
        {
            ob_start();
        }
     
        public function endBuffering()
        {
            if(ob_get_level() > 1)
            {
                $data = ob_get_contents();
                ob_end_clean();
                
                $this->insertBufferedContent($data);
                
                echo $data;
            }
        }
     
        function insertBufferedContent(&$data)
        {
            if(!empty($this->buffered))
            {
                foreach($this->buffered as $contentID => $contentData)
                {
                    $search[] = ' <!--'.$contentID.'--> ';
                }
     
                $data = str_replace($search, $this->buffered, $data);
            }
        }
     
        function showBuffered($contentID)
        {
            if(ob_get_level() > 1)
            {
                echo '<!--'.$contentID.'-->';
            }
        }
        
        function setBuffered($contentID, $data)
        {
            $this->buffered[$contentID] = $data;
        }
    }
    
    $tm = new TM();

    даже комментировать не хочется

    Взято отсюда:
    http://blog.kpitv.net/article/how-to-set-title/
    Автор:
    http://govnokod.ru/user/13961

    dead_star, 09 Июня 2016

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