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

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

    +135

    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
    /*
         * Lack of time prevents me from writing this segment properly.
         * May Krishna have mercy on my soul.
         */
        static const uint32_t pal            = 720 * 576 * 2;
        static const uint32_t ntsc_composite = 720 * 507 * 2;
        static const uint32_t ntsc_sdi       = 720 * 480 * 2;
        uint16_t new_width = width, new_height = height;
    
        if (height == 0) {
            new_width = 1920;
            new_height = 1080;
        }
    
        if (format == PAL) {
            rv = pal;
            memset(out_payload, 0x3F, rv);
        }
        else if (format == NTSC) {
            if (source == SDI_VIDEO) {
                rv = ntsc_sdi;
                memset(out_payload, 0x3F, rv);
            }
            else {
                rv = ntsc_composite;
                memset(out_payload, 0x3F, rv);
            }
        }
        else {
            rv = new_width * new_height * 2;
            memset(out_payload, 0x3F, rv);
        }

    Вот что переизбыток мочи делает.

    codemonkey, 31 Декабря 2014

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

    +75

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static int compareXmlGregorianCalendars(XMLGregorianCalendar left, XMLGregorianCalendar right) {
    	 int result = left.compare(right);
    	 if (result == DatatypeConstants.LESSER)
    		 return -1;
    	 else if (result == DatatypeConstants.EQUAL)
    		 return 0;
    	 else if (result == DatatypeConstants.GREATER)
    		 return 1;
    	 else
    		 throw new RuntimeException("Indeterminate result when comparing XMLGregorianCalendars.");
     }

    DatatypeConstants:

    /**
    * <p>Comparison result.</p>
    */
    public static final int LESSER = -1;

    /**
    * <p>Comparison result.</p>
    */
    public static final int EQUAL = 0;

    /**
    * <p>Comparison result.</p>
    */
    public static final int GREATER = 1;
    /**
    * <p>Comparison result.</p>
    */
    public static final int INDETERMINATE = 2;

    yccypuuck, 29 Декабря 2014

    Комментарии (5)
  4. Pascal / Говнокод #17371

    +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
    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
    var
      a : array[1..15000] of Integer;
      b : Real;
      c,k,i,j : Int64;
    begin
    
      c:=0;
      k:=0;
    
    for i:=1 to 15000 do
      a[i]:=i;
      
    for i:=1 to 15000 do
    begin
      for j:=1 to 15000 do
      begin
      b:=a[i] mod j;
        if b=0 then
          k:=k+1;
      end;
      if k=2 then
      begin
      WriteLn(a[i]);
      c:=c+1;
      end;
      
      k:=0;
    
      if c=1000 then
      break
    end;
      
    end.

    Ищем простые числа

    Toha, 25 Декабря 2014

    Комментарии (5)
  5. Java / Говнокод #17285

    +76

    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
    public  String bufer (int k) {
            String bufer = "";
            switch (k) {
                case 1:
                    for (int i = 0; i < 10; i++) {
                        if (i == 6)
                            bufer += " ";
                        bufer += Characters[random.nextInt(Characters.length)];
    
                    }
                    break;
                case 2:
                    for (int i = 0; i < 10; i++) {
                        if (i == 4 || i == 8)
                            bufer += " ";
                        bufer += Characters[random.nextInt(Characters.length)];
    
                    }
                    break;
                case 3:
                    for (int i = 0; i < 10; i++) {
                        if (i == 6)
                            bufer += "@";
                        if (i == 8)
                            bufer += ".";
                        bufer += Characters[random.nextInt(Characters.length)];
                    }
                    break;
                case 4:
                    for (int i = 0; i < 10; i++) {
                        bufer += Characters[random.nextInt(Characters.length)];
    
                    }
                    break;
    
            }
            return bufer;
        }

    Вот он, рандом, от тестировщика в selenium

    Android991, 10 Декабря 2014

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

    +57

    1. 1
    http://pastebin.ru/IvyLrrEr

    так и живём, реализация "зоопарка" на С++ после прочтения "банды четырёх"

    bitchboy, 10 Декабря 2014

    Комментарии (5)
  7. Java / Говнокод #17260

    +76

    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
    /**
     * all object cocomponents must be not the same objects in dump - to eliminate strange situations:
     * 
     * @param copySet
     */
    private void createAllNewComplexObjects(HashMap copySet) {
    	if (copySet != null) {
    		for (Iterator i = copySet.keySet().iterator(); i.hasNext();) {
    			Object key = i.next();
    			Object o = copySet.get(key);
    			Object newObject = madeNewObect(o);
    			copySet.put(key, newObject);
    		}
    	}
    }
    
    /**
     * create new instance of the object - if it is of known type. Hashes will bethe same
     * 
     * @param oldObject
     * @return
     */
    private Object madeNewObect(Object oldObject) {
    	if (oldObject instanceof String) {
    		return new String((String) oldObject);
    	}
    	if (oldObject instanceof Point) {
    		return new Point((Point) oldObject);
    	}
    	if (oldObject instanceof Vector2D) {
    		return new Vector2D((Vector2D) oldObject);
    	}
    	if (oldObject instanceof RGBA) {
    		RGBA c = (RGBA) oldObject;
    		return new RGBA(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
    	}
    	if (oldObject instanceof Integer) {
    		return new Integer(((Integer) oldObject).intValue());
    	}
    	if (oldObject instanceof Double) {
    		return new Double(((Double) oldObject).doubleValue());
    	}
    	if (oldObject instanceof Boolean) {
    		return new Boolean(((Boolean) oldObject).booleanValue());
    	}
    	if (oldObject instanceof Float) {
    		return new Float(((Float) oldObject).floatValue());
    	}
    
    	if (oldObject instanceof HashMap) {
    		createAllNewComplexObjects((HashMap) oldObject);
    		return oldObject;
    	}
    
    	return oldObject;
    
    }

    В продолжение темы конструктора String(String).

    someone, 05 Декабря 2014

    Комментарии (5)
  8. Си / Говнокод #17245

    +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
    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
    int Sys_FunctionCmp(void *f1, void *f2) {
    
    	int i, j, l;
    	byte func_end[32] = {0xC3, 0x90, 0x90, 0x00};
    	byte *ptr, *ptr2;
    	byte *f1_ptr, *f2_ptr;
    
    	ptr = (byte *) f1;
    	if (*(byte *)ptr == 0xE9) {
    		//Com_Printf("f1 %p1 jmp %d\n", (int *) f1, *(int*)(ptr+1));
    		f1_ptr = (byte*)(((byte*)f1) + (*(int *)(ptr+1)) + 5);
    	}
    	else {
    		f1_ptr = ptr;
    	}
    	//Com_Printf("f1 ptr %p\n", f1_ptr);
    
    	ptr = (byte *) f2;
    	if (*(byte *)ptr == 0xE9) {
    		//Com_Printf("f2 %p jmp %d\n", (int *) f2, *(int*)(ptr+1));
    		f2_ptr = (byte*)(((byte*)f2) + (*(int *)(ptr+1)) + 5);
    	}
    	else {
    		f2_ptr = ptr;
    	}
    	//Com_Printf("f2 ptr %p\n", f2_ptr);
    
    #ifdef _DEBUG
    	sprintf((char *)func_end, "%c%c%c%c%c%c%c", 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3);
    #endif
    	for (i = 0; i < 1024; i++) {
    		for (j = 0; func_end[j]; j++) {
    			if (f1_ptr[i+j] != func_end[j])
    				break;
    		}
    		if (!func_end[j]) {
    			break;
    		}
    	}
    #ifdef _DEBUG
    	l = i + 7;
    #else
    	l = i + 2;
    #endif
    	//Com_Printf("function length = %d\n", l);
    
    	for (i = 0; i < l; i++) {
    		// check for a potential function call
    		if (*((byte *) &f1_ptr[i]) == 0xE8) {
    			// get the function pointers in case this really is a function call
    			ptr = (byte *) (((byte *) &f1_ptr[i]) + (*(int *) &f1_ptr[i+1])) + 5;
    			ptr2 = (byte *) (((byte *) &f2_ptr[i]) + (*(int *) &f2_ptr[i+1])) + 5;
    			// if it was a function call and both f1 and f2 call the same function
    			if (ptr == ptr2) {
    				i += 4;
    				continue;
    			}
    		}
    		if (f1_ptr[i] != f2_ptr[i])
    			return qfalse;
    	}
    	return qtrue;
    }

    Хмм...

    gost, 03 Декабря 2014

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

    −124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Попытка
          ТекущийЭлемент = ЭлементыФормы[АктивныйРеквизит];
          ТекущийЭлемент.АктивиризоватьПоУмолчанию();
    Исключение
    КонецПопытки;

    Это прекрасно...
    Автор - кто-то из 1С-Хомнет

    Aleksandr_N, 02 Декабря 2014

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    (strrev "hello")                #=> "olleh"
    (array_sum [array 1 2 3])       #=> 6
    (array-product [array 4 5 6])   #=> 120
    (substring "world" 2)           #=> "rld"

    Теперь ваш Lisp и в PHP: https://github.com/lisphp/lisphp

    volter9, 29 Ноября 2014

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

    +54

    1. 1
    virtual bool    IsUnlockedAll(){bool temp = false;return temp^temp;};

    Код с боевого проекта. Комментариев не будет.

    DlangGovno, 26 Ноября 2014

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