- 1
- 2
- 3
- 4
- 5
SELECT *
FROM TRANSACTION
WHERE status = 'in-check'
AND created >= '2021-11-17 12:40'
AND created <= '2021-11-17 01:10';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
SELECT *
FROM TRANSACTION
WHERE status = 'in-check'
AND created >= '2021-11-17 12:40'
AND created <= '2021-11-17 01:10';
Когда очень полюбили 12-часовой формат
0
// https://github.com/dxFeed/dxfeed-c-api/blob/8f24055298c9751344db72da03ab8eb37dfeb6a5/src/DXAlgorithms.h#L63
#define CHECKED_CALL(func, param) \
do { \
if (!func(param)) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_0(func) \
do { \
if (!func()) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_1(func, param1) \
do { \
if (!func(param1)) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_2(func, param1, param2) \
do { \
if (!func(param1, param2)) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_3(func, param1, param2, param3) \
do { \
if (!func(param1, param2, param3)) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_4(func, param1, param2, param3, param4) \
do { \
if (!func(param1, param2, param3, param4)) { \
return false; \
} \
} while (false)
#define CHECKED_CALL_5(func, param1, param2, param3, param4, param5) \
do { \
if (!func(param1, param2, param3, param4, param5)) { \
return false; \
} \
} while (false)
Мокроебства
−1
for (k = k + 0, j = 0; j < m; j++)
{
b[k] = mat[i][j];
cout << b[k];
}
Увидел в лабе у чела из универа. Почему бы лишний раз не присвоить k собственное значение
+3
INSERT INTO Receipt VALUES ('2', '01.06.2020',
(SELECT ProdPrice FROM Products WHERE ProdID=2),
(((SELECT ProdPrice FROM Products WHERE ProdID=2)*20)/100),
(SELECT ProdPrice FROM Products WHERE ProdID=2)+(((SELECT ProdPrice FROM Products WHERE ProdID=2)*20)/100), '1');
ого
Кровь из глаз. Четыре подзапроса вместо одного, да ещё и имена колонок для вставки не указаны.
Я уже молчу про то, как считается НДС.
0
// больше говнокодить не могу. сайт не дает мне писать коменты.
// на последок говнокод
const adapter = await navigator.gpu.requestAdapter();
const device = this.device = await adapter.requestDevice();
if (!device) {
document.body.className = 'error';
alert("No WebGPU");
return;
}
const computeShaderSource = document.getElementById("calculate").value;
const computePipeline = device.createComputePipeline({
compute: {
module: device.createShaderModule({
code: computeShaderSource,
}),
entryPoint: 'main',
},
});
просто говнокод. больше говнокодить не могу. сайт не дает мне писать коменты.
+1
struct file_id
{
uint64_t persistent;
uint64_t volatile_;
static const size_t RAW_LENGTH = 16;
operator std::string() const
{ return std::string(reinterpret_cast<const char*>(&persistent), RAW_LENGTH); }
// Операторы для использования file_id в качестве ключа map и
// unordered_map
struct hash
{
std::size_t operator()(const ntdec_smb2_file_id& file_id) const
{
std::string s_file_id = file_id;
std::hash<std::string> hasher;
return hasher(s_file_id);
}
};
bool operator == (const ntdec_smb2_file_id& other)
{
return std::string(*this) == std::string(other);
}
bool operator < (const ntdec_smb2_file_id& other)
{
return std::string(*this) < std::string(other);
}
bool operator > (const ntdec_smb2_file_id& other)
{
return std::string(*this) > std::string(other);
}
};
operator std::string тоже UB?
+1
Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages
Parameter for function...
+1
INTERRUPT_TABLE section:
00> FF FF | . .
02> 9F 00 | . .
DATA section:
32> 48 65 6C 6C 6F 20 77 6F | Hello.wo
3A> 72 6C 64 21 00 00 00 00 | rld . . . . .
42> 00 00 00 00 00 00 00 00 | . . . . . . . .
4A> 00 00 00 00 00 00 00 00 | . . . . . . . .
_START section:
8F> 9B 00 32 00 PUSH 32
93> 18 00 00 00 INT 0
97> 18 00 01 00 INT 1
9B> 94 40 01 00 ADD %B 1
EXIT interrupt:
9F> 81 40 16 E8 MOV %B E816
A3> 20 00 00 00 RET
RUNFLOW:
8F> 9B 00 32 00 PUSH 32
93> 18 00 00 00 INT 0 DEBUG OUTPUT: Hello world!
97> 18 00 01 00 INT 1
9F> 81 40 16 E8 MOV %B E816
A3> 20 00 00 00 RET
9B> 94 40 01 00 ADD %B 1
HALT SEQUENCE REACHED: 0xE817
Закодил свою виртуальную машину и ассемблер под неё.
Заспидранил Hello world за неделю.
https://pastebin.com/NmLEuGMU
0
class MediaWiki {
// Поля, другие методы
private function performRequest() {
global $wgTitle;
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ( $request->getVal( 'printable' ) === 'yes' ) {
$output->setPrintable();
}
$this->getHookRunner()->onBeforeInitialize( $title, null, $output, $user, $request, $this );
// Invalid titles. T23776: The interwikis must redirect even if the page name is empty.
if ( $title === null || ( $title->getDBkey() == '' && !$title->isExternal() )
|| $title->isSpecial( 'Badtitle' )
) {
$this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
try {
$this->parseTitle();
} catch ( MalformedTitleException $ex ) {
throw new BadTitleError( $ex );
}
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permissionStatus = PermissionStatus::newEmpty();
if ( !$this->context->getAuthority()->authorizeRead( 'read', $title, $permissionStatus ) ) {
// T34276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor( 'Badtitle' );
$this->context->setTitle( $badTitle );
$wgTitle = $badTitle;
throw new PermissionsError( 'read', $permissionStatus );
}
// Еще какая-то логика для хандлинга редиректов по заголовкам страниц
}
// ...
}
// ...
class MessageCache implements LoggerAwareInterface {
// ...
public function parse( $text, $title = null, $linestart = true,
$interface = false, $language = null
) {
global $wgTitle;
if ( $this->mInParser ) {
return htmlspecialchars( $text );
}
$parser = $this->getParser();
$popts = $this->getParserOptions();
$popts->setInterfaceMessage( $interface );
if ( is_string( $language ) ) {
$language = $this->langFactory->getLanguage( $language );
}
$popts->setTargetLanguage( $language );
if ( !$title || !$title instanceof Title ) {
$logger = LoggerFactory::getInstance( 'GlobalTitleFail' );
$logger->info(
__METHOD__ . ' called with no title set.',
[ 'exception' => new Exception ]
);
$title = $wgTitle;
}
// Sometimes $wgTitle isn't set either...
if ( !$title ) {
# It's not uncommon having a null $wgTitle in scripts. See r80898
# Create a ghost title in such case
$title = Title::makeTitle( NS_SPECIAL, 'Badtitle/title not set in ' . __METHOD__ );
}
$this->mInParser = true;
$res = $parser->parse( $text, $title, $popts, $linestart );
$this->mInParser = false;
return $res;
} // ...
}
Зачем в методах класса вообще использовать глобальные изменяемые состояния, если это нарушает принцип инкапсуляции (для обеспечения чего и была введена абстракция класса в языки)? И сидишь гадаешь, при вызове какого метода у какого объекта у тебя слетела верстка, контент и пр. Это усложняет написание безопасных расширений для системы.
+1
$query = "
SELECT
`version`, `mods`, `plugins`, `keywords`
WHERE
`version` = {$version}";
foreach (explode(",", $mods) as $mod)
{
$query += "AND `mods` LIKE '{$mod}' OR `mods` LIKE '{$mod},%' OR `mods` LIKE '%,{$mod},%' OR `mods` LIKE '%,{$mod}'";
}
foreach (explode(",", $plugins) as $plugin)
{
$query += "AND `plugins` LIKE '{$plugin}' OR `plugins` LIKE '{$plugin},%' OR `plugins` LIKE '%,{$plugin},%' OR `plugins` LIKE '%,{$plugin}'";
}
Говнокод чтобы прогнать массив с id записей внутри varchar по массиву с id записей из переменной (id,id,id)