1. Список говнокодов пользователя spaceoflabview

    Всего: 5

  2. bash / Говнокод #6268

    −137

    1. 1
    find . -type f -exec sed -i 's^`/bin/date -v1d -v-1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y) yesterday" +%Y-%m-%d`^g;s^`/bin/date -v1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y)" +%Y-%m-%d`^g;s^`/bin/date -v+1m -v1d -v-1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y) + 1month - 1day" +%Y-%m-%d`^g;s^/bin/date -v-2d ^/bin/date --date "$(date +%m/%d/%Y) -2day" ^g;s^/bin/date -v-7d ^/bin/date --date "$(date +%m/%d/%Y) -7day" ^g;' {} \;

    spaceoflabview, 07 Апреля 2011

    Комментарии (4)
  3. Python / Говнокод #6267

    −369

    1. 1
    n=' '.join((n[::-1][n[::-1].find('_')+1:])[::-1].lower().replace('_',' ').split()).split()

    Нашел у себя в коде. Что делает уже не осилил вспомнить.

    spaceoflabview, 07 Апреля 2011

    Комментарии (10)
  4. Python / Говнокод #6117

    −97

    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
    if row[0].find('lk_s_du') > -1 or row[0].find('lk_s_su') > -1:
        price = ''
        if row[6] == 'incoming_external':
            if tariff['ie_price_second'] == 0:
                price = row[5] * tariff['ie_price_first'] / 102400
            elif ie_global > tariff['ie_price_switch']:
                price = row[5] * tariff['ie_price_second'] / 102400
            else:
                price = overhead(tariff['ie_price_switch']-ie_global,tariff['ie_price_switch'])*tariff['ie_price_first'] / 102400 + hev((row[5]+ie_global-tariff['ie_price_switch']))*tariff['ie_price_second'] / 102400
            ie_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        if row[6] == 'internal':
            if tariff['il_price_second'] == 0:
                price = row[5] * tariff['il_price_first'] / 102400
            elif il_global > tariff['il_price_switch']:
                price = row[5] * tariff['il_price_second'] / 102400
            else:
                price = overhead(tariff['il_price_switch']-il_global,tariff['il_price_switch'])*tariff['il_price_first'] / 102400 + hev((row[5]+il_global-tariff['il_price_switch']))*tariff['il_price_second'] / 102400
            il_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        if row[6] == 'outgoing_any':
            if tariff['oe_price_second'] == 0:
                price = row[5] * tariff['oe_price_first'] / 102400
            elif oe_global > tariff['oe_price_switch']:
                price = row[5] * tariff['oe_price_second'] / 102400
            else:
                price = overhead(tariff['oe_price_switch']-oe_global,tariff['oe_price_switch'])*tariff['oe_price_first'] / 102400 + hev((row[5]+oe_global-tariff['oe_price_switch']))*tariff['oe_price_second'] / 102400
            oe_global += row[5]
            unit = 'kb'
            if tariff['price_per_unit'] == 1:
                price = price /1024
                unit = 'mb'
            if tariff['price_per_unit'] == 2:
                price = price /1024/1024
                unit = 'gb'
            if tariff['price_per_unit'] == 3:
                price = price /1024/1024/1024
                unit = 'tb'
        price = str(price).replace('.',',')

    Черная магия непосредственно тарификации интернет-трафика.

    spaceoflabview, 29 Марта 2011

    Комментарии (7)
  5. 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)
  6. SQL / Говнокод #5978

    −864

    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
    SELECT foo.oper_id,
    	                     foo.client_id,
    			     base_clients.name,
    			     base_clients.options,
    			     base_providers.name,
    	  		     base_subproviders.name,
    			     base_clients.address_post,
    			     base_clients.balance,
    			     base_currency_types.descr,
    			     base_clients.descr,
    			     base_clients.client_type,
    			     base_clients.pdn_permission_taken,
    			     base_clients.person_use_srv_as_org,
    	             base_clients.none_client
    		      FROM   (SELECT oper_id,client_id FROM base_clients WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )   AND ( base_clients.client_id = '681843' OR base_clients.personal_id = '681843' OR base_clients.name ~ '[66][88][11][88][44][33]' OR base_clients.address_post ILIKE  '%681843%'OR base_clients.descr ILIKE '%681843%' )  UNION SELECT DISTINCT oper_id,client_id FROM telephone_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM channel_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM dry_pair_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM inet_dynamic_ip_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   
    				UNION 
    				    SELECT DISTINCT sss.oper_id, sss.client_id 
    					FROM inet_fixed_ip_services as sss
    					    left join inet_fixed_ip_group_items as itms on (sss.oper_id = itms.oper_id and sss.user_id = itms.ip_group )
    				    WHERE 
    					 (  sss.oper_id = 'TT'  OR sss.oper_id = 'SC'  OR sss.oper_id = 'TT2'  OR sss.oper_id = 'RC'  )  AND 
    					(  
    					    sss.user_id ILIKE '%681843%'  
    						OR
    					    itms.ip ILIKE '%681843%'  
    					)
    			     UNION SELECT DISTINCT oper_id,client_id FROM unix_shell_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM voip_ip_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM voip_card_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM ani_phone_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'   UNION SELECT DISTINCT oper_id,client_id FROM cable_tv_services WHERE  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  AND user_id ILIKE '%681843%'  UNION select distinct oper_id,client_id from base_client_aon_list where caller_phone = '681843' AND  (  oper_id = 'TT'  OR oper_id = 'SC'  OR oper_id = 'TT2'  OR oper_id = 'RC'  )  ) AS foo 
    		             JOIN 
    			     base_clients ON foo.oper_id=base_clients.oper_id AND 
    			                     foo.client_id=base_clients.client_id 
    			     JOIN 
    			     base_providers ON base_clients.oper_id=base_providers.oper_id 
    			     JOIN 
    			     base_currency_types ON base_clients.oper_id=base_currency_types.oper_id AND 
    			                            base_clients.currency_type=base_currency_types.currency_type
    	                     LEFT JOIN
    			     base_subproviders ON base_clients.oper_id=base_subproviders.oper_id AND
    	                                          base_clients.suboper_id=base_subproviders.suboper_id 
    	              ORDER BY to_number(base_clients.client_id,'999999999') DESC

    Это запрос на простой поиск клиента в биллинге.

    spaceoflabview, 14 Марта 2011

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