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

    +9

    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
    class A
    {
    public:
            A () : p (new SomeType)
            {
                    assert ("It must be non-zero" && p);
            }
            ~A ()
            {
                    Box <SomeType> deleter (p);
                    p = 0;
            }
    private:
            SomeType *p;
    };

    А вот и применение класса Box

    Setry, 19 Ноября 2012

    Комментарии (11)
  2. C++ / Говнокод #12151

    +22

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    class ClassA 
    {
    };
    class ClassB : private ClassA
    {
    public:
    	ClassA& AsClassA()
    	{
    		return *this;
    	}
    };

    Setry, 19 Ноября 2012

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

    +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
    template<class T>
    class Box
    {
    private:
    	explicit Box(const Box&);
    	Box& operator = (const Box&);
    public:
    	explicit Box()
    		: m_value(0)
    	{}
    	explicit Box(T* value)
    		: m_value(value)
    	{}
    	~Box()
    	{
    		std::auto_ptr <T> toDelete(m_value);
    	}
    	T* Release()
    	{
    		T* const result(m_value);
    		m_value = 0;
    		return result;
    	}
    	void Reset(T* value)
    	{
    		std::auto_ptr <T> toDelete(m_value);
    		m_value = value;
    	}
    private:
    	T* m_value;
    };

    Setry, 19 Ноября 2012

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

    −119

    1. 1
    2. 2
    3. 3
    1С::Функторы::АппликативныйФунктор::Монад 1С::Монада::НаЭкран -> 1С::Монада::Символ,1С::Монада::СимволСлед
    | Пустота = Отчёт.Откат()
    | 1С::Буква = 1С::МонадаМир::ВводВывод::Печать 1С::Буква

    Многие интересуются, существует ли в 1С метод вывода монады на экран? Оказывается, существует!
    Данный аппликативный функтор не требует теор.ката, хотя и не без улыбки, выводит квантовое состояние функциональной монады в виде стрелок и морфизмов.
    PS Автор не я, а мой коллега, который, ковыряясь в 1С, обнаружил в нём "Функциональный режим"

    serpinski, 18 Ноября 2012

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

    +139

    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
    <div class="slogan">
      <table>
        <tbody>
          <tr>
            <td>В</td>
            <td class="r"> </td>
            <td>с</td>
            <td class="r"> </td>
            <td>ё</td>
            <td> </td>
            <td class="r"> </td>
            <td>ч</td>
            <td class="r"> </td>
            <td>т</td>
            <td class="r"> </td>
            <td>о</td>
            <td> </td>
            <td class="r"> </td>
            <td>д</td>
            <td class="r"> </td>
            <td>в</td>
            <td class="r"> </td>
            <td>и</td>
            <td class="r"> </td>
            <td>ж</td>
            <td class="r"> </td>
            <td>е</td>
            <td class="r"> </td>
            <td>т</td>
            <td class="r"> </td>
            <td>с</td>
            <td class="r"> </td>
            <td>я</td>
          </tr>
        </tbody>
      </table>
    </div>

    Разрядка слогана "ВСЁ ЧТО ДВИЖЕТСЯ" на motor.ru

    Yurik, 18 Ноября 2012

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

    +157

    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
    <SCRIPT language=JavaScript>                     <!--#### Подпрограммы (скрипты) для вывода фотографий составных частей ПК #### -->
    	function picture1(){
    		window.open("P4P800.jpg", "newwindow01", config="width=460, height=515, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture2(){
    		window.open("CPU.jpg", "newwindow02", config="width=355, height=380, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture3(){
    		window.open("Video.jpg", "newwindow03", config="width=475, height=380, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture4(){
    		window.open("Syst.jpg", "newwindow04", config="width=220, height=220, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture5(){
    		window.open("audio.jpg", "newwindow05", config="width=315, height=200, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture6(){
    		window.open("Seti.jpg", "newwindow06", config="width=190, height=120, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture7(){
    		window.open("hdd.jpg", "newwindow07", config="width=725, height=425, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture8(){
    		window.open("dvd.jpg", "newwindow08", config="width=520, height=205, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture9(){
    		window.open("korpus.jpg", "newwindow09", config="width=820, height=435, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture10(){
    		window.open("monitor.jpg", "newwindow10", config="width=320, height=320, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture11(){
    		window.open("Klava.jpg", "newwindow11", config="width=510, height=250, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture12(){
    		window.open("Mouse.jpg", "newwindow12", config="width=340, height=285, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture13(){
    		window.open("print.jpg", "newwindow13", config="width=467, height=295, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    	function picture14(){
    		window.open("RAM.jpg", "newwindow14", config="width=530, height=135, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
    }
    </script>                                    <!--#### Конец скриптов ####-->

    Stallman, 18 Ноября 2012

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

    −117

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Часто проскальзывают темы, что 1С часто отказывает в монадах.
    Я вот этого вообще не понимаю, как такое может выглядеть???
    Я со своей восьмёрочкой 2 года, в любой момент, когда я захочу монад, он будет.
    Если он скажет, нет, я не хочу, я показываю ему С++, показываю что я недоволен и говорю, почему ты не хочешь монаду?
    Ты любишь кресты? Когда монады встречаются в 1С, они должны преобразовываться по первому же желанию программиста.

    serpinski, 17 Ноября 2012

    Комментарии (12)
  8. 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)
  9. 1C / Говнокод #12144

    −125

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

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

    serpinski, 17 Ноября 2012

    Комментарии (27)
  10. Си / Говнокод #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)