1. PHP / Говнокод #12145

    +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
    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
    public function custom_result_object($class_name)
    	{
    		if (array_key_exists($class_name, $this->custom_result_object))
    		{
    			return $this->custom_result_object[$class_name];
    		}
    
    		if ($this->result_id === FALSE OR $this->num_rows() == 0)
    		{
    			return array();
    		}
    
    		// add the data to the object
    		$this->_data_seek(0);
    		$result_object = array();
    
    		while ($row = $this->_fetch_object())
    		{
    			$object = new $class_name();
    
    			foreach ($row as $key => $value)
    			{
    				$object->$key = $value;
    			}
    
    			$result_object[] = $object;
    		}
    
    		// return the array
    		return $this->custom_result_object[$class_name] = $result_object;
    	}
    
    	// --------------------------------------------------------------------
    
    	/**
    	 * Query result.  "object" version.
    	 *
    	 * @access	public
    	 * @return	object
    	 */
    	public function result_object()
    	{
    		if (count($this->result_object) > 0)
    		{
    			return $this->result_object;
    		}
    
    		// In the event that query caching is on the result_id variable
    		// will return FALSE since there isn't a valid SQL resource so
    		// we'll simply return an empty array.
    		if ($this->result_id === FALSE OR $this->num_rows() == 0)
    		{
    			return array();
    		}
    
    		$this->_data_seek(0);
    		while ($row = $this->_fetch_object())
    		{
    			$this->result_object[] = $row;
    		}
    
    		return $this->result_object;
    	}

    Govnisti_Diavol, 17 Ноября 2012

    Комментарии (14)
  2. 1C / Говнокод #12144

    −125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    МояМонада :: МойПарсерТип МойПарсер -> (МойПарсерТип -> МойПарсер МойПарсерТип2) -> МойПарсер МойПарсерТип2
    
    МойСущность МойМонад [] Где
        Возврат МойТип = [МойТип]
        МойВозвратВозврат >>= МойФункция = МойСклейка (МойВсем МойФункция МойВозвратВозврат)

    Коллега выдал - закоммитил в локальный гитхаб 1С парсер хаскелля на 1С.

    serpinski, 17 Ноября 2012

    Комментарии (27)
  3. Си / Говнокод #12143

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    //void wyslij(int pin, char mode[] = "open") { //было
    void wyslij(int pin, int mode) { //стало
      if (pin != -1)
      {
        if (mode == "open")
        {
    
    //...
    
      else if ( (mode == "touch") && ( (error != 1) || (olej_error == 1) ) )

    Кусок дипломной работы польского студента, код для ардуино. Выцарапано отсюда: http://vimeo.com/47656204, примерно с 1:15.

    Xom94ok, 17 Ноября 2012

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

    +24

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #define TRUE (1)
    #define FALSE (0)
    
    #define internal protected:
    #define external public:
    #define declareSuper(superClass) protected: typedef superClass super

    Оттуда.

    LispGovno, 17 Ноября 2012

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

    +39

    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
    <?php
    session_start();
    include ("system/db.config.php");
         if (empty($_SESSION['login']) or empty($_SESSION['id']))
               {
                  header("Location: index.php");
               }
               else
              {
                 //Выясняем, кто зашел сюда, если админ, удаляем юзера, если нет - перекидываем в список пользователей
                 $fResult = mysql_query("SELECT user_level FROM users WHERE id=".$_SESSION['id'], $db);
                 $fRow = mysql_fetch_array($fResult);
                 if($fRow['user_level'] == 1)
                 {
                     $DelTenderId = $_GET['id'];
                     $DellFiled = mysql_query("SELECT file_link FROM tenders WHERE id=".$DelTenderId);
                     $isdLnk = mysql_fetch_array($DellFiled);
                     $delPater = "uploads/".$isdLnk['file_link'];
                     unlink($delPater);
                     mysql_query("DELETE FROM tenders WHERE id =".$DelTenderId);
                     header("Location: tenders_list.php"); 
                 }
                 else
                 {
                   header("Location: home.php"); 
                 }
             }
    ?>

    Ну как то так....

    Govnisti_Diavol, 17 Ноября 2012

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

    +83

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ((decoded.length() > 40) && (el != null))
          el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 2 ANSI/ISO Standards");
        else if ((decoded.length() > 107) && (el != null)) {
          el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 3 ANSI/ISO Standards");
        }

    Декодинг содержимого магнитной полосы карты в софте одного банка.

    popoffka, 17 Ноября 2012

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

    +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
    if (
        event.which == $.ui.keyCode.COMMA ||
        event.which == $.ui.keyCode.ENTER ||
        (
            event.which == $.ui.keyCode.TAB &&
            that._tagInput.val() !== ''
        ) ||
        (
            event.which == $.ui.keyCode.SPACE &&
            that.options.allowSpaces !== true &&
            (
                $.trim(that._tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' ||
                (
                    $.trim(that._tagInput.val()).charAt(0) == '"' &&
                    $.trim(that._tagInput.val()).charAt($.trim(that._tagInput.val()).length - 1) == '"' &&
                    $.trim(that._tagInput.val()).length - 1 !== 0
                )
            )
        )
    ) {
        event.preventDefault();
        that.createTag(that._cleanedInput());
    
        // The autocomplete doesn't close automatically when TAB is pressed.
        // So let's ensure that it closes.
        that._tagInput.autocomplete('close');
    }

    https://github.com/aehlke/tag-it/blob/master/js/tag-it.js#L183

    Sc0rp10, 16 Ноября 2012

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

    +14

    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
    [code=cpp]
    #include <iostream>
    #include <cmath>
    
    void foo(double x, double y)
    {
        if (std::cos(x) != std::cos(y)) 
            std::cout << "Я знаю точно невозможное возможно";
    }
    
    int main()
    {
        foo(1.0, 1.0);
        return 0;
    }
    [/code]

    floatы и нуб.

    igumnovf, 16 Ноября 2012

    Комментарии (126)
  9. Python / Говнокод #12137

    −112

    1. 1
    while h == h

    Делал так раньше, когда не знал про while True

    lancerok, 16 Ноября 2012

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

    +136

    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
    private BusinessSocialProfile GetSocialProfileLink(string searchProvider, string searchKey)
    {
    	var link = new BusinessSocialProfile { Name = searchProvider, Url = "#" };
    	
    	if (searchProvider.Contains("city", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = cityLink;
    		link.Logo = "/citysearch.png";
    		link.ImageStyle = "margin-top:-8px";
    	}
    	else if (searchProvider.Contains("google", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = googleLink;
    		link.Logo = "/google.png";
    	}
    	else if (searchProvider.Contains("yelp", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = yelpLink;
    		link.Logo = "/yelp.png";
    		link.ImageStyle = "margin-top:-8px";
    	}
    	else if (searchProvider.Contains("manta", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = mantaLink;
    		link.Logo = "/manta.png";
    	}
    	else if (searchProvider.Contains("patch", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = patchLink;
    		link.Logo = "/patch.png";
    	}
    	else
    	{
    		link.Url = "#";
    		link.Logo = string.Empty;
    		link.Name = string.Empty;
    	}
    
    	return link;
    }

    уже до боли известный девелопер ;) а для чего еще нужна бизнесс-логика...?

    mangyst, 16 Ноября 2012

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