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

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

    +146

    1. 1
    2. 2
    3. 3
    setInterval (function () {
    				document.getElementById("t").height=window.innerHeight-20;
    			}, 123);

    научите меня как!

    makc3d, 12 Июня 2012

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

    +137

    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
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    int main()
    {
    	long i, copy, n, temp;
    	int *ar, j, k, flag, d1, d2;
    	for(i=987654321; i>=123456789; i--)
    	{		
    		copy=i;
    		ar=(int *)calloc(10, sizeof(int));
    		while(copy>0)
    		{
    			if(copy%10==0)
    				break;
    			if(ar[copy%10]!=0)
    				break;
    			ar[copy%10]=1;
    			copy/=10;
    		}
    		free(ar);
    		if(copy==0)
    		{				
    			for(j=8; j>=5; j--)
    			{
    				flag=1;
    				n=i/(long)pow(10, j);
    				copy=i-n*(long)pow(10, j);
    				for(k=2; k<=8 && flag; k++)
    				{
    					temp=n*k;
    					if(temp>copy)
    					{
    						flag=0;
    						break;
    					}
    					while(temp>0)
    					{
    						d1=temp/(long)pow(10, (int)log10(temp));
    						d2=copy/(long)pow(10, (int)log10(copy));
    						if(d1!=d2)
    						{
    							flag=0;
    							break;
    						}
    						temp=temp-d1*(long)pow(10, (int)log10(temp));
    						copy=copy-d2*(long)pow(10, (int)log10(copy));
    					}
    					if(copy==0)
    					{
    						printf("The pandigital number is %ld and the integer is %ld\n", i, n);
    						return 0;
    					}
    				}
    			}
    		}
    	}
    	return 0;
    }

    Очередной гений с пр. Ейлер:
    http://projecteuler.net/problem=38
    http://projecteuler.net/thread=38&page=8


    >Runtime: 14.86s on 2.67Ghz machine

    TheHamstertamer, 08 Июня 2012

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

    +136

    1. 1
    http://www.jackrussell-italy.it/

    Весь сайт - одни картинки с мапами.
    Страница, на ней картинка, к ней привязана карта.
    Причем разные версии для каждого языка.
    Fuck html5! Fuck css3!

    7ion, 30 Мая 2012

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

    −32

    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
    #pragma once
    
    #include <vector>
    #include <assert.h>
    
    class Obj
    {
    public:
    	virtual ~Obj(void) { }
    };
    
    
    class Sig
    {
    	typedef void (Obj::*slot_t)(void*);
    	mutable std::vector<std::pair<Obj*, Sig::slot_t>> m_connSlots;
    
    public:
    	void operator()(void* arg) const
    	{
    		std::vector< std::pair<Obj *, slot_t> >::const_iterator iter = m_connSlots.cbegin();
    		while(iter != m_connSlots.cend())
    		{
    			Obj * object = iter->first;
    			slot_t slot = iter->second;
    			(object->*slot)(arg);
    			iter++;
    		}
    	}
    
    	template<class obj_T> void connect(obj_T* object, void (obj_T::*slot)(void*)) const
    	{
    		assert(dynamic_cast<Obj*>(object)!=0);
    		m_connSlots.push_back(std::make_pair(reinterpret_cast<Obj*>(object),
    			reinterpret_cast<Sig::slot_t>(slot)));
    	}
    };

    QBicycle

    Xom94ok, 30 Мая 2012

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

    −32

    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
    //
    //	std::string wrapper
    //
    namespace priv {
    	class string {
    		std::string &m_s;
    
    		std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
    		std::string &(std::string::*m_pAssign2)( const char * );
    
    	public:
    		string( std::string &str ): m_s(str),
    			m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
    
    		string &assign( const char *s, std::string::size_type n )
    		{
    			(m_s.*m_pAssign1)( s, n ); return *this;
    		}
    		string &assign( const char *s )
    		{
    			(m_s.*m_pAssign2)( s ); return *this;
    		}
    	};
    }

    сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
    наткнулся в одной из либ на вот это

    defecate-plusplus, 30 Мая 2012

    Комментарии (11)
  7. Си / Говнокод #10465

    +123

    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
    #include <stdio.h>
    int getLen(long long num)
    {
        int count=0;
        while (num > 0)
        {
            count++;
            num/=10;
        }
        return count;
    }
    
    int main(void)
    {
        int count = 0;
        for (long long i=1; i<=9; i++)
        {
            long long num = 1;
            int modify=0;
    
            for (int j=1; j<30; j++)
            {
                if (i==7 && j == 5)
                {
                    int a= 1;
                    a++;
                }
                num *= i;
                if (getLen(num) == j-modify)
                {
                    printf("%d^%d=%lld OK  %d\n", i, j, num, count+1);
                    count++;
                }
                if (num > 10000000)
                {
                    num/=10;
                    modify++;
                }
            }
        }
        printf("%d\n", count);
        return 0;
    }

    http://projecteuler.net/problem=63
    http://projecteuler.net/thread=63&page=8



    >I don't want to write again an big number rendering algorithm, so I played a little trick on it and hoped it won't cause any trouble..

    TheHamstertamer, 30 Мая 2012

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

    +82

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class ExceptionAction extends ActionImpl {
    
        public void nullPointer() throws Throwable {
            throw new NullPointerException();
        }
    
    }

    Гениально же!

    nafania217518, 29 Мая 2012

    Комментарии (11)
  9. Куча / Говнокод #10404

    +125

    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
    (defun question-2 ()
      (let ((b '(1 2 3))
            (a '(1 2 3 4))
            (com (make-hash-table :test #'equal)))
        (labels ((put-sorted (x)
                   (let ((key
                          (sort
                           (flatten
                            (copy-tree x)) #'<)))
                     (if (gethash key com)
                         (incf (gethash key com))
                         (setf (gethash key com) 1)))))
          (values (remove-if
           #'(lambda (x)
               (prog ((results
                      (do ((x x (cdr x)) (r))
                          (nil)
                        (setf r (append (cadar x) r))
                        (when (null (cdr x))
                          (return r)))))
                 (dolist (y a)
                   (when (not (member y results))
                     (go remove-it)))
                 (put-sorted results)
                 (go keep-it)
                 remove-it (return t)
                 keep-it nil))
           (all-functions b (cartesian-product a))) com))))

    Ну, чем бы еще порадовать. Вот, родилось во время проверки домашних заданий :)

    wvxvw, 29 Мая 2012

    Комментарии (11)
  10. Perl / Говнокод #10339

    −122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    my (@data) = $content =~ m#href="/show/\d+.*?">(.*?)</a>.*?(Ep: \d+).*?(at \d{2}:\d{2}).*?</small>#gsi;
    	
    for (my $i; $i < @data;){
    	$data .= $data [$i++].' '.$data [$i++].' '.$data [$i++];
    	$data .= "\n" unless $i == @data;
    }

    Распарсил.

    VictorVonSpok, 21 Мая 2012

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

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    OdbcCommand dist_cmd = ifx_conn.CreateCommand();
                    dist_cmd.CommandText = string.Format(@"select  -1 as districtid, '-=ВСІ=-' as districtname from systables where  tabname = 'systables'                               union all 
                                            select id as districtid , cpz_name as districtname from  post_cpz where directorate_id = {0} and id != 0 ORDER BY 2", (String.IsNullOrEmpty(DDL_obl.SelectedValue))?"-1":DDL_obl.SelectedValue);
                    reader = dist_cmd.ExecuteReader();

    в процессе рефакторинга, убирая NHibernate код был заменен на это

    bercerker, 17 Мая 2012

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