1. SQL / Говнокод #8775

    −114

    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
    DECLARE 
      CURSOR get_col1 IS
        SELECT DISTINCT 
    	a.constraint_name, 
      a.constraint_type,
      a.table_name,
      a.r_constraint_name,
      b.column_name
        FROM all_constraints a, all_cons_columns b
        WHERE a.table_name = b.table_name
      AND a.constraint_type in ('P', 'R')
      AND a.constraint_name = b.constraint_name
      --AND rownum < 20
        ORDER by 1;
      
      CURSOR get_col2 IS
        SELECT table_name, column_name 
        FROM all_cons_columns
        WHERE constraint_type = 'R';
        
    BEGIN
      dbms_output.ENABLE;
      dbms_output.put_line(rpad('Имя ограничения', 30)
                ||rpad('Тип', 5)
                ||rpad('Имя столбца', 20)
                ||rpad('Имя таблицы', 20)
                ||rpad('Имя таблицы', 20)
                ||rpad('Имя столбца', 20));
      dbms_output.put_line(rpad('-', 115, '-'));
      
      FOR main_col IN get_col1 LOOP
        dbms_output.put_line(rpad(to_char(main_col.constraint_name), 30)
          ||rpad(to_char(main_col.constraint_type), 5)
          ||rpad(to_char(main_col.column_name), 20)
          ||rpad(to_char(main_col.table_name), 20));
        
        /*IF (main_col.constraint_type = 'R') THEN
          dbms_output.put_line(lpad(rpad('Comment', 11), 37)||': '||main_col.comments);
        END IF;*/
        
        FOR sec_col IN get_col2 LOOP
          IF (main_col.constraint_type = 'R') THEN
            dbms_output.put_line(rpad('Index', 10)
            ||rpad('Index', 10)': '||ind_col.index_name);
          END IF;
        END LOOP;
        dbms_output.new_line();  
      END LOOP;
    END;
    /

    kikis, 09 Декабря 2011

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

    −115

    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
    @try {
            NSMutableArray *items = nil;
            if(isGrouped){
                items = [NSMutableArray arrayWithArray:[_sortedItemsDict objectForKey:[_alphabet objectAtIndex:section]]];
            }else{
                items = _itemsArray;
            }
            [cell.textLabel setText:[[items objectAtIndex:row] name]?[[items objectAtIndex:row] name]:@"No Title"];
            
            if([[items objectAtIndex:row] isKindOfClass:[Song class]]){
                
                Song *song = (Song*)[items objectAtIndex:row];
                
                [cell.detailTextLabel setText:[NSString stringWithFormat:@"%@ %@", [song albumName]?[song albumName]:[NSString string], [song artistName]]?[song artistName]:[NSString string]];
                
                if([song isAvailableAtItunes])
                    NSLog(@"%@ %d", [song name], [song ID]);
                
                [cell setTag:[song ID]];
                
            }else if([[items objectAtIndex:row] isKindOfClass:[Album class]]){
                
                [cell.detailTextLabel setText:[NSString stringWithFormat:@"%@", [[items objectAtIndex:row] artistName]]?[[items objectAtIndex:row] artistName]:[NSString string]];
                
            }else if([[items objectAtIndex:row] isKindOfClass:[Podcast class]] || [[items objectAtIndex:row] isKindOfClass:[Audiobook class]]){
                [cell setTag:[[items objectAtIndex:row]ID]];
            }
            
            if(!isFromSelfLibrary){
            
                if(items && ([[items objectAtIndex:row] isKindOfClass:[Song class]] || [[items objectAtIndex:row] isKindOfClass:[Podcast class]] || [[items objectAtIndex:row] isKindOfClass:[Audiobook class]])){
                
                    if([[items objectAtIndex:row]isAvailableAtItunes]){
                    
                        for(UIView *view in [cell subviews]){
                            if(view.tag == 111){
                                [view setHidden:NO];
                            }
                        }
                    }else{
                        [[DataController instance] checkItem:[items objectAtIndex:row]];
                    }
                    [cellsDict setValue:cell forKey:[NSString stringWithFormat:@"%d",[cell tag]]];
                }
            }
            
            if(items && ![[items objectAtIndex:row] isKindOfClass:[Song class]] 
               && ![[items objectAtIndex:row] isKindOfClass:[Podcast class]]
               && ![[items objectAtIndex:row] isKindOfClass:[Audiobook class]])
            {
                [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
            }
            [cell.textLabel setTextColor:[UIColor whiteColor]];
            [cell.textLabel setShadowColor:[UIColor blackColor]];
            [cell.textLabel setShadowOffset:CGSizeMake(0, 1)];
            [cell.detailTextLabel setTextColor:[UIColor lightGrayColor]];
            [cell.detailTextLabel setShadowOffset:CGSizeMake(0, 1)];
            [cell.detailTextLabel setShadowColor:[UIColor blackColor]];
            [tableView deselectRowAtIndexPath: indexPath animated: YES];
        }
        @catch (NSException *exception) {
            NSLog(@"olo1");
        }

    Не то, чтобы отлов исключения меня печалит.... :'(

    lime, 09 Декабря 2011

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

    +132

    1. 1
    RewriteRule ^groups/([^/]+)/(201[1-9]-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]))$ /index.php?g=$1&amp;action=week&amp;d=$2 [L]

    Без коментариев

    LiteError, 08 Декабря 2011

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

    −117

    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
    d1.onPress=function() {
    	startDrag(this);
    };
    d1.onRelease=function(){
    	stopDrag();
    	if(d1.hitTest(a) || d1.hitTest(b) || d1.hitTest(c) || d1.hitTest(d)){
    		popadanie=popadanie | 8;
    		if(d1.hitTest(a)){ z[0] = 4; }
    		if(d1.hitTest(b)){ z[1] = 4; }
    		if(d1.hitTest(c)){ z[2] = 4; }
    		if(d1.hitTest(d)){ z[3] = 4; }				
    	}
    	else{
    		popadanie=popadanie & 7;
    		if(d1.hitTest(a)){ z[0] = 0; }
    		if(d1.hitTest(b)){ z[1] = 0; }
    		if(d1.hitTest(c)){ z[2] = 0; }
    		if(d1.hitTest(d)){ z[3] = 0; }		
    	}
    	if(popadanie==15){ proverka._visible = true;}
    	else{
    		proverka._visible = false;
    	}
    };

    Из старого кода. Таких функций еще 3, мне почему-то было лень напрямую сравнить, какой из 8 прямоугольников с каким перекрылся. Заодно потроллел преподовательницу.

    unfalse, 08 Декабря 2011

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

    +160

    1. 1
    2. 2
    Обратите внимание:
    http://govnokod.ru/user/4866

    TarasGovno, 08 Декабря 2011

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

    −118

    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
    int CurrentPos;
    
    NSInteger cnt = [ListOfFtpFiles count];
    
    CurrentPos = [[[NSUserDefaults standardUserDefaults] objectForKey:@"DownLoadIndex" ] intValue];
    if (CurrentPos==nil)  CurrentPos=0;
    
    if (CurrentPos == 0) 
    {
        //...
        for (int i = 0; i < (int)cnt; i=i+1)
    	//...
    }

    kodovich, 08 Декабря 2011

    Комментарии (13)
  7. ActionScript / Говнокод #8768

    −114

    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
    for(i=0;i<5;i++){
    		if(_root.positions[i] == number){
    // поменяем мувиклипы местами
    			p2=_root.positions[i+1];
    			with(_root){
    			switch(p2){
    				case 2: tx=b._x; ty=b._y; b._x=c._x; b._y=c._y; c._x=tx; c._y=ty; break;
    				case 1: tx=a._x; ty=a._y; a._x=c._x; a._y=c._y; c._x=tx; c._y=ty; break;
    				case 4: tx=d._x; ty=d._y; d._x=c._x; d._y=c._y; c._x=tx; c._y=ty; break;
    				case 5: tx=e._x; ty=e._y; e._x=c._x; e._y=c._y; c._x=tx; c._y=ty; break;
    				case 6: tx=f._x; ty=f._y; f._x=c._x; f._y=c._y; c._x=tx; c._y=ty; break;
    				default: break;
    			}
    			}

    Когда-то давно написал это, чтобы менять местами два прямоугольника, лежащие рядом, по нажатию на кнопку на одном из них. До сих пор горжусь тем, какой же я крутой кодер.

    unfalse, 08 Декабря 2011

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

    −89

    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
    def get_caller_module_dict(levels):
        try:
            raise RuntimeError
        except RuntimeError:
            e,b,t = sys.exc_info()
            f = t.tb_frame
            while levels > 0:
                f = f.f_back                   
                levels -= 1
            ldict = f.f_globals.copy()
            if f.f_globals != f.f_locals:
                ldict.update(f.f_locals)
    
            return ldict

    cxielamiko, 08 Декабря 2011

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

    +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
    public class Xorer {
        private static long SHIFR= 71180519;
        private Xorer() {
        }
    
        /**
         * ��������� �������� value XOR shifr
         * @param value ������� �������� �������� � ��������� �������
         * @return ��������� ��� �������� �������� � ��������� �������
         */
        public static synchronized String executeString(String value){
            String res=null;
            long code=0;
            try{
                  code=Long.parseLong(value);
            } catch(Exception e){
                e.printStackTrace();
            }
            res=execute(code);
            return res;
        }
    
        /**
         * ��������� �������� value XOR shifr
         * @param code ������� �������� �������� � ������� long
         * @return ��������� ��� �������� �������� � ��������� �������
        */
        public static synchronized String execute(long code){
            String res=null;
            if(code>0){
                long newvalue= code ^ SHIFR;
                res=""+newvalue;
            }
            return res;
        }
    }

    Вот вам ещё еда.

    nikelin, 08 Декабря 2011

    Комментарии (24)
  10. Куча / Говнокод #8765

    +132

    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
    local obj_on_cursor = objSetup:get("obj_on_cursor").value
      
                  if ( obj_on_cursor == "none" and 
    			 obj_on_cursor ~= "tool_pincers" and 
    			 obj_on_cursor ~= "tool_knife" ) then
    			 
    			objSetup:get("rope_clicked").value = 1
    			quest_callSFAction(objGame, "onRopeAttrition")
    			sf_worktable_rope_research_complete()
    			
    		elseif ( obj_on_cursor ~= "none" and 
    				 obj_on_cursor == "tool_pincers" and 
    				 obj_on_cursor ~= "tool_knife" ) then
    				 
    				objSetup:get("rope_clicked").value = 1
    				quest_callSFAction(objGame, "onRopeAttritionPincers")
    				sf_worktable_rope_research_complete()
    		
    		elseif ( obj_on_cursor ~= "none"  and 
    			    obj_on_cursor ~= "tool_pincers" and 
    			    obj_on_cursor ~= "tool_knife" ) then
    			quest_callSFAction(objGame, "onWrongTool")
    		end

    Прислали баг по миниигре. Человек, который делал минигру в отпуске, пришлось мне разбираться. Полез в код, а там такое... ХЗ, может и нормально, но у меня чуть глаза не выпали. Такой фигни там много, ~ 1.5К строк, хотя обычно минигра пишется максимум на 500 строк.

    MAGnit, 08 Декабря 2011

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