1. Си / Говнокод #12967

    +129

    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
    // After #include <this file>   you can  
    // use b_1010_1100 isted of 0b10101100 
     
    #define b_0000_0000 0 
    #define b_0000_0001 1 
    #define b_0000_0010 2 
    #define b_0000_0011 3 
    #define b_0000_0100 4 
    #define b_0000_0101 5 
    #define b_0000_0110 6 
    #define b_0000_0111 7 
    
    .......................
    
    #define b_1111_1010 250 
    #define b_1111_1011 251 
    #define b_1111_1100 252 
    #define b_1111_1101 253 
    #define b_1111_1110 254 
    #define b_1111_1111 255

    http://radiokot.ru/forum/download/file.php?id=150175

    И там такого добра валом и всё в одном файле и для вашего "удобства"

    m08pvv, 05 Мая 2013

    Комментарии (10)
  2. Objective C / Говнокод #12964

    −100

    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
    {
    	//replace common symbols...
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"&" withString:@"and"]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"!" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"#" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"$" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"%" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"^" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"*" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"(" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@")" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"+" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"=" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"|" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"\\" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"?" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@">" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"<" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@";" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@":" withString:@""]];
    	[createWrapperName setStringValue:[[createWrapperName stringValue] stringByReplacingOccurrencesOfString:@"@" withString:@""]];
    	// ...
    }

    Так-то.

    Источник: https://sourceforge.net/p/wineskin/code/ci/master/tree/Wineskin%20Winery/Wineskin_WineryAppDelegate.m

    P. S. А тулза, между прочим, нужная. Наткнулся на багу, полез фиксить. Увидев AppDelegate.m на 2700+ строк, заинтересовался, и не зря: вышеприведенное — мелочи.

    UncleAli, 03 Мая 2013

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

    +133

    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
    //программист
            private void work7_Click(object sender, EventArgs e)
            {
                if ((player.CompLevel > 50) & (player.GamedevLevel > 20))
                {
                    work1.Enabled = true;
                    work2.Enabled = true;
                    work3.Enabled = true;
                    work4.Enabled = true;
                    work5.Enabled = true;
                    work6.Enabled = true;
                    work7.Enabled = false;
                    player.Salary = 20000;
                    player.Levels = 50;
                    player.HealthWork = 0;
                    Game_Update();
                }
                else MessageBox.Show("Ты еще плохо знаешь программирование и компьютер");
            }

    Оттуда ж.

    tirinox, 03 Мая 2013

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

    +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
    string t = label1.Text;
    char[] bits = t.ToCharArray();
    int a1 = (Convert.ToInt16(bits[0]) - 48) + (Convert.ToInt16(bits[1]) - 48) + (Convert.ToInt16(bits[2]) - 48) + (Convert.ToInt16(bits[3]) - 48) + (Convert.ToInt16(bits[4] - 48));
                    char[] hemming = { '0', '0', bits[0], '0', bits[1], bits[2], bits[3], '0', bits[4] };
                    if (a1 == 1 || a1 == 2 || a1 == 4)
                    {
                        hemming[0] = '0';
                    }
                    else
                    { hemming[0] = '1'; }
                    int a2 = (Convert.ToInt16(hemming[2] - 48) + Convert.ToInt16(hemming[5] - 48) + Convert.ToInt16(hemming[6] - 48));
                    if (a2 == 1 || a2 == 2 || a2 == 4)
                    {
                        hemming[1] = '0';
                    }
                    else
                    { hemming[1] = '1'; }
                    int a3 = (Convert.ToInt16(hemming[4] - 48) + Convert.ToInt16(hemming[5] - 48) + Convert.ToInt16(hemming[6] - 48));
                    if (a3 == 1 || a3 == 2 || a3 == 4)
                    {
                        hemming[3] = '0';
                    }
                    else
                    { hemming[3] = '1'; }
                    if (hemming[7] == '1')
                    {
                        hemming[8] = '1';
                    }
                    else
                    { hemming[8] = '0'; }

    Реализация кода Хемминга (орфография и пунктуация сохранены)

    Psilon, 03 Мая 2013

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

    +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
    /*
        * Now do an in-place copy.
        * Map (R) to (r) and (TM) to (tm).
        * The era of teletypes is long gone, and there's
        * -really- no need to shout.
        */
    while (*src != '\0') {
        if (src[0] == '(') {
            if (strncmp(src + 1, "R)", 2) == 0) {
                (void) strncpy(dst, "(r)", 3);
                src += 3;
                dst += 3;
                continue;
            }
            if (strncmp(src + 1, "TM)", 3) == 0) {
                (void) strncpy(dst, "(tm)", 4);
                src += 4;
                dst += 4;
                continue;
            }
        }
        *dst++ = *src++;
    }
    *dst = '\0';

    Не говнокод, но забавно.
    Инициализация процессоров (и сбор cpuid) в Solaris
    http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/i86pc/os/cpuid.c#2488

    myaut, 03 Мая 2013

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

    +113

    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
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    
    public class Pause extends JFrame{
    
    	private int MAX;
    	private static String s;
    	
    	Pause(){
    		this.setSize(300, 300);
    		this.setVisible(true);
    	}
    
    	public void text(String s, final Thread t){
    		try {
    			t.wait();
    		} catch (InterruptedException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    		}
    		JLabel l = new JLabel(s);
    		l.addMouseListener(new MouseListener() {
    			
    			@Override
    			public void mouseClicked(MouseEvent e) {
    				// TODO Auto-generated method stub
    				t.notify();
    			}
    			@Override
    			public void mousePressed(MouseEvent e) {
    				// TODO Auto-generated method stub
    			}
    			@Override
    			public void mouseReleased(MouseEvent e) {
    				// TODO Auto-generated method stub
    			}
    			@Override
    			public void mouseEntered(MouseEvent e) {
    				// TODO Auto-generated method stub
    			}
    			@Override
    			public void mouseExited(MouseEvent e) {
    				// TODO Auto-generated method stub
    			}
    		});
    		this.add(l);
    	}
    	
    	public int getMAX() {
    		return MAX;
    	}
    
    	public void setMAX(int mAX) {
    		MAX = mAX;
    	}
    	
    	public String getS() {
    		return s;
    	}
    
    	public void setS(String s) {
    		this.s = s;
    	}
    
    	public void appendS(String s) {
    		this.s += s;
    	}
    
    
    	public static void main(final String[] args){
    		final Pause p = new Pause();
    		final Thread t = new Thread(new Runnable() {
    			
    			public void run() {
    				
    				for (int i = 0; i < p.getMAX(); ++i){
    					p.appendS(i + " ");
    					if (i+2 <= p.getMAX()){
    						p.text(s, t); //error
    					}
    				}
    			}
    		});
    		t.start();
    	}
    }

    Прислала подруга, изучающая потоки в Java, с просьбой подсказать, почему выдаётся ошибка компиляции при использовании переменной t внутри run.

    Придётся объяснять, что в этом коде неправильно вообще всё, от первой до последней строки...

    someone, 03 Мая 2013

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

    +102

    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
    if (
         !(this.Department.Length == 4 && 
                "0123456789".Contains(this.Department[0]) && 
                "0123456789".Contains(this.Department[1]) && 
                "0123456789".Contains(this.Department[2]) && 
                "0123456789".Contains(this.Department[3])) &&
         !(this.Department.Length == 4 && 
                "0123456789".Contains(this.Department[0]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[1]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[2]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[3])) &&
         !(this.Department.Length == 5 && 
                "0123456789".Contains(this.Department[0]) && 
                "0123456789".Contains(this.Department[4]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[1]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[2]) && 
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(this.Department[3])))
         {
          return "error";
         }

    Он видимо не знал о существовании регулярных выражений

    NeoN, 02 Мая 2013

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

    −93

    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
    private function showTick():void {
        d=getTimer() - startT;
        if (d<ACT_TIME) {
            if(d<=200){
                //scale up
                sprite.scaleX = 0.3+(d/200)*0.7;
                sprite.scaleY = 0.3+(d/200)*0.7;
            }else if(d>200 && d<500){
                sprite.scaleX = 1;
                sprite.scaleY = 1;
            }
            if(d<=300){
                sprite.alpha = d/300;
                //alpha up
            }else if(d>300 && d<500){
                sprite.alpha = 1;
            }
            if(d>=500 && d<=800){
                //scale down
                sprite.scaleX = 1-((d-500)/300);
                sprite.scaleY = 1-((d-500)/300);
                sprite.alpha = 1-((d-500)/300);
            }else if(d>800){
                sprite.scaleX = 0;
                sprite.scaleY = 0;
                sprite.alpha = 0;
            }
    
        }else {
            EnterFrame.removeAction(this._action);
            this._action = null;
        }
    }

    Хотела поменять скорость анимации текста... Уже не хочу.

    kyzi007, 01 Мая 2013

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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    if(searchParams == null)
    {
    	throw new NullReferenceException("параметры поиска = null" + searchParams.ToString());
    }

    Эдакий InnerException, чтоб верняково

    NeoN, 01 Мая 2013

    Комментарии (15)
  10. C++ / Говнокод #12956

    +10

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    static int
          _S_compare(size_type __n1, size_type __n2)
          {
      const difference_type __d = difference_type(__n1 - __n2);
    
      if (__d > __gnu_cxx::__numeric_traits<int>::__max)
        return __gnu_cxx::__numeric_traits<int>::__max;
      else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
        return __gnu_cxx::__numeric_traits<int>::__min;
      else
        return int(__d);
          }

    LispGovno, 01 Мая 2013

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