- 1
(format t "~A~%" (*) )
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
(format t "~A~%" (*) )
https://ideone.com/oO7f4I
+2
https://codeforwin.org/2018/05/10-cool-bitwise-operator-hacks-and-tricks.html
10 cool bitwise operator hacks and tricks every programmer must know
Right shift (>>) operator is equivalent to division by 2
Want to divide a number by 2 quicky. Here you go, use bitwise right shift operator to divide an integer by 2. Each right shift operation reduces the number (operand) to its half.
Просто напомню, что Jawa-петушки вручную заменяют деление/умножение на 2 на сдвиг, потому что анскильный компилятор так не умеет.
+3
for (size_t i = 0; i < 4; ++i) {
__m128 x0 = _mm_loadu_ps((const float*)blocks[0] + i * 4);
__m128 x1 = _mm_loadu_ps((const float*)blocks[1] + i * 4);
__m128 x2 = _mm_loadu_ps((const float*)blocks[2] + i * 4);
__m128 x3 = _mm_loadu_ps((const float*)blocks[3] + i * 4);
__m128 t0 = _mm_unpacklo_ps(x0, x1);
__m128 t1 = _mm_unpackhi_ps(x0, x1);
__m128 t2 = _mm_unpacklo_ps(x2, x3);
__m128 t3 = _mm_unpackhi_ps(x2, x3);
x[i * 4 + 0] = _mm_castps_si128(_mm_movelh_ps(t0, t2));
x[i * 4 + 1] = _mm_castps_si128(_mm_movehl_ps(t2, t0));
x[i * 4 + 2] = _mm_castps_si128(_mm_movelh_ps(t1, t3));
x[i * 4 + 3] = _mm_castps_si128(_mm_movehl_ps(t3, t1));
}
4х MD5
https://ideone.com/a8YcZ8
0
IT Оффтоп #114
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
#97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
#98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
#99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
#100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
#101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
#102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
#103: https://govnokod.ru/27526 https://govnokod.xyz/_27526
#104: https://govnokod.ru/27534 https://govnokod.xyz/_27534
#105: https://govnokod.ru/27544 https://govnokod.xyz/_27544
#106: https://govnokod.ru/27552 https://govnokod.xyz/_27552
#107: https://govnokod.ru/27554 https://govnokod.xyz/_27554
#108: https://govnokod.ru/27557 https://govnokod.xyz/_27557
#109: https://govnokod.ru/27581 https://govnokod.xyz/_27581
#110: https://govnokod.ru/27610 https://govnokod.xyz/_27610
#111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
#112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
#113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
0
public function StartDataCache($TTL=false, $uniq_str=false, $initdir=false, $vars=Array(), $basedir = "cache")
{
$narg = func_num_args();
if($narg<=0)
return $this->cache->startDataCache();
if($narg<=1)
return $this->cache->startDataCache($TTL);
if($narg<=2)
return $this->cache->startDataCache($TTL, $uniq_str);
if($narg<=3)
return $this->cache->startDataCache($TTL, $uniq_str, $initdir);
return $this->cache->startDataCache($TTL, $uniq_str, $initdir, $vars, $basedir);
}
+1
$bIsExpressDelivery = !empty($arDeliveryTariff["UF_EXPRESS_DELIVERY"]) ? true : false;
Чтобы наверняка true или наверняка false...
0
function main()
{
print("before");
try
{
throw 1;
}
catch (x: any)
{
print("catch");
}
print("end");
}
Самый большей говнокод за всю историю человечества сделан.
−1
Если у меня есть приватный метод, то зачем мне его объявлять в .h-файле?
Хочу только в .cpp написать вспомогательный метод и только там его использовать.
А вынужден копипастить сигнатуру ещё и в .h.
0
/**
* Возвращает сумму прописью
* @param $num
* @return string
*/
public static function num2str($num) {
$nul='ноль';
$ten=[
['','один','два','три','четыре','пять','шесть','семь', 'восемь','девять'],
['','одна','две','три','четыре','пять','шесть','семь', 'восемь','девять'],
];
$a20=['десять','одиннадцать','двенадцать','тринадцать','четырнадцать' ,'пятнадцать','шестнадцать','семнадцать','восемнадцать','девятнадцать'];
$tens=[2=>'двадцать','тридцать','сорок','пятьдесят','шестьдесят','семьдесят' ,'восемьдесят','девяносто'];
$hundred=['','сто','двести','триста','четыреста','пятьсот','шестьсот', 'семьсот','восемьсот','девятьсот'];
$unit=[ // Units
['копейка' ,'копейки' ,'копеек', 1],
['рубль' ,'рубля' ,'рублей' ,0],
['тысяча' ,'тысячи' ,'тысяч' ,1],
['миллион' ,'миллиона','миллионов' ,0],
['миллиард','милиарда','миллиардов',0],
];
//
list($rub,$kop) = explode('.',sprintf("%015.2f", floatval($num)));
$out = [];
if (intval($rub)>0) {
foreach(str_split($rub,3) as $uk=>$v) { // by 3 symbols
if (!intval($v)) continue;
$uk = sizeof($unit)-$uk-1; // unit key
$gender = $unit[$uk][3];
list($i1,$i2,$i3) = array_map('intval',str_split($v,1));
// mega-logic
$out[] = $hundred[$i1]; # 1xx-9xx
if ($i2>1) $out[]= $tens[$i2].' '.$ten[$gender][$i3]; # 20-99
else $out[]= $i2>0 ? $a20[$i3] : $ten[$gender][$i3]; # 10-19 | 1-9
// units without rub & kop
if ($uk>1) $out[]= self::morph($v,$unit[$uk][0],$unit[$uk][1],$unit[$uk][2]);
} //foreach
}
else $out[] = $nul;
$out[] = self::morph(intval($rub), $unit[1][0],$unit[1][1],$unit[1][2]); // rub
$out[] = $kop.' '.self::morph($kop,$unit[0][0],$unit[0][1],$unit[0][2]); // kop
return trim(preg_replace('/ {2,}/', ' ', join(' ',$out)));
}
Один большой проект...
0
function error {
printf "ERROR: $1\n" >&2
}
function warning {
printf "WARNING: $1\n"
}
function info {
printf "INFO: $1\n"
}
function println {
printf "$1\n"
}
function block {
printf "\n$3\n$1 \t[$2]\n$3\n"
}
function fail {
println "\n"
println "FAIL"$1
println
}
function checkz {
if [ -z $1 ]; then
error "empty string"
return 1
fi
info "string \"$1\" \t[OK]"
return 0
}
function checkx {
if [ ! -x $1 ]; then
error "$1 \t[NOT FOUND]"
return 1
fi
info "$1 \t[OK]"
return 0
}
function checkb {
if [ ! -b $1 ]; then
error "$1 \t[NOT FOUND]"
return 1
fi
info "$1 \t[OK]"
return 0
}
function checkc {
if [ ! -c $1 ]; then
error "$1 \t[NOT FOUND]"
return 1
fi
info "$1 \t[OK]"
return 0
}
function checkf {
if [ ! -f $1 ]; then
error "$1 \t[NOT FOUND]"
return 1
fi
info "$1 \t[OK]"
return 0
}
function checkd {
if [ ! -d $1 ]; then
error "$1 \t[NOT FOUND]"
return 1
fi
info "$1 \t[OK]"
return 0
}
function checkd_mk {
if [ ! -d $1 ]; then
info "$1 \t[NOT FOUND]"
info "$1 \t[MAKING...]"
mkdir -p $1
checkd $1
return $?
fi
info "$1 \t[OK]"
return 0
}
function sized {
sized=($(ls $1))
return ${#sized[@]}
}
Вспомогательные функции проверки файлов и директорий, а также вывода ошибок