- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
std::queue<char *> outQueue2;
std::lock_guard<std::mutex> lock(mtx);
mtx.lock();
if (outQueue.size() > 0) {
std::swap(outQueue2, outQueue);
outQueue = {};
}
std::lock_guard<std::mutex> unlock(mtx);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
std::queue<char *> outQueue2;
std::lock_guard<std::mutex> lock(mtx);
mtx.lock();
if (outQueue.size() > 0) {
std::swap(outQueue2, outQueue);
outQueue = {};
}
std::lock_guard<std::mutex> unlock(mtx);
со слов автора:
у меня 2 исходящие очереди
в одну соседний поток ложит
потом приходит тик
врубает симафор
копирует по-бырому очередь
и чистит её
дальше отпускает поток
чтобы не ждать
пока всё отправится
и спокойно в соседнем потоке уже начинает BYtestream...
и всё такое
разьве не так делают в домах парижу?
+1
utf8 = {}
function utf8.charbytes(s, i)
-- argument defaults
i = i or 1
local c = string.byte(s, i)
-- determine bytes needed for character, based on RFC 3629
if c > 0 and c <= 127 then
-- UTF8-1
return 1
elseif c >= 194 and c <= 223 then
-- UTF8-2
local c2 = string.byte(s, i + 1)
return 2
elseif c >= 224 and c <= 239 then
-- UTF8-3
local c2 = s:byte(i + 1)
local c3 = s:byte(i + 2)
return 3
elseif c >= 240 and c <= 244 then
-- UTF8-4
local c2 = s:byte(i + 1)
local c3 = s:byte(i + 2)
local c4 = s:byte(i + 3)
return 4
end
end
function utf8.len(s)
local pos = 1
local bytes = string.len(s)
local len = 0
while pos <= bytes and len ~= chars do
local c = string.byte(s,pos)
len = len + 1
pos = pos + utf8.charbytes(s, pos)
end
if chars ~= nil then
return pos - 1
end
return len
end
print(utf8.len("Аутизм")) --6
local mt = {__len = function(self)
local k=0
for _,v in pairs(self) do
k = k+1;
if k > 1 then print(1) return #self end
end
if k==1 and type(self[1])=="string" then
print(utf8.len(self[k]))
end
end};
setmetatable(_G,{
__index = function(self, key) return setmetatable({key},mt) end}
)
t=(#Аутизм) --12
Чот пытался - но словил хуйца.
+2
for ($j = 0; $j < rand(2, 5); $j++) {
// тут какой-то другой код
}
На каждой новой итерации rand() пересчитывается, т.е. цикл сам не знает от нуля до скольки он будет
0
<table class="table table-hover" id="tab2">
<tr>
<th>Штрихкод </th>
<th>Имя покупателя</th>
<th>Штук</th>
</tr>
</table>
Код ajax
<script>
$(document).ready(function() {
$.ajax({
type: "POST",
url: 'ajax.php',
data : 'task=tab2',
dataType: "html",
success: function(response) {
$('#tab2').append(response)
}
});
});
</script>
file/ajax.php
* вызов списка клиентов ws_purchase*/
if ($ar_clean['task'] === "tab2") { echo "string";
$getServices = mysqli_query($db,"
SELECT *`
FROM ws_purchase ");
while($Service = mysqli_fetch_assoc($getServices)) {
?>
<tr >
<td><?=$Service['id_purchase'] ?></td>
<td><?=$Service['other_barcode'] ?></td>
<td><?=$Service['username'] ?></td>
</tr>
<?}
}
Привет, я тут вызываю таблицу из бд mysql через ajax что бы при добавление ново и записью не обновить страницу,
данные с бд приходе но при добавление новои записи нужно обновить страницу.
Что не так?
*Я не сселён в ajax
+2
switch (field.type) {
case 'checkbox':
case 'notification':
if (field.type == 'notification') {
fieldData.element.addClass('field-notification');
$('<span class="notification-button" data-action="notification">').text('Принять').appendTo(body).on(
'click', function () {
_class.wrapper.removeClass('notification');
_class.notification.wrapper.removeClass('notification-active');
_class.fields[index - 1].changeStatus();
$Mediator.fire({
name: 'active:filter',
target: _class.fields[0].filter
});
});
}
break;
}
Вдруг SWITCH не сработал)
+25189
Обратил внимание, что сток превратился в обычное обсуждение в чате.
Все читают всех, оффтопят, и похер в каком треде. А также когда я проверяю новые сообщения, хожу в телеграм, потом на хуз.
Поэтому создал бота в телеге, который фактически повторяет функционал стока + можно оставлять комменты (конечно же они будут от guest8).
По-моему получилось охуенно.
http://t.me/GovnokodBot
- посылаются посты и комменты
- работает отправка и редактирование
- если кто-то постит ссылку на картинку или youtube, телега автоматически отображает превью - удобно
- нужно использовать bbcode
- markdown -> bbcode - в TODO
−2
SELECT country, QTY, MIN(launched)
FROM (SELECT country, launched, COUNT(name) QTY
FROM Classes c JOIN
Ships s ON c.class = s.class
GROUP BY country,launched
HAVING COUNT(name) = (SELECT MAX(qty)
FROM (SELECT country,launched,COUNT(name) qty
FROM Classes c1 JOIN
Ships s1 ON c1.class = s1.class
WHERE country = c.country
GROUP BY country,launched
)e
)
)T
GROUP BY t.qty, t.country;
-2 sql ex rating
я так понял необходимо ещё как-то добавить проверку на NULL?
−1
select Outcomes.ship,count(*)
from Outcomes
where outcomes.result!='sunk'
group by ship
HAVING count(*)>=2
union
select ships.name,count(*)
from ships
where ships.launched!=NULL
group by name
HAVING count(*)>=2
-9 sql ex...
неверно на тренировочной
коммент :
парсить имя на '%NAME%' ? или как ?
−1
select distinct pass_in_trip.trip_no, (pass_in_trip.trip_no/5+pass_in_trip.trip_no/25+pass_in_trip.trip_no/125+pass_in_trip.trip_no/625+pass_in_trip.trip_no/3125+pass_in_trip.trip_no/15625+pass_in_trip.trip_no/78125)
from pass_in_trip
union
select distinct trip.trip_no, (trip.trip_no/5+trip.trip_no/25+trip.trip_no/125+trip.trip_no/625+trip.trip_no/3125+trip.trip_no/15625+trip.trip_no/78125)
from Trip
-12 рейтинговое sql ex... на тренировочной что-то не так...
наверно что-то связанное с NULL ?
добавить проверку ?
0
select model,(CAST(substring(model, 1, 1) as int)+CAST(substring(model, 2, 1) as int)+CAST(substring(model, 3, 1) as int)+CAST(substring(model, 4, 1) as int)) as qty
from product
where
(substring(model, 1, 1) like '0' or substring(model, 1, 1) like '1' or substring(model, 1, 1) like '2'
or substring(model, 1, 1) like '3' or substring(model, 1, 1) like '4' or substring(model, 1, 1) like '5'
or substring(model, 1, 1) like '6' or substring(model, 1, 1) like '7' or substring(model, 1, 1) like '8'
or substring(model, 1, 1) like '9')
AND (substring(model, 2, 1) like '0' or substring(model, 2, 1) like '1' or substring(model, 2, 1) like '2'
or substring(model, 2, 1) like '3' or substring(model, 2, 1) like '4' or substring(model, 2, 1) like '5'
or substring(model, 2, 1) like '6' or substring(model, 2, 1) like '7' or substring(model, 2, 1) like '8'
or substring(model, 2, 1) like '9')
AND (substring(model, 3, 1) like '0' or substring(model, 3, 1) like '1' or substring(model, 3, 1) like '2'
or substring(model, 3, 1) like '3' or substring(model, 3, 1) like '4' or substring(model, 3, 1) like '5'
or substring(model, 3, 1) like '6' or substring(model, 3, 1) like '7' or substring(model, 3, 1) like '8'
or substring(model, 3, 1) like '9')
AND (substring(model, 4, 1) like '0' or substring(model, 4, 1) like '1' or substring(model, 4, 1) like '2'
or substring(model, 4, 1) like '3' or substring(model, 4, 1) like '4' or substring(model, 4, 1) like '5'
or substring(model, 4, 1) like '6' or substring(model, 4, 1) like '7' or substring(model, 4, 1) like '8'
or substring(model, 4, 1) like '9')
select model,
ASCII(SUBSTRING(model,1,1))+
ASCII(SUBSTRING(model,2,1))+
ASCII(SUBSTRING(model,3,1))+
ASCII(SUBSTRING(model,4,1))
-48*4 as qty from Product
тоже не помогло.
sql ex рейтинговое 4. показывает что на тренировочной что-то не правильно.
лайк же вроде проверяет '1' как цифру а не как строку.
любые хинты как тут