1. JavaScript / Говнокод #11394

    +155

    1. 1
    element.data('selected') ? element.show() : $.noop();

    Либо человек из ассемблера пришел, либо "IF" сильно ему по жизни насолил.

    InnerJoin, 11 Июля 2012

    Комментарии (18)
  2. Куча / Говнокод #11393

    +124

    1. 1
    2. 2
    http://habrahabr.ru/post/147484/
    Я просто оставлю это здесь.

    Fai, 10 Июля 2012

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

    +141

    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
    int main()
      {
        int i = 0;
        goto A;
        for (;i<3; ++i)
        L:{
            {
              int x;
              x += i;
              if (0) { A: x = 0; goto B; }
              printf("X: %d ",x);
            }
            {
              int y;
              y -= i;
              if (0) { B: y = 10; goto L; }
              printf("Y: %d\n",y);
            }
          }
      }

    Отсюда: http://rsdn.ru/forum/cpp/4812647.flat.aspx Автор походу уверен в гениальности кода.

    slavap, 10 Июля 2012

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

    +24

    1. 1
    2. 2
    3. 3
    Fixed f = 0.2;
    	f = std::abs(f);
    	std::cout << (float)f;

    Угадайте, чему будет равно f?
    Fixed - тип из той же библиотеки, что и в http://govnokod.ru/11294

    TarasB, 10 Июля 2012

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

    +129

    1. 1
    return GetByteArray((Object)obj);

    На всякий случай.

    Em1ss1oN, 10 Июля 2012

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

    +119

    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
    /**
     * Imbues the given {@link Font} with support for fallback fonts,
     * needed to display CJK characters in fonts that do not support them.
     * 
     * This is an ugly mess that depends on internal Sun APIs. Use sparingly!
     *
     * @param font the font
     * @return the composite font UI resource
     */
    public static FontUIResource getCompositeFontUIResource(final Font font) {
    	try {
    		Class<?> klass;
    		
    		try {
    			// Java 7
    			klass = Class.forName("sun.font.FontUtilities");
    		} catch (final ClassNotFoundException e) {
    			// Java 6
    			klass = Class.forName("sun.font.FontManager");
    		}
    		
    		// Invoke static method that wraps the font
    		val method = klass.getMethod("getCompositeFontUIResource", Font.class);
    		return (FontUIResource) method.invoke(null, font);
    	} catch (final ClassNotFoundException e) {
    		// Long block of catches that cannot happen on a Sun JRE
    		throw new AssertionError(e);
    	} catch (final IllegalAccessException e) {
    		throw new AssertionError(e);
    	} catch (final IllegalArgumentException e) {
    		throw new AssertionError(e);
    	} catch (final InvocationTargetException e) {
    		throw new AssertionError(e);
    	} catch (final NoSuchMethodException e) {
    		throw new AssertionError(e);
    	} catch (final SecurityException e) {
    		throw new AssertionError(e);
    	}
    }

    someone, 10 Июля 2012

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

    +48

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function is_array_assoc($arr) {
        if (is_array($arr)) {
            foreach ($arr as $k => $v) {
                if (is_string($k) || (is_int($k) && $k < 0)) {
                    return 1;
                }
            }
            return 0;
        }
        return -1;
    }

    Взята с php.net проверка массива на ассоциативность.
    Типа array(5 => 4, 8=>9, 1 => 3) не ассоциативный?

    mkusher, 09 Июля 2012

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

    +24

    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
    do
        {
    		count++;
    		Xt=X;
    		if (ii==1)
    		{
    			X= dichotomia(a,b, E);
    			fprintf(bnf, "%lf;\n", Xt);
    		}
    		else
    		{
    			if (ii==2)
    			{
    				X=newton(X, E);
    				fprintf(bnf, "%lf;\n", Xt);
    			} 
    			else
    			{
    				if (ii==3)
    				{
    					X=sekuschich(X, b);
    					fprintf(bnf, "%lf;\n", Xt);
    				}
    				else
    				{
    					if (ii==4)
    					{
    						ii==1;
    						ii==2;
    						ii==3;
    					}
    				}
    			}
    		}
    		printf("X=%lf\n", X);
    		if(Func(X)*Func(a)>0)a=X;
    		else b=X;
    	}
    	while(fabs(X-Xt)>=E);

    В общем лаба на численые методы поиска корней.
    После того как я предоставил няшный, полностью удовлетворяющий условиям, после проверки меня попросили "сделать как у парней", и вот участок их высера

    p.s. форматирование сохранить не удалось, да и там совсем бы ничего понятно бы не было

    maksim_ovcharik, 09 Июля 2012

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

    −86

    1. 1
    movie_data["genres"][i]["ru"].lower().encode("utf-8").decode("utf-8")

    Хм...

    Yurik, 08 Июля 2012

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

    +72

    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
    public abstract class SomeActivity extends Activity implements SomeEventListener {
    
        @Override
        protected void onResume() {
            super.onResume();
            application.addSomeListener(this);
        }
    
        @Override
        protected void onPause() {
            application.removeSomeListener(this);
            super.onPause();
        }

    В дополнение к #11379
    Вопрос пользователю нужно задать поверх любой нашей активити...

    rat4, 08 Июля 2012

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