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

    +181

    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
    #include "iostream"
    using namespace std;
    
    enum {MaxFucktorial=13};
    static int fucks[MaxFucktorial+1];
    
    template<const int ValuePosition, const int Value>
    struct initFuckedValue
    {
    	enum {CurrentValue=Value*ValuePosition};
    	static void fuckUp(void)
    	{
    		fucks[ValuePosition]=CurrentValue;
    		initFuckedValue<ValuePosition+1, CurrentValue>::fuckUp();
    	};
    };
    template<const int Value>
    struct initFuckedValue<MaxFucktorial, Value>
    {
    	static void fuckUp(void){};
    };
    void InitFucks(void)
    {
    	fucks[0]=1;
    	initFuckedValue<1,1>::fuckUp();
    };
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	cout<<"Введите аргумент факториала: "<<endl;
    	InitFucks();
    	int fuckArg=0;
    	cin>>fuckArg;
    	cout<<"Начинаем считать факториал..."<<endl
    	<<"Подсчёт факториала успешно завершён. ОК."<<endl
    	<<"Результат: "<<fucks[fuckArg]<<endl;
    	cin>>fuckArg;
    	return 0;
    }

    Решил запостить всё. Жемчужена.

    Мой знакомый, молодой преподаватель-аспирант из института пришёл однажды расстроенный. Спрашиваю у него: "Что случилось?"
    -- "Один мой первокурсник, когда я дал ему задание посчитать факториал через рекурсию принёс мне какую-то непонятную компилирующуюся галиматью. И считает она уж слишком быстро... Это какая-то программа обманка. Вообщем я ему поставил 2."

    Да, это лаба. ^_^

    Говногость, 28 Июня 2011

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

    +159

    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
    $get = dbcom('SELECT * FROM downloads ORDER BY views DESC;');
    			$i = 1;
    			while($row = mysql_fetch_array($get))
    			{
    				if($i == 1)
    				{
    					$p['v'] = $row['views'];
    				}
    				if($row['reports'] != 0)
    				{
    					$t['rep']++;
    				}
    				$t['dl'] += $row['views'];
    				$i = 0;
    			}

    DDLCMS is a COMMERCIAL grade content management system for DDL site owners.
    при 400к записях в downloads немножно все в ОЗУ не помещалось.

    peinguin, 28 Июня 2011

    Комментарии (0)
  3. Pascal / Говнокод #7095

    +89

    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
    // qsort.inc:
    procedure SortRow(var A: array of T);
    
      procedure sort(l,r: integer);
      var
        i,j: integer;
        x,y: T;
      begin
        i := l;
        j := r;
        x := a[random(r-l+1)+l];
        repeat
          while LESS(a[i],x) do inc(i);
          while LESS(x,a[j]) do dec(j);
          if i<=j then begin
            y    := a[i];
            a[i] := a[j];
            a[j] := y;
            inc(i);
            dec(j);
          end;
        until i>=j;
        if l<j then sort(l,j);
        if i<r then sort(i,r);
      end;
    
    begin
      Sort(Low(A), High(A));
    end;
    
    // unit1.pas
      T = TPoint;
      function LESS(const a,b: T): boolean;
      begin
        result := a.x<b.x;
      end;
      {$I qsort.inc}
    
    var 
      a: array of TPoint;
    begin  
      ...
      SortRow(a);
      ...
    end;

    Я использую шаблоны в Дельфи-7 ололо.

    TarasB, 28 Июня 2011

    Комментарии (27)
  4. PHP / Говнокод #7094

    +153

    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
    function read($fields = null, $id = null) {
    	$this->validationErrors = array();
    
    	if ($id != null) {
    		$this->id = $id;
    	}
    
    	$id = $this->id;
    
    	if (is_array($this->id)) {
    		$id = $this->id[0];
    	}
    
    	if ($id !== null && $id !== false) {
    		$this->data = $this->find(array($this->alias.'.'.$this->primaryKey => $id), $fields);
    		return $this->data;
    	} else {
    		return false;
    	}
    }

    И ещё cakePHP (самый-самый фреймворк, даже в говнокоде впереди планеты всей).

    zabuhailo, 28 Июня 2011

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

    +147

    1. 1
    2. 2
    3. 3
    if ($this->alias === null) {
    			$this->alias = (isset($alias) ? $alias : $this->name);
    		}

    Это cakePHP. Вот так вот в нём модель узнаёт свой alias.

    zabuhailo, 28 Июня 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Если вам нужно запустить скрипт написанный на jQuery по окончанию загрузки страницы
    
    $(document).ready( function(){
      // ну и тут ваш код
    });
    
    Преимущество это метода, в том, что он исполняет скрипт по окончанию загрузки кода страницы, НЕ включая флеш баннеры и видео.

    Увидел на одном сайте, который "учит" jQuery

    substr, 28 Июня 2011

    Комментарии (13)
  7. Куча / Говнокод #7091

    +131

    1. 1
    copy /b *.mpg FullMovie.mpg

    1. Open a blank text file.
    2. Type copy /b *.mpg FullMovie.mpg
    3. Save the file with a .Bat extension.
    Let's say you saved the text file as Joiner.Bat.
    4. Now Copy and Paste this Joiner.Bat file in a folder which contains more than one mpg files.
    5. Double click the Joiner.Bat file.

    Говногость, 27 Июня 2011

    Комментарии (15)
  8. 1C / Говнокод #7090

    −131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    РегламентированнаяОтчетность.ПередОткрытиемФормыРегламентированногоОтчета(ЭтаФорма, Отказ);
    ////Вызывается перед открытием, а потом видим:
    
    Процедура ПередОткрытиемФормыРегламентированногоОтчета(Форма, Отказ) Экспорт
    	
    	Отказ = Ложь;
    	
    КонецПроцедуры

    Windtalkers, 27 Июня 2011

    Комментарии (14)
  9. Си / Говнокод #7089

    +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
    bool aiccu_os_install(void)
    {
        /* Check if IPv6 support is available */
        if (access("/proc/net/if_inet6", F_OK))
        {
            /* Doing the modprobe doesn't guarantee success unfortunately */
            (void)system("modprobe -q ipv6 2>/dev/null >/dev/null");
    
            /* Thus test it again */
            if (access("/proc/net/if_inet6", F_OK))
            {
                dolog(LOG_ERR, "No IPv6 Stack found! Please check your kernel and module configuration\n");
                return false;
            }
        }
    
        /* Try to load modules (SIT tunnel, TUN/TAP)
         * They can be kernel builtins and there is no easy
         * way to check if they are loaded/built except for
         * trying to use them and fail at that point
         */
        (void)system("modprobe -q sit 2>/dev/null >/dev/null");
        (void)system("modprobe -q tun 2>/dev/null >/dev/null");
    
        return true;
    }

    raorn, 27 Июня 2011

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

    +153

    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
    <form method="POST" id="acceptaction" action="/">
                 <input type="submit" value="Принять участие" name="startUserEvent" />
                 <input type="hidden" value="62" name="userid" />
    </form>
    <div id="result"></div>
    
    jQuery(document).ready(function()
    {
       jQuery("#acceptaction").submit(function(event)) {
        event.preventDefault();
        var form = jQuery( this ),
            term = form.find( 'input[name="userid"]' ).val(),
            url = form.attr( 'action' );
        jQuery.post( url, { userid: term },
          function( data ) {
              var content = jQuery( data ).find( '#content' );
              jQuery( "#result" ).empty().append( content );
          };
        );
       };
    });

    maeln0r, 27 Июня 2011

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