- 1
- 2
- 3
- 4
Когда написал залупу на крестах
https://pbs.twimg.com/media/EQNGt9QU4AABnd1?format=png&name=small
Именно поэтому я за Electron.js
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Когда написал залупу на крестах
https://pbs.twimg.com/media/EQNGt9QU4AABnd1?format=png&name=small
Именно поэтому я за Electron.js
−1
g = {'А', 'Е', 'Ё', 'И', 'У', 'О', 'Я', 'Ы', 'Э', 'Ю'}
s = input().split()
last = -1
start = -1
first = 0
f = 0
GL = 0
gl = 0
cnt = 0
el = s[0]
if len(s) == 1:
el = s[0]
for i in range(len(el)):
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].upper() in g:
gl += 1
GL += 1
if el[i].isupper():
start = gl
f = 1
if gl and not f:
print('ошибка')
exit()
if start == -1:
print('не стихи')
exit()
if (start == 2 and gl == 3) \
or (start == 1 and gl == 2) \
or (start == 2 and gl == 2):
print('недостаточно информации')
exit()
last = -1
start = -1
first = 0
GL = 0
f = 0
gl = 0
cnt = 0
el = s[0]
while start == -1 and first < len(s):
el = s[first]
first += 1
for i in range(len(el)):
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].upper() in g:
gl += 1
GL += 1
if el[i].isupper():
start = gl
gl = 0
f = 1
if gl and not f:
print('ошибка')
exit()
if start == -1:
print('не стихи')
exit()
cnt = gl
for k in range(first, len(s)):
el = s[k]
f = 0
gl = 0
cnt = cnt
for i in range(len(el)):
if el[i].upper() in g:
cnt += 1
gl += 1
GL += 1
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].isupper():
if last == -1:
last = cnt
cnt = 0
elif cnt != last:
print('не стихи')
exit()
else:
cnt = 0
f = 1
if gl and not f:
print('ошибка')
exit()
if GL == 1:
print('не стихи')
exit()
if start > 3 or last > 3 or cnt > 2:
print('не стихи')
exit()
if start == 1:
if last == 2 and cnt < last:
print('хорей')
elif (last == 3 or last == -1) \
and cnt < 3:
print('дактиль')
else:
print('не стихи')
elif start == 2:
if (last == 2 and cnt < last) \
or last == -1:
print('ямб')
elif last == 3:
print('амфибрахий')
else:
print('не стихи')
elif start == 3 \
and (last == 3 or last == -1):
print('анапест')
else:
print('не стихи')
0
$('#calculator').on('change', clr);
$('#calculator').on('change', total_sum);
$('#calculator').on('click', '.title', add_block);
$('#calculator').on('change', total_kg);
$("input[name='group1']").on('click', total_sum);
$("input[name='pack']").on('click', total_sum);
$('#calculator').on('click', '.title', total_sum);
$('#dop_block_0').html(
'<select size="1" name="paper" class="paper" id="paper_0">' +
'<option selected="" disabled="">Вид макулатуры</option>' +
'<option value="Картон">Картон</option>' +
'<option value="Книги, журналы">Книги, журналы</option>' +
'<option value="Архив">Архив</option>' +
'<option value="Полиэтилен">Полиэтилен</option>' +
'<option value="Газеты">Газеты</option>' +
'</select>' +
'<input type="text" placeholder="Вес в килограммах" name="weight" class="masa" id="masa_0" min="0">' +
'<p>' +
'Цена (руб/кг): <input type="text" class="price" value="0" disabled=""><input type="hidden" class="cur" id="cur_0" value="0" disabled="">' +
'</p>'
);
function total_kg() {
var i = 0;
var kg_ol = 0;
while (i < 6) {
var t = +$("#masa_" + i).val();
if (t !== t) { t = 0 };
kg_ol += t;
i++;
}
if (kg_ol >= 300) {
$('#test').attr('disabled', false);
}
else {
$('#test').attr('disabled', true);
$('#test').attr('checked', false);
$('#test').attr('checked', true);
}
};
function total_sum() {
var i = 0;
var pri0 = $("#test_block_" + i).find('.cur').val();
var price_ol = 0;
if (pri0 !== pri0) { pri0 = 0 };
while (i < 6) {
var t = +$("#test_block_" + i).find('.cur').val();
if (t !== t) { t = 0 };
price_ol += t;
i++;
}
$('.cur_ol').text(price_ol);
};
function add_block() {
var parent_id = $(this).parent().attr('id');
if ($('#' + parent_id + ' .block_dop').text() == "") {
$('#' + parent_id + ' .block_dop').html('<select size="1" name="paper" class="paper">' +
'<option selected disabled>Вид макулатуры</option>' +
'<option value="Картон">Картон</option>' +
'<option value="Книги, журналы">Книги, журналы</option>' +
'<option value="Архив">Архив</option>' +
'<option value="Полиэтилен">Полиэтилен</option>' +
'<option value="Газеты">Газеты</option>' +
'</select>' +
'<input type="text" placeholder="Вес в килограммах" name="weight" class="masa" id="masa_' + colum + '" min="0">' +
'<p>Цена (руб/кг): <input type="text" class="price" value="0" disabled><input type="hidden" class="cur" value="0" disabled></p>' +
'<script>jQuery(function($){$("#masa_' + colum + '").mask("999999",{placeholder:"",autoclear: false});});</script>');
$('#' + parent_id + ' .block_dop').slideDown();
$(this).html('Убрать вид макулатуры');
if (colum < 5) {
console.log("1=2");
var st = colum + 1;
$('#calculator .param').append('<div id="dop_block_' + st + '" class="dop">' +
'<p class="title">Добавить вид макулатуры</p>' +
' <div class="block_dop"></div>' +
'</div>');
colum++;
};
}
else {
if (colum == 1) {
console.log("2=1");
$('#' + parent_id + ' .block_dop').slideUp();
$('#' + parent_id + ' .block_dop').html("");
$(this).html('Добавить вид макулатуры');
console.log("сolum=" + colum);
}
else {
console.log("2=2");
$('#' + parent_id).slideUp();
$('#' + parent_id).remove();
colum--;
};
function clr() {
var i = 0;
while (i < 6) {
var price = 0;
var x = $("#dop_block_" + i).find('.paper').val();
if ($('input[name=group1]:checked').val() == 2 && $('input[name=pack]:checked').val() == 1){
switch (x) {
case '1'://Картон
Кокой "Java Script"
+1
Гуляя по парку, сразу кинулось в глаза,что лебедей в пруду нет.
Оказалось, что они пали жертвами бродячих псов.
Ах, твою ж мать!
ceo
#птичку жалко_пост
−3
Davaj'te ebat'sja v zhopu
0
https://pastebin.com/hC1Ux6kC
По колено в коде... Код одной обезьяны, которая решилась дописать вакабу до ума... спойлер: судя по коду она обосралась, уберите от экрана детей и беременных женщин
+2
SELECT SQL_NO_CACHE IT.itemCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.ean),",", 1) as ean,
SUBSTRING_INDEX(GROUP_CONCAT(IT.artCode),",", 1) as artCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.description),",", 1) as description,
SUBSTRING_INDEX(GROUP_CONCAT(IT.siteName),",", 1) as siteName,
SUBSTRING_INDEX(GROUP_CONCAT(IT.familyName),",", 1) as familyName,
SUBSTRING_INDEX(GROUP_CONCAT(IT.familyCode),",", 1) as familyCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.SSfamilyCode),",", 1) as SSfamilyCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.SSfamilyName),",", 1) as SSfamilyName,
SUBSTRING_INDEX(GROUP_CONCAT(IT.sectorCode),",", 1) as sectorCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.sectorName),",", 1) as sectorName,
SUBSTRING_INDEX(GROUP_CONCAT(IT.radiusCode),",", 1) as radiusCode,
SUBSTRING_INDEX(GROUP_CONCAT(IT.radiusName),",", 1) as radiusName,
FI.areaName,
FI.areaCode,
ROUND(SUM(IT.price), 2) as price,
SUM(IT.quantity) as theoreticalQty,
IFNULL(FI.countedQty, 0) as countedQty,
ROUND(SUM(IT.quantity) * ROUND(SUM(IT.price), 2), 2) as theoreticalQtyValue,
ROUND(IFNULL(FI.countedQty, 0) * ROUND(SUM(IT.price), 2), 2) as countedQtyValue,
IFNULL(FI.countedQty, 0) - SUM(IT.quantity) as stockGapQty,
ROUND((IFNULL(FI.countedQty, 0) - SUM(IT.quantity)) * SUM(IT.price), 2) as stockGapValue,
DATE_FORMAT(ST.lastImport, "%d-%m-%Y %H:%i:%s") as dateOfLastImport,
DATE_FORMAT(NOW(), "%d-%m-%Y %H:%i:%s") as dateOfExport
FROM Items as IT
LEFT JOIN (
SELECT MIN(FI.ean) as ean, SUM(FI.quantity) as countedQty, IT.itemCode,
GROUP_CONCAT(DISTINCT AR.name) as areaName,
GROUP_CONCAT(DISTINCT AR.code) as areaCode
FROM FoundItems as FI
INNER JOIN Items as IT ON FI.ean = IT.ean
LEFT JOIN Areas as AR ON AR.id = FI.areaId
INNER JOIN Stores as ST ON ST.id = IT.storeId
WHERE eventId = ${args.eventId}
AND IT.storeId = (SELECT storeId FROM Events WHERE id = ${args.eventId})
GROUP BY IT.itemCode
) as FI ON IT.itemCode = FI.itemCode
INNER JOIN Stores as ST ON ST.id = IT.storeId
WHERE IT.storeId = (SELECT storeId FROM Events WHERE id = ${args.eventId})
GROUP BY IT.itemCode, FI.areaName, FI.areaCode, FI.countedQty, dateOfLastImport
а що ця конструкція вміє, а ета що, про та ще й ето потрібно впихнути сюди
+1
// reflection.h
template <class T>
QStringList getPropertyList(T)
{
const QMetaObject& metaObject = T::staticMetaObject;
...
return properties;
}
// Copy-pasted, the parameter now is T*
template <class T>
QStringList getPropertyList(T*)
{
const QMetaObject& metaObject = T::staticMetaObject;
...
return properties;
}
// In other headers
class IMessage
{
public:
virtual ~IMessage();
...
};
class File
: public IMessage
{
...
};
class Text
: public IMessage
{
...
};
// Usage of all this
QStringList p;
p << getPropertyList(File());
p << getPropertyList(Text());
p << getPropertyList(static_cast<IMessage*>(new File()));
Работаю с шаблонами и теку
+1
// https://gcc.gnu.org/onlinedocs/cpp/Directives-Within-Macro-Arguments.html
// Occasionally it is convenient to use preprocessor directives within the arguments
// of a macro. The C and C++ standards declare that behavior in these cases is
// undefined. GNU CPP processes arbitrary directives within macro arguments in
// exactly the same way as it would have processed the directive were the
// function-like macro invocation not present.
// If, within a macro invocation, that macro is redefined, then the new definition
// takes effect in time for argument pre-expansion, but the original definition is
// still used for argument replacement. Here is a pathological example:
#define f(x) x x
f (1
#undef f
#define f 2
f)
// which expands to
// 1 2 1 2
Ну и хуйня.
+2
// https://godbolt.org/z/dMT7v3
unsigned div_eq(unsigned a, unsigned b)
{
ALWAYS_TRUE(a == b);
return a/b;
}
unsigned div(unsigned a, unsigned b)
{
return a/b;
}
int test_array(unsigned char a[10])
{
for (int i = 1; i < 10; i++)
{
ALWAYS_TRUE(a[i-1] <= a[i]);
}
return a[0] <= a[2];
}
Refinement type
Можно этой хуйней ассерты позаменять попробовать, и компилятор возможно что-то сможет за счет этого соптимизировать