1. PHP / Говнокод #13928

    +158

    1. 1
    2. 2
    3. 3
    function addGetParam($key,$value){
        $_GET[$key]=$value;
    }

    В аду найдется специальное место для таких :-)

    aleksssmix, 11 Октября 2013

    Комментарии (60)
  2. ActionScript / Говнокод #13927

    −92

    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
    package
    {
        import flash.display.Stage;
    
        public class StageLocator {
    
            public static var instance:StageLocator;
    
            public static var stage:Stage;
    
            public function StageLocator (_stage:Stage) {
    
                instance = this;
    
                stage = _stage;
            }
        }
    }

    Гадаю, в чем же заключается сокровенный смысл instance и вообще этого класса.

    strax, 10 Октября 2013

    Комментарии (29)
  3. PHP / Говнокод #13926

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (false) {} 
    				else
    				{
    					//какие-то действия
    
    
    }

    desu, 10 Октября 2013

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

    +71

    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
    app_preferences = PreferenceManager.getDefaultSharedPreferences(context);
    			
    	        mApplication = (MyApplication)context;
    if(mApplication.nomgor == 0 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID", "0"));
    		      mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID","");//в работе
                  }
                if(mApplication.nomgor == 1 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID1", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID1","");//в работе
                  }
                if(mApplication.nomgor == 2 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID2", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID2","");//в работе
                   }
                if(mApplication.nomgor == 3 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID3", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID3","");//в работе
                   }
                if(mApplication.nomgor == 4 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID4", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID4","");//в работе
                  }
                if(mApplication.nomgor == 5 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID5", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID5","");//в работе
                  }
                if(mApplication.nomgor == 6 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID6", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID6","");//в работе
                   }
                if(mApplication.nomgor == 7 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID7", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID7","");//в работе
                   }
                if(mApplication.nomgor == 8 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID8", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID8","");//в работе
                   }
                if(mApplication.nomgor == 9 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID9", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID9","");//в работе
                   }
                if(mApplication.nomgor == 10 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID10", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID10","");//в работе
                  }
                if(mApplication.nomgor == 11 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID11", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID11","");//в работе
                  }
                if(mApplication.nomgor == 12 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID12", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID12","");//в работе
                   }
                if(mApplication.nomgor == 13 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID13", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID13","");//в работе
                  }
                if(mApplication.nomgor == 14 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID14", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID14","");//в работе
                   }
                if(mApplication.nomgor == 15 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID15", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID15","");//в работе
                   }
                if(mApplication.nomgor == 16 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID16", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID16","");//в работе
                   }
                if(mApplication.nomgor == 17 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID17", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID17","");//в работе
                   }

    кто-то с детства привык копипастить

    grampe, 09 Октября 2013

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

    +136

    1. 1
    2. 2
    3. 3
    if (ds2.Rows[l]["MIMETYPE"].ToString().Length >= 5 && ds2.Rows[l]["MIMETYPE"].ToString().Substring(0, 5).ToLower() == "image"){
     //  кучка гуана
    }

    Наверное определяется тип вложения.
    Path для лохов

    bars, 09 Октября 2013

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

    +139

    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
    public class Switch
        {
            public Switch(object switchElement)
            {
                Object = switchElement;
            }
    
            public object Object{get; private set; }
        }
    
        public static class SwitchExtensions
        {
            public static Switch Case<T>(this Switch switchCase, Func<T, bool> isTrue, Action<T> action) where T : class
            {
                return Case(switchCase, isTrue, action, false);
            }
    
            public static Switch Case<T>(this Switch switchCase, Func<T, bool> isTrue, Action<T> action, bool fallThrough) where T : class
            {
                if (switchCase == null)
                    return null;
    
                var obj = switchCase.Object as T;
    
                if (obj != null)
                    if (isTrue(obj))
                    {
                        action(obj);
                        return fallThrough ? switchCase : null;
                    }
    
                return switchCase;
            }
        }
    
    
               //пример использования
    
                IImporter<AccountModel> result = null;
    
                new Switch(type)
                    .Case<string>(x => x == ".xls", y => result = new ExcelImporter())
                    .Case<string>(x => x == ".csv", y => result = new CsvImporter());
    
                return result;

    У нас будет свой Switch/Case с преферансом, куртизанками и экстеншен методами

    Tessen, 09 Октября 2013

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    var regex = new Regex(@"{[\w\d]+}");
    
    var keys = (regex.Matches(m_Format.Format)
          .Cast<object>()
          .Select(match => match.ToString()
          .Replace("{", ""))
          .Select(replace => replace.Replace("}", "")))
          .ToList();

    Tessen, 09 Октября 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    bool exit = false;
    while (!exit)
    {
        if (Console.KeyAvailable)
        {
            ConsoleKeyInfo key = Console.ReadKey(true);
            exit = true;
        }
    }

    Православная замена Console.ReadKey();

    adoconnection, 09 Октября 2013

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

    −101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def Find(dir):
            def walk(a,b,files):
                t1=0
                for i in files:
                    t1+=1
                    if i[-4:]==".sis" or i[-4:]==".Sis" or i[-4:]==".SIs" or i[-4:]==".SIS" or i[-4:]==".SiS" or i[-4:]==".sIS" or i[-4:]==".siS" or i[-5:]==".sisx" or i[-5:]==".Sisx" or i[-5:]==".SIsx" or i[-5:]==".SISx" or i[-5:]==".SISX" or i[-5:]==".sISX" or i[-5:]==".siSX" or i[-5:]==".sisX" or i[-5:]==".SisX" or i[-5:]==".SIsX" or i[-5:]==".SiSX" :
                        list1.append(cn(i))
                        list2.append(cn("%s\%s"%(b,i)))

    Когда еще была жива симба, под нее был интерпретатор питона. Этот отрывок - творение некоего китайского товарища под PyS60.

    Pythoner, 09 Октября 2013

    Комментарии (59)
  10. Си / Говнокод #13918

    +128

    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
    90. 90
    91. 91
    92. 92
    #include "unpacker.h"
    
    Unpacker::Unpacker(char *name) {
        _splitString = new char*[16];
        _ctx = SDL_RWFromFile(name, "rb");
    }
    
    Unpacker::~Unpacker() {
        delete _splitString;
        SDL_RWclose(_ctx);
        SDL_FreeRW(_ctx);
    }
    
    Dir *Unpacker::getDir(char *path) {;
        int index = 1;
        char pth[256];
        char name[80];
        char *str = "";
        if (!path)
            return NULL;
        _split(path);
        SDL_RWseek(_ctx, 2, SEEK_SET);
        pth[0] = '/'; pth[1] = '\0';
        while (_splitString[index]) {    
            Uint16 count;
            Uint32 hash;
            str = _splitString[index];
            hash = _hash(str);
            count = SDL_ReadLE16(_ctx);
            for (int i=0; i<count; i++) {
                Uint32 h;
                Uint32 offset;
                h = SDL_ReadLE32(_ctx);
                offset = SDL_ReadLE32(_ctx);
                if (hash == h) {
                    Uint8 size;
                    Uint32 curPos = SDL_RWtell(_ctx);
                    SDL_RWseek(_ctx, offset, SEEK_SET);
                    SDL_RWread(_ctx, &size, 1, 1);
                    SDL_RWread(_ctx, name, size, 1);
                    name[size] = '\0';
                    if (!strcmp(str, name)) {
                        if (_splitString[index+1]) {
                             strcat(pth, str);
                             strcat(pth, "/");
                        }
                        break;
                    } else {
                        if (i == count-1)
                            return NULL;
                        SDL_RWseek(_ctx, curPos, SEEK_SET);
                    }
                }
            }
            index++;
        }
        Dir *dir = new Dir;
        strcpy(dir->name,  str);
        strcpy(dir->path, pth);
        dir->dirsCount = SDL_ReadLE16(_ctx);
        dir->dirsOffset = SDL_RWtell(_ctx);
        SDL_RWseek(_ctx, dir->dirsCount*8, SEEK_CUR);
        dir->filesCount = SDL_ReadLE16(_ctx);;
        dir->filesOffset = SDL_RWtell(_ctx);
        return dir;
    }
    
    File *Unpacker::getFile(char *path) {
        char pth[256];
        char nm[80];
        int index = 2;
        _split(path);
        if (!_splitString[1])
            return NULL;
        if (_splitString[2]) {
            strcpy(pth, "/");
            strcpy(pth, _splitString[1]);
            strcat(pth, "/");
        } else {
            Dir *dir = getDir("/");
            return getFile(dir, _splitString[1]);
        }
        while (1) {
            if (_splitString[index+1]) {;
                strcat(pth, _splitString[index]);
                strcat(pth, "/");
            } else {
                strcpy(nm, _splitString[index]);
                break;
            }
            index++;
        }

    Нашел у себя на диске - старое творенье, когда я был мал и глуп... Распаковщик архива на своего формата на основе zlib.

    Pythoner, 09 Октября 2013

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