- 1
- 2
Это ATGC в заповеднике
https://pbs.twimg.com/media/DofuZTmWsAEWfxw.jpg
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−105
Это ATGC в заповеднике
https://pbs.twimg.com/media/DofuZTmWsAEWfxw.jpg
Я считаю, что после всех катастроф, которые обрушились на Россию в двадцатом веке, начиная с первой мировой и заканчивая перестройкой, тот факт, что Россия еще сохранилась и развивается, говорит, что у нашего народа имеется одна лишняя хромосома
0
function toUrl(url, key, value) {
if(url=='') url=window.location.href;
if(url.indexOf('//')<0) url='//'+url;
// protocol
var u=url.split(/\/?\//);
url={}; url.protocol=u.shift()+'//';
// hostname
url.hostname=u.shift().split(':');
if(url.hostname.length>1) url.port=':'+url.hostname.pop()
url.hostname=url.hostname.pop().split('@').pop();
// сохраним порядок для последующей свертки
url.pathname='/'; url.pagename='';
try {
// hash
url.search=u.pop().split(/#/);
if(url.search.length==2) url.sh='#'+url.search.pop();
url.search=url.search.shift().split(/\?/);
// pagename
url.pagename=url.search.shift(); url.search=url.search[0]
// pathname
url.pathname+=u.join('/')+(u.length?'/':'');
// разбор search, (c) Steven Benner, 2010
try {
var u = {};
url.search.replace(
new RegExp('([^?=&]+)(=([^&]*))?', 'g'),
function($0, $1, $2, $3) {
u[$1] = decodeURIComponent($3);
}
);
url.search=u;
} catch(e) {
delete url.search;
}
} catch(e) { };
// вернем URL как объект, где search так же
// представлен объектом {key:value}
if(!key && !value) return(url);
// возвращаем значение ключа
if(key && !value) return(url.search[key]);
// roll up url
var roll = function(url,search){
var out='';
for(var key in url) {
out+=(search?'&'+key+'=':'')+(key=='search'?'?'+roll(url[key],1).substr(1):url[key]);
};
return out;
};
// устанавливаем значение ключа
if(value) url.search[key]=value.toString();
// сворачиваемся, с учетом порядка следования свойств
return(roll(url));
}
// применение
console.log(toUrl('http://site.my:81/home/path/page.htm?a=1&b=2#hash','a',5));
https://habr.com/ru/sandbox/126206/
0
((ax + b)mod p) mod m
Какое вообще у этой хеш-функции название?
Я нашел только "Семейство универсальных хеш-функций"
−100
Я Stertor
0
void Obmen_RS1(void)
{
uint8_t txbuf[7], rxbuf[43], CheckSum;
//если сформирован запрос на чтение по RS1 - SSPC data
if (SoftFlag.RS_Flag3.bit.RS1_Read_Req)
{
txbuf[0] = 0x7B; //{
txbuf[1] = SSPC_Addr_RS[RS1_Counter];
txbuf[2] = 0x00; //d0, b00000000 - команда для формирования и отправки посылки данных от SSPC
txbuf[3] = 0x00;
txbuf[4] = 0x00;
txbuf[5] = txbuf[1];//(txbuf[1] ^ txbuf[2] ^ txbuf[3] ^ txbuf[4]); //xor [1..4]
txbuf[6] = 0x7D; //}
HAL_UART_Transmit(&huart1, (uint8_t *)&txbuf, 7, 1);
//HAL_Delay(1)
if (HAL_UART_Receive(&huart1, (uint8_t *)&rxbuf, 43, 9) == HAL_OK)
{ //если пришел правильный пакет
if ((rxbuf[0] == 0x5B)
&& (rxbuf[40] == SSPC_Addr_RS[RS1_Counter])
&& (rxbuf[42] == 0x5D))
{ //считаем КС
for (j = 1; j < 41; j++)
CheckSum ^= rxbuf[j];
if (CheckSum == rxbuf[41]) //Если КС совпадает
{
for (j = 1; j < 41; j++) //Сохраняем пакет в двумерный буфер
RS1_Paket[RS1_Counter][j] = rxbuf[j];
}
else
{
for (j = 1; j < 41; j++)
RS1_Paket[RS1_Counter][j] = 0; //Иначе пишем нули
}
}
}
RS1_Counter++;
if (RS1_Counter > 15)
RS1_Counter = 0;
SoftFlag.RS_Flag3.bit.RS1_Read_Req = 0; //сбрасываем флаг запроса чтения данных и ждем следующего по таймеру (100мс)
}
}
Процедура чтения данных от 16 модулей управления нагрузками по RS-485...
для STM32F4x с использованием калокуба
−2
<template>
<div class="side-effects">
<div class="side-effects__text" v-html="text"></div>
</div>
</template>
<script>
export default {
name: 'SideEffects',
data () {
return {
text: '<strong>JORNAY PM can cause serious side effects, including: </strong>' +
'<ul>' +
'<li>' +
'<strong>Abuse and dependence.</strong> JORNAY PM contains methylphenidate. JORNAY PM, other methylphenidate-containing products, and\n' +
'amphetamines have a high chance for abuse and can cause physical and psychological dependence. Your healthcare provider should check\n' +
'you or your child for signs of abuse and dependence before and during treatment with JORNAY PM.' +
'<ul>' +
'<li>Tell your healthcare provider if you or your child has ever abused or been dependent on alcohol, prescription medicines, or street\n' +
'drugs. </li>' +
'<li> Your healthcare provider can tell you more about the differences between physical and psychological dependence and drug addiction. </li>' +
'</ul>' +
'</li>' +
'<li>' +
'<p class="mb-0"><strong>Heart-related problems, including:</strong></p>' +
'<ul>' +
'<li>sudden death, stroke, and heart attack in adults</li>' +
'<li>sudden death in children who have heart problems or heart defects</li>' +
'<li> increased blood pressure and heart rate </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Your healthcare provider should check you or your child carefully for heart problems before starting JORNAY PM. Tell your healthcare provider\n' +
'if you or your child has any heart problems, heart defects, or high blood pressure.' +
' <p>Your healthcare provider should check your or your child’s blood pressure and heart rate regularly during treatment with JORNAY PM. </p>' +
'<p><strong>Call your healthcare provider right away or go to the nearest hospital emergency room right away if you or your child has any signs of\n' +
'heart problems such as chest pain, shortness of breath, or fainting during treatment with JORNAY PM. </strong></p>' +
'<ul>' +
'<li>' +
'<strong>Mental (psychiatric) problems, including:</strong>' +
'<ul>' +
'<li>new or worse behavior and thought problems</li>' +
'<li>new or worse bipolar illness</li>' +
'<li>new psychotic symptoms (such as hearing voices, or seeing or believing things that are not real) or new manic symptoms </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Tell your healthcare provider about any mental problems you or your child has, or about a family history of suicide, bipolar illness, or\n' +
'depression. ' +
'<p><strong>Call your healthcare provider right away if you or your child have any new or worsening mental symptoms or problems during treatment\n' +
'with JORNAY PM, especially hearing voices, seeing or believing things that are not real, or new manic symptoms</strong></p>' +
'<strong>JORNAY PM can cause other serious side effects, including:</strong>' +
'<ul>' +
'<li>See <strong>“What is the most important information I should know about JORNAY PM?” </strong></li>' +
'<li><strong>Painful and prolonged erections (priapism). </strong>Priapism has happened in males who take products that contain methylphenidate. If you or\n' +
'your child develops priapism, get medical help right away</li>' +
'<li>' +
'<strong>Circulation problems in fingers and toes (peripheral vasculopathy, including Raynaud’s phenomenon). Signs and symptoms may\n' +
'include:</strong>' +
'<ul>' +
'<li>fingers or toes may feel numb, cool, or painful</li>' +
'<li> fingers or toes may change color from pale, to blue, to red </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Tell your healthcare provider if you or your child has numbness, pain, skin color change, or sensitivity to temperature in the fingers or toes. ' +
'<strong>Call your healthcare provider right away if you or your child has any signs of unexplained wounds appearing on fingers or toes during\n' +
'treatment with JORNAY PM.</strong>' +
'<ul>' +
'<li>' +
'<strong>Slowing of growth (height and weight) in children</strong> Children should have their height and weight checked often during treatment with\n' +
'JORNAY PM. JORNAY PM treatment may be stopped if your child is not gaining weight or height. ' +
'</li>' +
'</ul>' +
'<strong>The most common side effects of methylphenidate products in children, adolescents, and adults with ADHD include:</strong>' +
'<ul>' +
'<li>decreased appetite</li>' +
'<li>stomach pain</li>' +
'<li>irritability</li>' +
'<li>trouble sleeping</li>' +
'<li>weight loss</li>' +
'<li>mood swings (affect lability)</li>' +
'<li>nausea</li>' +
'<li>anxiety</li>' +
'<li>increased heart rate</li>' +
'<li>vomiting</li>' +
'<li>dizziness</li>' +
'<li>increased blood pressure</li>' +
'<li>indigestion</li>' +
'</ul>' +
'<strorg>The most common side effects of JORNAY PM in children age 6 to 12 with ADHD include: </strorg>';
}
}
}
</script>
Так вот зачем нужна data и v-html (VueJS)
+1
namespace belugina
{
void Simple_Merging_Sort (char *name){
int a1, a2, k, i, j, kol, tmp;
FILE *f, *f1, *f2;
kol = 0;
if ( (f = fopen(name,"r")) == NULL )
printf("\nИсходный файл не может быть прочитан...");
else { while ( !feof(f) ) {
fscanf(f,"%d",&a1);
kol++;
}
fclose(f);
}
k = 1;
while ( k < kol ){
f = fopen(name,"r");
f1 = fopen("smsort_1","w");
f2 = fopen("smsort_2","w");
if ( !feof(f) ) fscanf(f,"%d",&a1);
while ( !feof(f) ){
for ( i = 0; i < k && !feof(f) ; i++ ){
fprintf(f1,"%d ",a1); fscanf(f,"%d",&a1); }
for ( j = 0; j < k && !feof(f) ; j++ ){
fprintf(f2,"%d ",a1); fscanf(f,"%d",&a1);}
}
fclose(f2); fclose(f1); fclose(f);
f = fopen(name,"w"); f1 = fopen("smsort_1","r");
f2 = fopen("smsort_2","r");
if ( !feof(f1) ) fscanf(f1,"%d",&a1);
if ( !feof(f2) ) fscanf(f2,"%d",&a2);
while ( !feof(f1) && !feof(f2) ){
i = 0; j = 0;
while ( i < k && j < k && !feof(f1) && !feof(f2) ) {
if ( a1 < a2 ) {
fprintf(f,"%d ",a1); fscanf(f1,"%d",&a1);i++;}
else {
fprintf(f,"%d ",a2);fscanf(f2,"%d",&a2); j++;}
}
while ( i < k && !feof(f1) ) {
fprintf(f,"%d ",a1); fscanf(f1,"%d",&a1); i++;}
while ( j < k && !feof(f2) ) {
fprintf(f,"%d ",a2); fscanf(f2,"%d",&a2); j++;}
}
while ( !feof(f1) ) {
fprintf(f,"%d ",a1); fscanf(f1,"%d",&a1); }
while ( !feof(f2) ) {
fprintf(f,"%d ",a2); fscanf(f2,"%d",&a2); }
fclose(f2); fclose(f1); fclose(f); k *= 2;
}
remove("smsort_1"); remove("smsort_2");
}
}
Вектор это не динамический массив.
+1
function managerLogin(){
... //Запрос для входа менеджера
cookie.set('MANAGERSESSID', response.MANAGERSESSID);
...
}
function userLogin(){
... //Запрос для входа пользователя
cookie.set('LKSESSID', response.LKSESSID);
...
}
Фронтендер решил что бэки слишком медленные и тупые и поэтому теперь он сам будет заниматься менеджментом сессии.
До этого был бэкер который тоже свои сесии изобретал, кое как починили.
Но теперь у нас вместо одной сессии две.
Теоретически их может быть больше.
Код написан на react с очень большим кол-ом native js.
Что посоветуете человеке?
0
// table for cart must have unique index for both columns for correct effect of this function
function save() {
if ($this->errno_ || !$this->db_link_)
return;
// optimized loop
$n = count($this->products_) - 1;
$s_query = "REPLACE INTO `". Config::DB_CART_TABLE_NAME ."` VALUES ";
for($i = 0; $i < $n; ++$i) {
$s_query .= "('". $this->phpsessid_ ."',". $this->products_[$i]->getId() .",". $this->counts_[$i] .",'". $this->sizes_[$i] ."')";
}
if ($n + 1)
$s_query .= "('". $this->phpsessid_ ."',". $this->products_[$n]->getId() .",". $this->counts_[$n] .",'". $this->sizes_[$n] ."')";
print($s_query);
$res = mysqli_query($this->db_link_, $s_query);
if (!$res)
$this->errno_ = IModel::E_DB_QUERY;
}
// Запрос сформирован некорректно, нету запятых между кортежами значений:/
// REPLACE INTO `cart` VALUES ('cbn1c7ljjd3gglb2lmpa96grnq3prq2iefb2elvcb4fhr9r0qls1',700,4,'')('cbn1c7ljjd3gglb2lmpa96grnq3prq2iefb2elvcb4fhr9r0qls1',701,2,'')
Опять мой говнокод.
И это как-то србатывало О_о
+1
foreach ($result->getDataCollection() as $data) {
if (!$data->getStatus() === Status::PAID)
continue;
// ACTIONS
}
Зачем использовать !== если есть ===
P/s
Смотрим на if (