1. ActionScript / Говнокод #12025

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    private function onClick(e:MouseEvent):void 
    {
            dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false))
    }

    Еще один кусочек очень полезного кода. (this для этого обработчика - MovieClip).

    wvxvw, 30 Октября 2012

    Комментарии (33)
  2. C++ / Говнокод #12023

    +20

    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
    void __fastcall TfРѕrm1::SpeedButton1Click(TobjРµct *Sender)
    {
    SpeedButton1->Enabled=false;
     SpeedButton1->Caption=Edit1->Text;
     if(Edit1->Text=="X")
     Edit1->Text="0";
     else
     Edit1->Text="X";
     if(SpeedButton1->Caption=="X" && SpeedButton2->Caption=="X" && SpeedButton3->Caption=="X" ||
     SpeedButton4->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton6->Caption=="X" ||
     SpeedButton7->Caption=="X" && SpeedButton8->Caption=="X" && SpeedButton9->Caption=="X" ||
     SpeedButton1->Caption=="X" && SpeedButton4->Caption=="X" && SpeedButton7->Caption=="X" ||
      SpeedButton2->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton8->Caption=="X" ||
       SpeedButton3->Caption=="X" && SpeedButton6->Caption=="X" && SpeedButton9->Caption=="X" ||
        SpeedButton1->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton9->Caption=="X" ||
         SpeedButton3->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton7->Caption=="X")
    
      ShowMessage("Ea?a caeii?aia, e?anoeee auea?aee");
    
      else
       if(SpeedButton1->Caption=="0" && SpeedButton2->Caption=="0" && SpeedButton3->Caption=="0" ||
     SpeedButton4->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton6->Caption=="0" ||
     SpeedButton7->Caption=="0" && SpeedButton8->Caption=="0" && SpeedButton9->Caption=="0" ||
     SpeedButton1->Caption=="0" && SpeedButton4->Caption=="0" && SpeedButton7->Caption=="0" ||
      SpeedButton2->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton8->Caption=="0" ||
       SpeedButton3->Caption=="0" && SpeedButton6->Caption=="0" && SpeedButton9->Caption=="0" ||
        SpeedButton1->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton9->Caption=="0" ||
         SpeedButton3->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton7->Caption=="0")
      ShowMessage("Ea?a caeii?aia, iieeee auea?aee");
    
    }

    jQuery, 29 Октября 2012

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

    +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
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {		
    	// ...skipped...
    });  
    </script>
    <!-- end script vert menu -->
    
    <!-- spoiler -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"> </script>
    <script type="text/javascript"> 
    $(document).ready(function(){ 
    // ...skipped...
    });
    </script>
    <!-- spoiler -->
    
    <!-- up-->
    <script language="JavaScript" type="text/javascript"
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
    </script><!--up-->
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'></script>
    <script type="text/javascript" src="ajax.js"></script>
    <!-- gallery -->  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>

    jQuery в организме не хватает?..

    telnet, 29 Октября 2012

    Комментарии (6)
  4. ActionScript / Говнокод #12020

    −122

    1. 1
    2. 2
    if (activeObject && (((activeObject is LevelObjectBirdBlack) || (activeObject is LevelObjectBirdOrange)) || (activeObject is LevelObjectBirdOrange)) && (!(activeObject as LevelObjectBird).specialPowerUsed || activeObject.getSpecialAnimationProgress() >= 0 ) )
    {...}

    primerno tak vyglyadit angry birds from inside

    iliakot, 29 Октября 2012

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

    +18

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    template <class TBitMap, int MMCROffset>
    class TControllerMemoryMappedRegister: public TBaseControllerMemoryMappedRegister<MMCROffset>
    {
    public:
    	static void set(TBitMap::E Bit) { setBit(Bit); }
    	static void reset(TBitMap::E Bit) { resetBit(Bit); }
    };

    Говногость, 29 Октября 2012

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    revision = String.Format("{0}{1:d2}{2:d2}",
    				DateTime.Now.Year.ToString().Substring(2),
    				DateTime.Today.Month,
    				DateTime.Today.Day);

    видно автор хотел сделать
    revision = DateTime.Today.ToString("yyMMdd");

    http://www.codeproject.com/Articles/272551/Custom-Assembly-Versioning-with-VS-2010-and-MSBUIL

    graph_di5, 28 Октября 2012

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

    +15

    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
    #include <iostream>
    #include <cxxabi.h>
    #include <typeinfo>
    
    int main(void)
    {
       uint8_t i = 63;
       int  status;
    
       std::cout << i << std::endl;
    
       char *realname = abi::__cxa_demangle(typeid(i).name(), 0, 0, &status);
       std::cout << "Real type of uint8_t is: " << realname << std::endl;
       delete (realname);
    
       std::cout << (unsigned int)i << std::endl;
    
    return 0;
    }

    ...нативный 8bit-ый беззнаковый int.

    sayidandrtfm, 28 Октября 2012

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int next_id() {
        static int id = 0;
        __sync_add_and_fetch(&id, 1);
        return id;
    }

    "Атомарная" раздача айдишек.

    bormand, 28 Октября 2012

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

    −94

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #!/usr/local/bin/cpython
    
    回答 = 读入('你认为中文程式语言有存在价值吗 ? (有/没有)')
     
    如 回答 == '有':
            写 '好吧, 让我们一起努力!'
    不然 回答 == '没有':
            写 '好吧,中文并没有作为程式语言的价值.'
    否则:
            写 '请认真考虑后再回答.'

    http://ru.wikipedia.org/wiki/ChinesePython

    Сопроваждай, пробуй!

    sayidandrtfm, 28 Октября 2012

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

    +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
    static /*public*/ string GenerateRandomJpegName()
            {
                return GenerateRandomString() + ".jpg";
            }
     
            static string GenerateRandomString()
            {
                bool UseSigns = true;
                bool UseUpperLetters = true;
                bool UseLetters = true;
                int Length;
            NewLabel:
                try
                {
                    Length = new Random(DateTime.Now.Millisecond - DateTime.Now.Second + new Random(DateTime.Now.Millisecond).Next(0, 100) / new Random(DateTime.Now.Millisecond - DateTime.Now.Second).Next(0, 10)).Next(0, 100);
                }
                catch { goto NewLabel; }
                string result = "C:/";
                try
                {
                    int Seed = 0;
                    char[] letters = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
                    char[] signs = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                    List<char> keyWords = new List<char>();
                    List<char> upperLetters = new List<char>();
                    foreach (char c in letters)
                        upperLetters.Add(Convert.ToChar(c.ToString().ToUpper()));
                    if (UseLetters)
                        foreach (char c in letters)
                            keyWords.Add(c);
                    if (UseSigns)
                        foreach (char c in signs)
                            keyWords.Add(c);
                    if (UseUpperLetters)
                        foreach (char c in upperLetters)
                            keyWords.Add(c);
                    int MaxValue = keyWords.Count;
                    for (int i = 0; i <= Length; i++)
                    {
                        try
                        {
                            Random mainrand = new Random(Seed);
                            char RandChar = keyWords[mainrand.Next(0, MaxValue)];
                            result += RandChar;
                            Seed += DateTime.Now.Millisecond + Seed - new Random().Next(10) + new Random(DateTime.Now.Millisecond + 800 * 989 / 3).Next(10);
                        }
                        catch { continue; }
                    }
                }
                catch { }
                return result;
            }

    Вместо одного вызова Path.GetRandomFileName

    psina-from-ua, 28 Октября 2012

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