- 1
(addNewItem) ? (isVideoAudioAttached = true) : (isVideoAudioAttached = false);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+174
(addNewItem) ? (isVideoAudioAttached = true) : (isVideoAudioAttached = false);
addNewItem и isVideoAudioAttached типа bool
−181
from django.db import models
# Класс Студент
class Student(models.Model):
name = models.CharField(max_length=50) # ФИО студента
group = models.CharField(max_length=10) # Группа студента
starosta = models.BooleanField(default=False) # Является ли студент старостой группы?
# Класс Пара
class Pair(models.Model):
name = models.CharField(max_length=30) # Название пары
auditory = models.CharField(max_length=7) # Аудитория
lecturer = models.CharField(max_length=50) # ФИО преподавателя
# Класс День
class Day(models.Model):
pair1 = models.ForeignKey(Pair) # Первая пара
pair2 = models.ForeignKey(Pair) # Вторая пара
pair3 = models.ForeignKey(Pair) # Третья пара
pair4 = models.ForeignKey(Pair) # Четвёртая пара
pair5 = models.ForeignKey(Pair) # Пятая пара
pair6 = models.ForeignKey(Pair) # Шестая пара
pair7 = models.ForeignKey(Pair) # Седьмая пара
# Класс Расписание
class TimeTable(models.Model):
group = models.CharField(max_length=10) # Группа, к которой относится расписание
weekcolor = models.BooleanField() # False, 0 - Красная неделя; True, 1 - Синяя неделя
monday = models.ForeignKey(Day) # Понедельник
tuesday = models.ForeignKey(Day) # Вторник
wednesday = models.ForeignKey(Day) # Среда
thursday = models.ForeignKey(Day) # Четверг
friday = models.ForeignKey(Day) # Пятница
saturday = models.ForeignKey(Day) # Суббота
Очередной шедевр от Magister Yoda
Попытка сделать модель расписания для студентов.
−97
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('.',',')
Черная магия непосредственно тарификации интернет-трафика.
−83
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')
Кусочек интернет-тарификатора.
+172
CString convertInt2Str(int i_Number, int i_NumDigits)
{
CString str = "";
for(int j=1; j<i_NumDigits; j++)
{
int digits = (int) pow((float) 10, j);
if(i_Number<digits) str += "0";
}
CString num;
num.Format("%d", i_Number);
return str+num;
}
Adding leading zeros...
+162
Speed = ini.GetInt("Speed" , Speed /(1 mm_s )) * (-1 mm_s);
Скорость задается изначально как положительное число, но в ресчетах используется ее отрицательное значение.
−103
к = 0;
ТЗ2=СоздатьОбъект("ТаблицаЗначений");
ВыгрузитьТабличнуюЧасть(ТЗ2,"ТМЦ,Кво");
ТЗ2.НоваяКолонка("Арт");
ТЗ2.ВыбратьСтроки();
Пока ТЗ2.ПолучитьСтроку()=1 Цикл
ТМЦ_=ТЗ2.ПолучитьЗначение(к+1,"ТМЦ");
Если Лев(ТМЦ_,5)="Набор" Тогда
ТЗ2.Арт=ТМЦ_.Родитель;
Иначе
ТЗ2.Арт=ТМЦ_.Родитель.Родитель;
КонецЕсли;
к=к+1;
КонецЦикла;
Из 7.7. Особенно радует момент ТМЦ_=ТЗ2.ПолучитьЗначение(к+1,"ТМЦ");
+166
$expired = (time() > 1280241436) ? true : false;
if ($expired) { return; }
В начале кэш-файлов phpBB3.
−862
SET @SQL = '
SELECT
@diff1 = @diff1 + ''CASE WHEN '' + Field_Name + ''=@'' + Field_Name +
'' OR ('' + Field_Name + '' IS null AND @'' + Field_Name + '' IS NULL) THEN ''''''''
ELSE '''''' + Field_Name + ''="''''+COALESCE(CAST('' + Field_Name + '' AS varchar(max)), ''''NULL'''')
+ ''''", '''' END +'',
@diff2 = @diff2 + ''CASE WHEN '' + Field_Name + ''=@'' + Field_Name +
'' OR ('' + Field_Name + '' IS Null AND @'' + Field_Name + '' IS NULL) THEN ''''''''
ELSE '''''' + Field_Name + ''="''''+COALESCE(CAST(@'' + Field_Name + '' AS varchar(max)), ''''NULL'''')
+ ''''", '''' END +'',
@declare = @declare + ''DECLARE @'' + Field_Name + '' '' + Field_Type + '';'',
@set = @set + ''SET @'' + Field_Name + ''='' + Field_Value + '';''
FROM (' + @pre + ') AS t'
Моё. Кусочек небольшой хранимки в 700 строк.
Формирование SQL-a, который формирует SQL, который, в свою очередь, формирует строку для записи изменений таблицы в лог.
−87
ТекЗакладка=0;
Если ТекЗакладка=0 тогда ТекЗакладка=1;КонецЕсли;
Путаем следы?