1. Лучший говнокод

    В номинации:
    За время:
  2. Python / Говнокод #6116

    −83

    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
    for row in rows:
        service = row[0].split('_')
        if row[0].find('lk_s_du') > -1:
            loki_cursor.execute("""select tariff_id from inet_inetsessionlog where id = %s;""", (service[-1],))
            tariff_id = str(loki_cursor.fetchall()[0][0])
        else:
            if row[1] == 'inet_dynamic_ip':
                cursor.execute('select tariff_plan from inet_dynamic_ip_services where id = %s', (service[-1],))
                tariff = str(cursor.fetchall()[0][0])
            elif row[1] == 'inet_fixed_ip':
                if row[0].split('_')[-1].find('.') == -1:
                    cursor.execute('select tariff_plan from inet_fixed_ip_services where id = %s', (service[-1],))
                else:
                    cursor.execute('select tariff_plan from inet_fixed_ip_services where id = %s', (service[-2],))
                tariff = str(cursor.fetchall()[0][0])
            loki_cursor.execute("select tariff_ptr_id from inet_inettariff where cherry_id = %s", (tariff,))
            tariff_id = str(loki_cursor.fetchall()[0][0])
        loki_cursor.execute("select * from inet_inettariff where tariff_ptr_id = %s", (tariff_id,))
        tariff = loki_cursor.fetchall()[0]
    tariff = dict(zip(('tariff_ptr_id', 'price_per_unit', 'is_dynamic', 'cherry_id', 'ie_price_first', 'ie_price_second', 'ie_price_switch', 'oe_price_first', 'oe_price_second', 'oe_price_switch', 'il_price_first', 'il_price_second', 'il_price_switch', 'ol_price_first', 'ol_price_second', 'ol_price_switch'), tariff))
        if login in row[0]:
            print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').encode('utf-8')
        else:
            print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').replace(date_start,u'Суммарно').encode('utf-8')
    else:
        price = str(row[7]).replace('.',',')
        if login in row[0]:
            print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').encode('utf-8')
        else:
            print>>o, (str(row[2]) + ';' + row[4] + ';' + str(row[5]).replace('.000000', '').replace('.', ',') + ';' + row[6] + ';' + str(price)).decode('utf-8').replace(u'incoming_external', u'Входящий внешний').replace(u'internal', u'Внутренний').replace(u'outgoing_any',u'Исходящий внешний').replace(date_start,u'Суммарно').encode('utf-8')

    Кусочек интернет-тарификатора.

    spaceoflabview, 29 Марта 2011

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

    +190

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // Count how many rows are in the table.
        for (var x = 0; x < tableRows.length; ++x)
        {
        	rowCount += 1;
        }

    napmor1, 26 Марта 2011

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

    +113

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    int main(int argv,char *argc[]){
      ...
      if(fork() != 0)goto _EXIT;
      ...
      return 0;
    _EXIT:
      return 0;
    }

    Ну как ???

    Mooncrafter, 24 Марта 2011

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

    −863

    1. 1
    2. 2
    3. 3
    WHERE (p.city_id = 1)
       AND ((COALESCE(b.banket_persons,0)=0) OR (b.banket_persons>=20 AND b.banket_persons<=30))
       AND ((COALESCE(b.banket_per_person,0)=0) OR (b.banket_per_person>=500 AND b.banket_per_person<=1000))

    упорный программер явно не подозревал о существовании "is null" и "between"

    NaCilnic, 24 Марта 2011

    Комментарии (5)
  6. PHP / Говнокод #6081

    +167

    1. 1
    2. 2
    $handle = fopen($filename, "a+");
    fwrite($handle, '');

    В цикле таким образом измененяли дату модификации файлов. Существование touch() похоже было неизвестно.

    tkf, 24 Марта 2011

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

    −94

    1. 1
    var toCrypt:String = encodeURIComponent("GET")

    пруф: https://github.com/ptitJean/AS3FaceApi/blob/master/net/metafor/faceapi/auth/OAuth.as

    wvxvw, 22 Марта 2011

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

    +162

    1. 1
    2. 2
    return vars[v] = ($.inArray(v, wndConfig["out_zero"]) !== -1)
      ? (tmp == 0 ? 0 : tmp) : tmp;

    Из серии "в пятницу вечером". Ладно хоть сейчас перечитал этот кусок и увидел.

    telnet, 19 Марта 2011

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

    +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
    if (defaultOrderType == OrderType.NoCharge || defaultOrderType == OrderType.Claims)
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "block");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "none");
        items.Style.Add(HtmlTextWriterStyle.Display, "none");
    }
    else
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "none");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "block");
        items.Style.Add(HtmlTextWriterStyle.Display, "block");
    }

    abatishchev, 18 Марта 2011

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

    +160

    1. 1
    2. 2
    float alpha = float(m_startAlpha) + 255.0f * (getElapsed() / (m_duration * (1.0f - float(m_startAlpha) / 255.0f)));
    m_target->setAlpha(static_cast<uint8_t>(alpha));

    Выдержка из обновления объекта-действия, производящего линейный фейд-аут объекта...

    Общение с чужим говнокодом не проходит бесследно... что же я курил, перед тем как ЭТО соорудить?

    Kirinyale, 14 Марта 2011

    Комментарии (5)
  11. PHP / Говнокод #5971

    +160

    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
    public function get_settings($id,$name,$total,$limit)
    {    
        $config = array();
        $config['total_rows'] = $total;
        $config['per_page'] = $limit;    
        $config['first_link'] = '&laquo;Первая';
        $config['last_link'] = 'Последняя&raquo;';
        $config['next_link'] = '&raquo;';
        $config['prev_link'] = '&laquo;';
    
        switch($id)
        {
            // Если навигация для категорий
            case 'category':            
                
                $config['base_url'] = base_url().'/index/category/'.$name;      
                $config['uri_segment'] = 4;
                
                //количество "цифровых" ссылок по бокам от текущей
                $config['num_links'] = 5;             
                
                return $config;            
                break; 
                
        }
    }

    qbasic, 13 Марта 2011

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