- 1
- 2
- 3
- 4
- 5
- 6
- 7
MyType(const CopyPastedFromSomewhere&) = delete;
MyType& operator=(const CopyPastedFromSomewhere&) = delete;
MyType& operator=(const MyType*) = delete;
// Winner?
MyType& MyType(const MyType&) = delete;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
MyType(const CopyPastedFromSomewhere&) = delete;
MyType& operator=(const CopyPastedFromSomewhere&) = delete;
MyType& operator=(const MyType*) = delete;
// Winner?
MyType& MyType(const MyType&) = delete;
А что можно найти в вашей кодовой базе? К слову, выяснилось, что вариант
void operator=(const MyType&) = delete;
вполне себе допустим.
0
Посанеы, помогите как поднять БД по Уфе
https://shamarc.biz/buy/389?method=qiwi&anonym=1
Да, я наркоман, Онал-Пертрал, помоги
За последние 8 лет, ни разу не писал, только постилГК, помогите.
−1
try {
String sDate = new SimpleDateFormat("MM/dd/yyyy").format(new SimpleDateFormat("dd.MM.yyyy").parse(dayOfMonth + "." + (monthOfYear + 1) + "." + year));
dueDate.setText(sDate);
} catch (ParseException e) {
e.printStackTrace();
}
Красивое (и безопасное) решение проблем с разными форматами дат
−2
$scope.storage.oldDriver = JSON.parse(JSON.stringify($scope.storage.driverEdit || {})); // @TODO: ни _.clone ни Object.assign не сработали
Нашел на работе в коде
0
You have three options in Javascript:
//slice
//syntax: string.slice(start [, stop])
"Good news, everyone!".slice(5,9); // extracts 'news'
//substring
//syntax: string.substring(start [, stop])
"Good news, everyone!".substring(5,9); // extracts 'news'
//substr
//syntax: string.substr(start [, length])
"Good news, everyone!".substr(5,4); // extracts 'news'
Как извлечь подстроку в JavaScript.
0
#include <xmmintrin.h>
void crasher() {
constexpr __m128 w = {1,2,3,4};
asm ("addps %[w], %[w]" : : [w] ""(w));
}
Крашим GCC
https://ideone.com/iIAN0i
0
class PriceCache {
public:
FlightStorage(const std::size_t count) {
for (std::size_t i = 0; i < count; ++i) {
flights.emplace_back(FlightCache::get(i));
prices.emplace_back(&flights.back(), Price::getFor(flights.back()));
}
}
private:
std::vector<Flight> flights;
std::vector<const Flight *, double> prices;
};
"случайные сегфолты при обращении к PriceCache::prices"
+2
typedef unsigned int uint;
uint inc(uint i) {
return i+1;
}
uint dec(uint i) {
return i-1;
}
uint add(uint a, uint b) {
return 0==b ? a : add(inc(a),dec(b));
}
inline uint _mul(uint a, uint b, uint r) {
return 0==b ? r : _mul(a,b-1,r+a);
}
uint mul(uint a, uint b) {
return _mul(a,b,0);
}
uint dec_mul(uint a, uint b, uint r) {
return 0==b ? r : dec_mul(a,dec(b),r+a);
}
//gcc 7 здесь сходит с ума на O3, шланг невозмутимо ставит imul edi, esi
uint crazy_mul(uint a, uint b, uint r) {
return 0==b ? r : crazy_mul(a,dec(b),add(r,a));
}
//арифметическая прогрессия.
inline uint _sum(uint a,uint s) {
return a==0 ? s :_sum(a-1,s+a);
}
//gcc: сложна нипанятна
uint sum(uint a) {
return _sum(a,0);
}
//шланг:
// imul rcx, rax
// shr rcx
uint sum1(uint a) {
uint s=0;
for (int i=0;i<a;++i){
s+=i;
}
return s;
}
Смотрим как компиляторы решают разные упоротые рекурентные задачки.
https://godbolt.org/g/4JZuPr
0
<?php
$zero = '!![]';
$nums = ['![]','${![]}','${!![]}','$${[]}','$${![]}','$${!![]}','$$${[]}','${[].[]}'];
$initChr = "\${[]}=([].[])[![]+![]+![]];\${[]}++;\${[]}++;\${+![]}=\${[]};" .
"\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${+![]}.=\${[]};" .
"\${[]}=\${+![]}.([].[])[![]];";
$chr = '${[]}';
function initNumbers() {
global $nums;
$n = $nums[0];
$code = '';
foreach ($nums as $v => $num) {
if (!$v) continue;
$v = join('+', array_fill(0, 2, $n));
$code .= "$num=$v;";
$n = $num;
}
return $code;
}
function number($n) {
global $nums, $zero;
if ($n < 0 || $n > 255) die("Invalid number: $n.");
if (!$n) return $zero[0];
$i = 0;
while($n) {
$d = $n % 2;
if($d) $code[] = join('+', array_fill(0, $d, $nums[$i]));
$n /= 2;
$i++;
}
return join('+', $code);
}
function char($c) {
global $chr;
$c = number(ord($c));
return "$chr($c)";
}
function str($s) {
return join('.', array_map('char', str_split($s)));
}
function prettify($fucked) {
$line = '';
$ops = preg_split('/([;.])/', $fucked, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($ops as $op) {
if(strlen($line) + strlen($op) + 1 > 80) {
$lines[] = $line;
$line = '';
}
$line .= $op;
}
$lines[] = $line;
return join("\n", $lines);
}
function fuckify($code) {
global $chr, $initChr;
$nums = initNumbers();
$php = '$$$${[]}';
$initPHP = $php . '=(' . str('popen') . ')(' . str('php') . ',' . char('w') . ');';
$fputs = str('fputs');
$pclose = str('pclose');
$code = str($code);
return prettify("<?php\n$initChr$nums$initPHP($fputs)($php,$code);($pclose)($php);");
}
$code = '';
while ($line = fgets(STDIN)) $code .= $line;
print(fuckify($code));
Автаматизировала пхпфак почти как в http://govnokod.ru/23690
програма вводет код пхп из stdin и выводет в stdout его перивод на пхпфак
0
Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. We recommend that you keep the Pods directory under source control, and don't add it to your .gitignore
Benefits of checking in the Pods directory
After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.
https://guides.cocoapods.org/using/using-cocoapods.html