- 1
- 2
- 3
Открылся новый форум
https://gvforum.ru
Присоединяйтесь
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−3
Открылся новый форум
https://gvforum.ru
Присоединяйтесь
+1
onStart =: verb define
wd 'pc game15; pn 15; bin hv; bin h'
i =. 0
for_text. ":@>:0,~?~15 do.
name =. 'a', ":i
wd 'cc ', name , ' button; cn ', text
if. 3 = 4|i do.
wd 'bin z; bin h'
end.
wd 'set ', name, ' wh 80 80'
". 'game15_', name, '_button =: buttonclicked@]&', (":i)
i =. >:i
end.
wd 'set a15 text'
wd 'cc count static; cn 0'
count =: 0
wd 'bin z'
wd 'cc restart button; cn restart'
wd 'pshow'
empty =: 15
0$0
)
buttonclicked =: verb define
if. 1 = (+/)(**)(-/@:<.@:%&4 , -/@:|~&4) empty, y do.
wd 'set a', (":empty), ' text ', wd 'get a', (":y), ' text'
wd 'set a', (":y), ' text'
empty =: y
count =: >:count
wd 'set count text ', ":count
end.
)
game15_restart_button =: verb define
wd 'pclose'
wd 'activity base'
)
wd 'activity base'
Я осилил гуй в J! Урряяяя!
0
Ну и полный пример:
#include "stdafx.h"
#include "windows.h"
#include "iostream.h"
#include "process.h" // специально для потока
void fThredFunct1(void* pv); // декларация функции потока
__declspec(thread) DWORD dwTlsIndex; // локальная статическая функция для потока
void main()
{
ULONG hThread1 = 0; // Идентификатор потока 1
ULONG hThread2 = 0; // Идентификатор потока 2
//unsigned long _beginthread( void( __cdecl *start_address )( void * ),
// unsigned stack_size, void *arglist );
hThread1 = _beginthread(fThredFunct1,0,NULL); // создали первый поток
if (hThread1==-1)
cout << "Error create thread" << endl;
hThread2 = _beginthread(fThredFunct1,0,NULL); // создали второй поток
if (hThread1==-2)
cout << "Error create thread" << endl;
Sleep(2000); // ждем
}
void fThredFunct1(void* pv) // реализация функции потока
{
dwTlsIndex=TlsAlloc(); // Запросить индекс
if (dwTlsIndex==-1) // проверить на ошибку
{
cout << "Error TlsAlloc " << endl;
return;
}
cout << dwTlsIndex << endl;
Sleep(1000);
if ( TlsFree( dwTlsIndex)==0 ) // освободить индекс
{
cout << "Error TlsFree" << endl;
return;
}
}
Многопоточное говно
Гуглояндексится.
−1
restrictions = restrictions.filter(restriction =>
_.find(solution, item => (
(item.from === restriction.from) && (item.to === restriction.to)
))
).map(restriction => {
const solutionTransmission = _.find(
solution,
item => ((item.from === restriction.from) && (item.to === restriction.to))
);
if (solutionTransmission) {
return restriction;
}
return null;
}).filter(restriction => restriction);
+2
Pyhton 2:
>>> (2**54/1) + 10 - 10 == 2**54
True
>>> (2**64/1) + 10 == 2**64
False
Pyhton 3:
>>> (2**54/1) + 10 - 10 == 2**54
False
>>> (2**64/1) + 10 == 2**64
True
Pyhton 2: https://ideone.com/iqwl8L
Pyhton 3: https://ideone.com/ltG9Fq
Ну охуеть теперь.
x + 10 - 10 != x в общем случае - это норма?
Я всё понимаю - тяжёлое детство, инты, прибитые к железу, но на кой чёрт в современных интерпретируемых языках такое говнище?
+4
https://hi-tech.mail.ru/news/facebook-send-nudes/
"Facebook" тестирует систему распознавания фотографий пикантного содержания с их последующим
удалением, и в рамках тестирования умоляет пользователей отправить самим себе предметы боди-арта.
Так что можете наконец извлечь из смартфонов любовно разглядываемые холодными осенними вечерами
фотографии ваших анальных отверстий и пустить их на развитие искусственного интеллекта.
0
function string_cleaner($data, array $opts) //1: Массив или строка, 2: Только массив
{
if (empty($opts))
{
$opts['null_byte'] = TRUE;
}
$null_byte = ($opts['null_byte'] == 'off')
? FALSE
: TRUE;
$opts_allowed = ['trim', 'htmlspecialchars', 'strip_tags', 'addslashes', 'htmlentities'];
$opts = array_intersect_key($opts, array_flip($opts_allowed));
if(is_array($data))
{
foreach($data as $key => &$value)
{
if(is_array($value))
{
string_cleaner($value, $opts);
}
if ($null_byte)
{
$value = str_replace(chr(0), '', $value);
}
if(is_array($opts))
{
foreach($opts as $clear_func => $clear_func_params)
{
$value = (!$clear_func_params) ? $clear_func($value) : $clear_func($value, $clear_func_params);
}
}
}
}
else
{
if ($null_byte)
{
$data = str_replace(chr(0), '', $data);
}
if(is_array($opts))
{
foreach($opts as $clear_func => $clear_func_params)
{
$data = $value = (!$clear_func_params) ? $clear_func($data) : $clear_func($data, $clear_func_params);
}
}
}
return $data;
}
{...}
$server['get'] = string_cleaner($_GET, ['trim'=>' ', 'htmlentities'=>'', 'strip_tags'=>'', 'addslashes'=>'']);
Для сука ленивых
−3
А вы замечали, что пари предпросмотре поста выводится дата "01 Января 1970"?
0
// check that all selected vertices are one 3d vertex.
bool UsedIndex = 0;
bool IndexIsRegistered = false;
for (int t = 0; t < Indices.count(); t++)
{
zUVVertex Vertex = OldVerts->at(t);
if (!IndexIsRegistered)
{
IndexIsRegistered = true;
UsedIndex = Vertex.BaseVertexIndex;
}
else if (UsedIndex != OldVerts->at(t).BaseVertexIndex)
{
// quit on fail
return;
}
}
NewList = new QList<zUVVertex>();
zUVVertex NewVertex;
bool VertexIsInitialized = false;
bool CapIsHoled = false;
for (quint32 t = 0; t < OldVerts->count(); t++)
{
bool Taked = false;
for (quint32 j = 0; j < Indices.count(); j++)
{
if (OldVerts->at(t).index == Indices.at(j))
{
if (!VertexIsInitialized)
{
VertexIsInitialized = true;
NewVertex = OldVerts->at(t);
}
Taked = true;
NewVertex.IndicesBeforeWeld << t;
break;
}
}
if (!Taked)
{
(*NewList) << OldVerts->at(t);
}
else
{
zUVVertex Stub;
if (!CapIsHoled)
{
Stub = NewVertex;
}
else
{
Stub.Index = 0x7FFFFFFF;
}
(*NewList) << Stub;
}
}
(*NewList) << NewVertex;
Taked = false;
QList<zUVFace> *TempFacesList = new QList<zUVFace>();
for (int t = 0; t < Faces->count(); t++)
{
zUVFace Face = Faces->at(t);
zUVFace NewFace;
for (int j = 0; j < Face.VertsIndices; j++)
{
quint32 Index0 = Face.VertsIndices.at(j);
zUVVertex TestVertex = NewList->at(Index0);
if (TestVertex.Index == 0x7FFFFFFF)
{
// need to replace
NewFace = Faces->at(t);
NewFace.VertsIndices.operator [](j) = NewList->count() - 1;
Taked = true;
}
}
if (Taked)
{
(*TempFacesList) << NewFace;
}
}
http://www.gamedev.ru/code/forum/?id=216701
+1
auto getMaxSize = [](const auto &vec) {
if (vec.size() == 0)
return 0;
const auto &max = *std::max_element(
vec.begin(),
vec.end(),
[](const auto &lhs, const auto &rhs){
return lhs.size() < rhs.size();
});
return max.size();
};
Раньше я не понимал актуальность шутки:
In C++14, you just write auto auto(auto auto) { auto; } The compiler infers the rest from context