- 1
- 2
- 3
- 4
- 5
for (k = k + 0, j = 0; j < m; j++)
{
b[k] = mat[i][j];
cout << b[k];
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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)
0
#include <stdio.h>
#include <string.h>
double emit_fmadd(double a, double b, double c) __attribute ((noinline));
double emit_fmadd(double a, double b, double c)
{
return a*b+c;
}
int main(void)
{
double a = 10.0000;
double b = 1.00001;
double c = 1.001;
double res = emit_fmadd(a,b,c);
unsigned char arr[sizeof(res)];
memcpy(arr, &res, sizeof(res));
for (int i = 0; i < sizeof(res); i++)
{
printf("%.2x ", arr[i]);
}
printf("\n");
}
/*
gcc -O3 -march=skylake
emit_fmadd:
vfmadd132sd xmm0, xmm2, xmm1
ret
gcc -O3 -march=x86-64
emit_fmadd:
mulsd xmm0, xmm1
addsd xmm0, xmm2
ret
*/
Вот к чему плавучий питух приводит!
https://godbolt.org/z/sP19zP
0
function check_cur_zak(id_zak, obj)
{
obj.getElementsByTagName('img')[0].style.display='none';
obj.getElementsByTagName('img')[1].style.display='block';
var ch_ids_tree_dse = arr2_ids_dse[id_zak].split('|');
var ch_names_tree_dse = arr2_names_dse[id_zak].split('|');
var ch_obozs_tree_dse = arr2_obozs_dse[id_zak].split('|');
var ch_child_tree_dse = arr2_child_dse[id_zak].split('|');
var cur_tree_dse = '';
if(document.getElementById('nav_tekysh_3').name>0)
{
console.log(arr_oprs_c_r_2)
var spl_op_res = arr_oprs_c_r_2[document.getElementById('nav_tekysh_3').name].split('|');
var spl_op_res_arr = [];
for (var spl_f_ar=0; spl_f_ar<spl_op_res.length; spl_f_ar++)
spl_op_res_arr[spl_op_res[spl_f_ar]] = spl_op_res[spl_f_ar];
}
for (var ch_t_f_d=0; ch_t_f_d < (ch_ids_tree_dse.length-1); ch_t_f_d++)
{
var cur_tree_oper_cur_dse = '';
var jv3_arr_full_tbl_1_spl = jv2_arr_full_tbl_1_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_2_spl = jv2_arr_full_tbl_2_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_3_spl = jv2_arr_full_tbl_3_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_4_spl = jv2_arr_full_tbl_4_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_5_spl = jv2_arr_full_tbl_5_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_5_1_spl = jv2_arr_full_tbl_5_1_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_6_spl = jv2_arr_full_tbl_6_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_7_spl = jv2_arr_full_tbl_7_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_8_spl = jv2_arr_full_tbl_8_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_9_spl = jv2_arr_full_tbl_9_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_10_spl = jv2_arr_full_tbl_10_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_11_spl = jv2_arr_full_tbl_11_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_12_spl = jv2_arr_full_tbl_12_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_14_spl = jv2_arr_full_tbl_14_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_15_spl = jv2_arr_full_tbl_15_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var jv3_arr_full_tbl_16_spl = jv2_arr_full_tbl_16_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
jv3_arr_full_tbl_17_spl = jv2_arr_full_tbl_17_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
jv3_arr_full_tbl_18_spl = jv2_arr_full_tbl_18_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
jv3_arr_full_tbl_19_spl = jv2_arr_full_tbl_19_spl[ch_ids_tree_dse[ch_t_f_d]].split('|');
var cur_dse_op_dse = '';
var cur_id_op_dse = '';
var cur_vp_op_dse = '';
for (var ch_t_f_o=0; ch_t_f_o < (jv3_arr_full_tbl_1_spl.length-1); ch_t_f_o++)
{
var clas_tr_col = 'fff';
var clas_tr_br = 'fff';
var clas_tr_pr = 'fff';
var clas_tr_park = 'fff';
var zadel_op = 0;
var stl_b_tr_pr = '';
var js_vp_op = '0<br>0.00';
var js_ksz_op = '0<br>0.00';
// if (jv3_arr_full_tbl_14_spl[ch_t_f_o]>0)
// {
// clas_tr_col='ddffdd';
// clas_tr_br='ddffdd';
// clas_tr_pr='ddffdd';
// clas_tr_park='ddffdd';
// }
if(document.getElementById('nav_tekysh_3').name>0)
{
if (spl_op_res_arr[jv3_arr_full_tbl_16_spl[ch_t_f_o]])
{
clas_tr_pr='99ff99';
stl_b_tr_pr = 'font-size:150%; color:#13BD13;padding-left:5px';
}
var parks_for_cur_res = document.getElementById('park_sel_cur_res').options.length;
for (var p_f_c_r=0; p_f_c_r<parks_for_cur_res; p_f_c_r++)
{
if ((document.getElementById('park_sel_cur_res').options[p_f_c_r].value !== '0')&&(document.getElementById('park_sel_cur_res').options[p_f_c_r].value !== ''))
{
if (jv3_arr_full_tbl_5_1_spl[ch_t_f_o]==document.getElementById('park_sel_cur_res').options[p_f_c_r].value)
clas_tr_park='99ddff';
}
}
}
if (jv3_arr_full_tbl_12_spl[ch_t_f_o]==1)
clas_tr_br='ff9999';
if (jv3_arr_full_tbl_15_spl[ch_t_f_o]==0)
{
if(jv3_arr_full_tbl_3_spl[ch_t_f_o]=='')
jv3_arr_full_tbl_3_spl[ch_t_f_o]='0';
if(jv3_arr_full_tbl_6_spl[ch_t_f_o]=='')
jv3_arr_full_tbl_6_spl[ch_t_f_o]='0.00';
if(jv3_arr_full_tbl_7_spl[ch_t_f_o]=='')
jv3_arr_full_tbl_7_spl[ch_t_f_o]='0';
if(jv3_arr_full_tbl_8_spl[ch_t_f_o]=='')