- 1
#define GUIDSTR(s) __uuidof(class DECLSPEC_UUID(s) __guid_##__COUNTER__)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
#define GUIDSTR(s) __uuidof(class DECLSPEC_UUID(s) __guid_##__COUNTER__)
Может можно покороче?
0
if( sync_ip_index < 0 && result() ) {
QString tmp = tr(", нет синхронизации");
addResultMessage( false, p->dev(), tmp);
p->dev()->setState( CDiagramObject::e_Warning );
setResult( false );
}
else if ( sources_from_xml.indexOf( sources_from_ntpq[ sync_ip_index ] ) < 0) {
// ( ( (sync_ip_index >= 0) ? ( sources_from_xml.indexOf( sources_from_ntpq[ sync_ip_index ] ) < 0 ) : false ) ) {
// (p1 ( p2 ) ( p3 ( f1 ) )
// p1..3 - predicates
// Check sync_ip_index >= 0 (p2)
// true, then
// find sync source ip in list filled from xml config , and if there is finded, (p3) are true, else (p3) are false, and then (p1) will be false
// false, then
// (p1) will be false
// This construction for one string check syncronized source ip for host, if host not synchronized
QString tmp = tr(", хост синхронизирован с источником не указанным в схеме");
addResultMessage( false, p->dev(), tmp);
p->dev()->setState( CDiagramObject::e_Warning );
setResult( false );
}
Под конец рабочего дня уже поехала крыша, см. комментарии.
+1
select value, value_type from b_iblock_element_property WHERE id = **;
b_iblock_element_property.value: a:2:{s:4:"TYPE";s:4:"text";s:4:"TEXT";s:17:"Хорошее состояние";}
b_iblock_element_property.value_type: text
bitrix <3
+2
auto id = qobject_cast<QStandardItemModel *>(ui->cbxDevice->model())
->item(ui->cbxDevice->currentIndex(),
RemoteDev::Constants::DEV_ID_COLUMN)
->data(RemoteDev::Constants::DEV_ID_ROLE);
Q(Styled)ItemDelegate::setModelData, достаем данные из модели комбобокса: другая колонка, кастомная роль. Жиза :(
+2
$model->attributes = $_POST[$class];
// костыль на ajax валидацию и отправку файлов
$save = isset($_GET['notsave']) ? false : true;
if ($save) {
видимо автор кода соглашается с "хорошим" решением...
0
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 77.1 97.7" style="enable-background:new 0 0 77.1 97.7;" xml:space="preserve">
<style type="text/css">
.st0{fill:#010101;}
.st1{fill:#FFC627;}
.st2{fill:#FFD432;}
.st3{fill:#231F20;}
.st4{fill:#FFFFFF;}
</style>
<g>
<g>
<g>
<g>
<path class="st0" d="M6.1,71.6c-3.3,0-6.1,2.7-6.1,6.1v13.9c0,3.3,2.7,6.1,6.1,6.1h61.3c3.3,0,6.1-2.7,6.1-6.1V77.7
c0-3.3-2.7-6.1-6.1-6.1H6.1z"/>
<path class="st1" d="M67.3,73.5H6.1c-2.3,0-4.1,1.9-4.1,4.1v13.9c0,2.3,1.8,4.1,4.1,4.1h61.3c2.3,0,4.1-1.8,4.1-4.1V77.7
C71.5,75.4,69.6,73.5,67.3,73.5 M69.5,91.6c0,1.2-1,2.2-2.2,2.2H6.1c-1.2,0-2.2-1-2.2-2.2V77.7c0-1.2,1-2.2,2.2-2.2h61.3
c1.2,0,2.2,1,2.2,2.2V91.6z"/>
.........
</g>
</g>
</g>
<path class="st1" d="M73.4,73.4c0-1.1,0.9-1.8,1.8-1.8c1,0,1.8,0.7,1.8,1.8c0,1.1-0.9,1.8-1.8,1.8C74.3,75.2,73.4,74.5,73.4,73.4
M75.3,72c-0.8,0-1.4,0.6-1.4,1.4c0,0.8,0.6,1.4,1.4,1.4c0.8,0,1.4-0.6,1.4-1.4C76.6,72.5,76,72,75.3,72 M74.9,74.4h-0.4v-2h0.8
c0.5,0,0.8,0.2,0.8,0.6c0,0.4-0.2,0.5-0.5,0.5l0.5,0.9h-0.4l-0.4-0.9h-0.2V74.4z M74.9,73.2h0.3c0.3,0,0.4-0.1,0.4-0.3
c0-0.2-0.1-0.3-0.4-0.3h-0.3V73.2z"/>
</g>
</svg>
а вы когда-нибудь заглядывали в SVG?
+1
public static CategoryAttribute Build(string category_name, string attribute_type, string attribute_name, object attribute_value)
{
try
{
CategoryAttribute document_attribute;
switch(attribute_type)
{
case "string":
case "double_as_string":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.String);
break;
case "string_as_date":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.DateTime);
break;
case "int":
case "double_as_int":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Integer);
break;
case "double":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Double);
break;
default:
throw new ApplicationException("Не верно настроен тип данных атрибута '" + attribute_name + "' категории '" + category_name + "'.");
}
if (attribute_value == null)
return document_attribute;// атрибут остался неопределенным
switch (document_attribute.Type)
{
case TypeEnum.String:
{
switch (attribute_type)
{
case "string":
{
if (!(attribute_value is string))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.sValue = attribute_value as string;
} break;
case "double_as_string":
{
if (!(attribute_value is double))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.sValue = ((double)attribute_value).ToString();
} break;
}
}
break;
case TypeEnum.Integer:
{
switch (attribute_type)
{
case "int":
{
if (!(attribute_value is int))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.iValue = (int)attribute_value;
} break;
case "double_as_int":
{
if (!(attribute_value is double))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.iValue = (int)(double)attribute_value;
} break;
}
}
break;
case TypeEnum.Double:
{
if (!(attribute_value is float || attribute_value is double || attribute_value is int || attribute_value is long))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" + attribute_type + "'.");
document_attribute.dValue = (double)attribute_value;
}
break;
}
return document_attribute;
catch (Exception e)
{
//...
}
}
Создание объекта типа CategoryAttribute.
0
$(".tabs_nav-item").click ->
if($(this).hasClass("_active"))
else
$this = $(this)
target = $(this).attr("href")
$this.addClass("_active").siblings("._active").removeClass("_active")
$(target).addClass("_active").siblings("._active").removeClass("_active")
LOL
P.S. coffeescript
+1
string str3 = Strings.Trim(ID);
do
{
num2 = (short) Strings.InStr(str3, " ", CompareMethod.Binary);
if (num2 > 0)
{
str3 = str3.Substring(0, num2 - 1) + Strings.Mid(str3, num2 + 1);
}
}
while (num2 > 0);
А зачем нам str3.Replace(" ", string.Empty) ?
+1
section.static > div[style="display:block; border: solid 1px #cfcfcf; padding : 10px"]{
border: none !important;
padding: 0 !important;
}
css-костыль!)