1. Python / Говнокод #8824

    −86

    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
    def search_with_city(obj1, obj2, obj3):
        print '------------Search by latitude, longitude and city------------'
        list1 = []
        list_new = []
        while True:
            line = file_airport.readline().lower()
            if obj3 in line:
                Str_file = ''.join(line)
                List_file2 = Str_file.split(',')
                if obj3 in List_file2[7]:
                    list1.append(List_file2)
                    for item in list1:
                        item.append(sqrt((float(item[11]) - float(obj1))**2 + (float(item[12]) - float(obj2))**2))
                        list_new = sorted(list1, key = lambda x: x[-1], reverse = False)
                    config = yaml.load(open('findairport.conf'))
                    outs = config['output']
                for List_file in list_new:
                    if List_file2[3] != List_file[3]:
                        for out in outs:
                            out = out % dict(airportcode = str(List_file[0]).upper(), distance = List_file[-1],\
                                airportname = str(List_file[13]).title(),  sa = str(List_file[8]).title(), street = str(List_file[10]).title(),\
                                city = str(List_file[7]).title(), state = str(List_file[5]).upper(), zip = List_file[3],\
                                country = str(List_file[2]).upper(), lat = str(List_file[11]), lon = str(List_file[12]+'\n'))
                            print out
            if not line:
                break
        try:
            if not obj1 in line and not obj2 in line and not obj3 in line:
                print 'Nothing more is been found'
        except:
            pass
        else:
            pass
        file_airport.seek(0)

    PHP'шники наступают! :)

    stalk, 14 Декабря 2011

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

    +145

    1. 1
    ;

    Пример реализации абстрактного класса
    https://lh6.googleusercontent.com/-rKfFtpL_K1A/Tuh34-faW_I/AAAAAAAAAi8/B05ygbQKIu8/w402/abstract_class.png

    ursus, 14 Декабря 2011

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

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public int RemoveEquals(AtASEData[] ar,int ln) {
       if (ln==0) return 0;
       int i=1;
       int j=0;
       while (i<ln) {
          if (((Integer)ar[i].inData).intValue()==((Integer)ar[j].inData).intValue())
          ar[i].SetRootData(ar[j]); else ar[++j]=ar[i];
          i++;
       }
       return j+1;
    }

    Loord, 14 Декабря 2011

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

    +980

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private string doubleToString(double v)
    {
        if (v < 0)
            return "-" + (-(int)v).ToString() + "." + (-(v - (int)v) * 10000000).ToString("0000000.");
        return ((int)v).ToString() + "." + ((v - (int)v) * 10000000).ToString("0000000.");
    }

    Превращаем double в строку. Разделитель - надо точку, а то "блин, он ставит запятую, SQL-сервер потом это не понимает" (с)

    Meowth, 14 Декабря 2011

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

    +1002

    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
    string Daumants::getReverse()
    {
    	string message = this->data();
    	char *reverseMessage = new char[this->length()];
    	for (int i = this->length() - 1, j = 0; i >= 0; i--, j++)
    	{
    		reverseMessage[j] = message[i];
    	}
    
    	for (int i = 0; i < this->length(); i++)
    	{
    		message[i] = reverseMessage[i];
    	}
    
    	return message;
    }

    Даумант ХУЙ!

    toxicDuck, 14 Декабря 2011

    Комментарии (99)
  6. JavaScript / Говнокод #8819

    +158

    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
    <!--//
    calendar = new Date();
    day = calendar.getDay();
    document.write("<table width=100 border=1><tr><td><center><font size=2>")
    if (day == 0) {
    document.write("<font color=#ff0000>Воскресенье</font>")
    }
    if (day == 1) {
    document.write("Понедельник")
    }
    if (day == 2) {
    document.write("Вторник")
    }
    if (day == 3) {
    document.write("Среда")
    }
    if (day == 4) {
    document.write("Четверг")
    }
    if (day == 5) {
    document.write("Пятница")
    }
    if (day == 6) {
    document.write("<font color=#ff0000>Суббота</font>")
    }
    document.write("</font></center></td></tr><tr><td><center><font size=2>")
    month = calendar.getMonth();
    if (month == 0) {
    document.write("Январь")
    }
    if (month == 1) {
    document.write("Февраль")
    }
    if (month == 2) {
    document.write("Март")
    }
    if (month == 3) {
    document.write("Апрель")
    }
    if (month == 4) {
    document.write("Май")
    }
    if (month == 5) {
    document.write("Июнь")
    }
    if (month == 6) {
    document.write("Июль")
    }
    if (month == 7) {
    document.write("Август")
    }
    if (month == 8) {
    document.write("Сентябрь")
    }
    if (month == 9) {
    document.write("Октябрь")
    }
    if (month == 10) {
    document.write("Ноябрь")
    }
    if (month == 11) {
    document.write("Декабрь")
    }
    
    document.write("</font></center></td></tr><tr><td><center><font size=6>")
    date = calendar.getDate();
    document.write(date)
    document.write("</font></center></td></tr><tr><td><center><font size=2>")
    year = calendar.getYear();
    if (year < 100) {
    document.write("19" + year + "")
    }
    else if (year > 1999) {
    document.write(year)
    }
    document.write("</font></center></td></tr></table>")
    //-->

    Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.

    nibb13, 14 Декабря 2011

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    for (; itemList.Parent != null; {
            Item parent;
            itemList = parent.Parent;
        }
    )
    {
        parent = itemList.Parent.Parent.Parent;
        list.Add((object) parent);
    }

    Crazzy, 14 Декабря 2011

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

    −109

    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
    end;
    create or replace package body "MUT_TABLE" is
    type a_table is table of number index by pls_integer;
    position a_table;
    empty a_table;
    
    procedure SET_INITIAL_STATE
    as
    begin
    position:=empty;
    end SET_INITIAL_STATE;
    
    procedure BEF_TR( ID IN NUMBER, A IN NUMBER)
    as
    
    begin
    
    position (ID):= A;
    
    end BEF_TR;
    
    procedure AFT_TR
    is
    v number;
    
    begin
    v:=position.FIRST;
    while v is not null loop
    
    update A set
    A=1,
    B='!!!!!!!!!'
    where A = 1;
    v:= position.next(v); 
    end loop;
    
    end AFT_TR;
    
    end "MUT_TABLE";

    kikis, 14 Декабря 2011

    Комментарии (4)
  9. SQL / Говнокод #8816

    −111

    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
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    CREATE TABLE "A" 
    ( "ID" NUMBER, 
    "A" NUMBER, 
    "B" VARCHAR2(20), 
    CONSTRAINT "A_PK" PRIMARY KEY ("ID") ENABLE
    )
    /
    
    CREATE OR REPLACE TRIGGER "A_2" 
    AFTER
    insert or update on "A"
    for each row
    begin
    
    mut_table.bef_tr(:NEW.ID,:NEW.A);
    
    end;
    /
    ALTER TRIGGER "A_2" ENABLE
    /
    
    CREATE OR REPLACE TRIGGER "A_3" 
    AFTER
    insert on "A"
    declare
    b number;
    
    begin
    mut_table.aft_tr;
    end;
    /
    ALTER TRIGGER "A_3" ENABLE
    /
    
    CREATE OR REPLACE TRIGGER "A_AT" 
    BEFORE
    insert or update on "A"
    for each row
    declare 
    v number;
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
    
    :NEW.A:=:NEW.A+1;
    :NEW.B:='!!!!!!!!!!';
    
    commit;
    
    end;
    /
    ALTER TRIGGER "A_AT" DISABLE
    /
    
    CREATE OR REPLACE TRIGGER "A_I_S" 
    BEFORE
    insert or update on "A"
    begin
    mut_table.set_initial_state;
    end;
    /
    ALTER TRIGGER "A_I_S" ENABLE
    /
    
    CREATE OR REPLACE TRIGGER "A_T1" 
    BEFORE
    insert or update on "A"
    for each row
    
    begin
    
    update A set 
    A = :NEW.A+1,
    B = 'was incremented'
    where A = :NEW.A;
    end;
    /
    ALTER TRIGGER "A_T1" DISABLE
    /
    
    CREATE OR REPLACE TRIGGER "BI_A" 
    before insert on "A" 
    for each row 
    begin 
    if :NEW."ID" is null then 
    select "A_SEQ".nextval into :NEW."ID" from dual; 
    end if; 
    end; 
    
    /
    ALTER TRIGGER "BI_A" ENABLE
    /
    
    
    create or replace package MUT_TABLE as
    
    procedure set_initial_state;
    procedure bef_tr(ID number,A NUMBER);
    procedure aft_tr;

    kikis, 14 Декабря 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?
    if(!file_exists($abs_path)){
      $new = "Y";
      // ...
    }
    //...
    if(strlen($new) > 0  ){
    // ...
    ?>

    Угадай CMS по коду!

    belukov, 14 Декабря 2011

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