- 1
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−106
neTyxu BCẺ
расиянцам приготовиться к параду суевернитетов
−1
//"вирус" в стиле кулхацкеров
#include <stdlib.h>
int main() {
int i = 1;
while( i == 1) {
system("start calc");
}
return 0;
}
+1
#include <iostream>
#include <functional>
#include <array>
#include <iterator>
template <class T>
class Filter : public std::iterator<
std::input_iterator_tag,
typename std::iterator_traits<T>::value_type,
typename std::iterator_traits<T>::difference_type,
typename std::iterator_traits<T>::pointer,
typename std::iterator_traits<T>::reference
>
{
private:
typedef typename std::iterator_traits<T>::value_type value_type;
std::function<bool(value_type)> m_predicate;
T m_begin, m_end;
value_type m_current;
public:
Filter(T t_begin, T t_end, std::function<bool(value_type)> t_predicate)
: m_begin(t_begin), m_end(t_end), m_predicate(t_predicate)
{
}
Filter<T>& begin()
{
return ++*this;
}
Filter<T>& end()
{
return *this;
}
value_type operator* ()
{
return m_current;
}
Filter<T>& operator++ ()
{
do {
m_current = *m_begin;
++m_begin;
} while (m_begin != m_end && !m_predicate(m_current));
return *this;
}
bool operator!= (Filter<T>& t_right)
{
return m_begin != t_right.m_end;
}
};
int main()
{
std::array<int, 10> arr{ {4, 35, 0, 23, 0, 0, 5} };
for (auto i : Filter<typename std::array<int,10>::iterator>(arr.begin(), arr.end(), [](int x){return x != 0;})) {
std::cout << i << " ";
}
}
−99
Прошу забанить всех на один год.
админа - бессрочно.
+1
ДеФфЧоНаЧкИ с ПрАзДнИчКоМ вАс!
Всем джвумерным, трёхмерным и прочим N-мерным няшкам с клювом и без шлю чмоки-чмоки!
+3
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
enum {
HOST = INADDR_LOOPBACK,
PORT = 6666,
MAX_BUF = 1024
};
struct sock {
int sockfd;
int addrlen;
struct sockaddr_in addr;
} host, client;
int check(int x, char*msg)
{
if (!~x) {
perror(msg);
exit(1);
}
return x;
}
#define QUOTE_(...) #__VA_ARGS__
#define QUOTE(...) QUOTE_(__VA_ARGS__)
#define CHECK(...) check(__VA_ARGS__, QUOTE(line __LINE__: __VA_ARGS__))
int main(int argc, char**argv)
{
struct sock host, client;
host.sockfd = CHECK(socket(AF_INET, SOCK_STREAM, 0)),
host.addr = (struct sockaddr_in){AF_INET, htons(PORT), htonl(HOST)};
CHECK(bind(host.sockfd, &(struct sockaddr)host.addr, sizeof(host.addr)));
CHECK(listen(host.sockfd, 1));
CHECK(client.sockfd = accept(host.sockfd, (void*)&client.addr, &client.addrlen));
printf("connected: %s\n", inet_ntoa(client.addr.sin_addr));
struct {int len; char buf[MAX_BUF];} msg;
while (CHECK(msg.len = recv(client.sockfd, msg.buf, MAX_BUF - 1, 0)) && msg.len) {
msg.buf[msg.len] = 0;
printf("%s", msg.buf);
send(client.sockfd, msg.buf, msg.len, 0);
}
close(client.sockfd);
close(host.sockfd);
return 0;
}
Почему если закоментить 36-ю строчку адрес килента 0.0.0.0?
+1
source.setPropertyValue("phone", "фон");
Фон
0
// https://habr.com/company/JetBrains/blog/249479/
Привет, Хабр!
Некоторое время назад мы объявили конкурс — требовалось продолжить фразу:
Бьёрн Страуструп создал С++ 36 лет назад, и он до сих пор востребован и пользуется популярностью у разработчиков, потому что...
Спасибо всем участникам за массу положительных эмоций и разнообразные предположения о том, что же сделало C++ таким популярным.
Посовещавшись, мы выбрали топ-6 ответов:
0
public static function Exception($message, $info = []) {
ob_clean();
?>
<!-- Пичалька какая-то произошла! Мы в грустяшке и огорчульке. -->
<center>
<div style="width: 600px; height: 140px; border: 1px #DDDDDD solid;">
<img style="width: 134px; margin: 14px; float: left;" src="/images/error-big.png">
<div style="display: table-cell; vertical-align: middle; height: 155px;">
<h4>
<?= $message; ?>
</h4>
</div>
</div>
</center>
<?
exit();
}
Днище-кодинг.
+8
constexpr auto auto()
{
return 1;
}
typedef decltype(auto()) auto;
const auto auto = auto();
template <typename auto>
constexpr auto auto() {
return auto;
}
template <typename auto, typename auto, typename... auto>
constexpr auto auto() {
return auto + auto<auto, auto...>();
}
int main()
{
constexpr auto auto = auto<auto,auto,auto,auto,auto,auto>();
constexpr auto auto = auto<auto,auto,auto,auto,auto,auto,auto>();
return auto*auto;
}
auto auto auto...
https://twitter.com/RichardKogelnig/status/943497972481953792
https://godbolt.org/g/Yvczo1