- 1
https://www.youtube.com/watch?v=UcO6OXVZGyI
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
https://www.youtube.com/watch?v=UcO6OXVZGyI
Можно промотать в конец.
0
#include <iostream>
#include <memory>
#include <thread>
#include <chrono>
#include <mutex>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
// Note: non-virtual destructor is OK here
~Base() { std::cout << " Base::~Base()\n"; }
};
struct Derived: public Base
{
Derived() { std::cout << " Derived::Derived()\n"; }
~Derived() { std::cout << " Derived::~Derived()\n"; }
};
void thr(std::shared_ptr<Base> p)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::shared_ptr<Base> lp = p; // thread-safe, even though the
// shared use_count is incremented
{
static std::mutex io_mutex;
std::lock_guard<std::mutex> lk(io_mutex);
std::cout << "local pointer in a thread:\n"
<< " lp.get() = " << lp.get()
<< ", lp.use_count() = " << lp.use_count() << '\n';
}
}
int main()
{
std::shared_ptr<Base> p = std::make_shared<Derived>();
std::cout << "Created a shared Derived (as a pointer to Base)\n"
<< " p.get() = " << p.get()
<< ", p.use_count() = " << p.use_count() << '\n';
std::thread t1(thr, p), t2(thr, p), t3(thr, p);
p.reset(); // release ownership from main
std::cout << "Shared ownership between 3 threads and released\n"
<< "ownership from main:\n"
<< " p.get() = " << p.get()
<< ", p.use_count() = " << p.use_count() << '\n';
t1.join(); t2.join(); t3.join();
std::cout << "All threads completed, the last one deleted Derived\n";
}
https://en.cppreference.com/w/cpp/memory/shared_ptr
Объясните почему "reset" не грохнул инстанс в других потоках?
−1
https://habr.com/company/medgadgets/blog/418871/
−1
#include <stdio.h>
#include <inttypes.h>
int main(void) {
uint64_t a = 1<<31;
uint64_t b = 1<<32;
uint64_t c = (uint64_t)1<<32;
printf("a:%llx\n", a);
printf("b:%llx\n", b);
printf("c:%llx\n", c);
return 0;
}
a:ffffffff80000000
b:0
c:100000000
Занимался битоёбством и не сразу понял откуда в алгоритме мусор.
+1
...
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
...
.bashrc по умолчанию в Xubuntu.
Мне казалось, что приглашение должно быть другого цвета, чтобы можно было быстро найти начало вывода программы:
user@computer:~$ cat blah.txt
<много текста>
<много текста>
<много текста>
<много текста>
<много текста>
Но тут, понимаешь, решили, что нечего цвета разводить.
−2
Продолжение банкета
Челлендж: НОРМАЛЬНЫЙ человек должен собрать с помощью docker PHP 5.3 с его требованиями к древним и automake, и autoconf, и bison и запустить сие существо вместе с Apache2 и MySQL.
Сакральный смысл челленджа в том, чтобы в здравом уме начать, в здравом уме окончить.
0
/**
Константа
*/
private static let dateFormat = "dd.MM.yy_HH.mm.ss"
Комментарий от бога.
+5
function ехал(f) { f(); }
function через(f) { f.call(null); }
function видит(f) { setTimeout(f, 0); }
function сунул(f) { Promise.resolve(null).then(f); }
function в(f) { alert("Hello functional world!"); return f; }
ехал(function() {
через(function() {
видит(function() {
(function(_function) {
сунул(function() {
_function(в(function() {}))
})
})(function(_function() {
_function(function() {})
})
})
})
})
+1
github.com/php/php-src/commit/0e097f2c96ce31b16fa371981045f224e5a37160#diff-e0dff85f21e939e4e2a778bddb8a72d7R819
Кто мне объяснит, как вообще работает этот PHP до сих пор, если они через строчку получают длину строки siezof'ом и при этом это ещё помогло исправить баг?
0
...
([dictionary stringObjectForKey:@"scale"].length > 0) ? (_scale = [dictionary stringObjectForKey:@"scale"]) : (_scale = @"1");
...
Инициализация переменной с помощью тернарной операции.