- 1
- 2
- 3
- 4
http://rghost.ru/51035531
Новый бот для минусования (запускать на виртуалке)
Описание такое, чтобы отпугнуть хомячье.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+128
http://rghost.ru/51035531
Новый бот для минусования (запускать на виртуалке)
Описание такое, чтобы отпугнуть хомячье.
Новый бот для минусования.
+119
Well, there were other factors in play there. htmlspecialchars was a
very early function. Back when PHP had less than 100 functions and the
function hashing mechanism was strlen(). In order to get a nice hash
distribution of function names across the various function name lengths
names were picked specifically to make them fit into a specific length
bucket. This was circa late 1994 when PHP was a tool just for my own
personal use and I wasn't too worried about not being able to remember
the few function names.
-Rasmus
http://news.php.net/php.internals/70691
+166
if (substr(json_encode($row['list']), 0, 1) == '[') {
Такой вот аналог is_array()
−163
CREATE TABLE [dbo].[PPLS2BILLS_SRCO_MESAGE] (
[DOCUMENT] [char] (8) COLLATE Ukrainian_CI_AI_KS_WS NULL ,
[Nom_Document] [int] NULL ,
[Kol_Reis_In_Docum] [int] NULL ,
[Cancel_Kol_Reis_Doc] [int] NULL ,
[Greate_Date_Docum] [datetime] NULL ,
[Flag_Out_EC] [bit] NULL
) ON [PRIMARY]
именуй, не именуй ...
+149
if ($result->fetch()) {
return $result->get('num_flags');
}
else {
return 666;
}
Верующий программист :)
+141
if (connfailed) {
KSOCKET_CALLBACK(so, disconnected, error);
} else {
KSOCKET_CALLBACK(so, connectfailed, error);
}
https://github.com/joyent/illumos-joyent/blob/master/usr/src/uts/common/fs/sockfs/socknotify.c
+159
var lines = content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
// remove first and last tags
lines = lines.Skip(2).Take(lines.Count - 3).ToList(); // <------------ ОНО
for (var i = 0; i < lines.Count; i++)
{
// remove one indent from each line
lines[i] = lines[i].Substring(indentation, lines[i].Length - indentation);
}
Покоробило от такого подхода...
Я бы написал for от 1 до lines.Count-1 :)
+137
var romans = "I II III IV".Split(' ');
+10
#include <iostream>
#include <list>
#include <queue>
#include <memory>
#include <mutex>
#include <condition_variable>
#include <type_traits>
#include <assert.h>
using namespace std;
template<class Data>
class UnboundedQueueForNonThrowMovable
{
static_assert(std::is_nothrow_move_constructible<Data>::value, "Data must be nonthrow movable type.");
static_assert(!std::is_array<Data>::value, "Data must not be c-array.");
public:
typedef Data value_type;
private:
typedef std::queue<Data, std::list<Data>> Queue;
typedef std::unique_lock<std::mutex> Lock;
Queue _queue;
std::mutex _lockQueue;
std::condition_variable _pushToQueue;
UnboundedQueueForNonThrowMovable(const UnboundedQueueForNonThrowMovable&) = delete;
UnboundedQueueForNonThrowMovable(UnboundedQueueForNonThrowMovable&&) = delete;
UnboundedQueueForNonThrowMovable& operator=(const UnboundedQueueForNonThrowMovable&) = delete;
UnboundedQueueForNonThrowMovable& operator=(UnboundedQueueForNonThrowMovable&&) = delete;
public:
UnboundedQueueForNonThrowMovable(void){}
void push(Data&& data)
{
Lock lockerQueue(this->_lockQueue);
this->_queue.push(std::move(data));
this->_pushToQueue.notify_all();//_condition.notify_one(); most optimal, but can cause deadlock.
}
void push(Data& data)
{
this->push(std::move(data));
}
bool emptyUnstable(void) const
{
Lock lockerQueue(this->_lockQueue);
return this->_queue.empty();
}
Data pop(void)
{
Lock lockerQueue(this->_lockQueue);
this->_pushToQueue.wait(lockerQueue, [this](void){return !this->_queue.empty();});
assert(!this->_queue.empty());
Data result = std::move(this->_queue.front());
this->_queue.pop();
return result;
}
template< class Rep, class Period>
Data pop(const std::chrono::duration<Rep, Period> WaitDuration)
{
Lock lockerQueue(this->_lockQueue);
if(!this->_pushToQueue.wait(lockerQueue, WaitDuration, [this](void){return !this->_queue.empty();}))
return Data();
assert(!this->_queue.empty());
Data result = std::move(this->_queue.front());
this->_queue.pop();
return result;
}
};
template<class Data>
using UnboundedQueueForUniquePtr = UnboundedQueueForNonThrowMovable<std::unique_ptr<Data>>;
template<class Data>
using UnboundedQueueForSharedPtr = UnboundedQueueForNonThrowMovable<std::shared_ptr<const Data>>;
template<class Data>
using UnboundedQueue = UnboundedQueueForUniquePtr<Data>;
int main() {
cout<<"ok"<<endl;
{
//UnboundedQueueForSharedPtr<int>::value_type == std::shared_ptr<const int>
UnboundedQueueForSharedPtr<int> queueSharedPtr;
//auto a = std::make_shared<const int>(45);
auto a = std::make_shared<int>(45);
assert(a);
queueSharedPtr.push(a);
assert(!a);//Fired if you use "auto a = std::make_shared<int>(45)" below. It is compiler bug, I think, because previus code line must cause compile error.
auto b = queueSharedPtr.pop();//std::shared_ptr<const int>
assert(b);
cout<<*b<<endl;
assert(*b==45);
http://ideone.com/qdsWJi
Немного глупый вопрос, почему в 90 строчке не получаем ошибку компиляции если закомментировать 87-ую строку и разкомментировать 88-ую?
+161
//надо показать элемент каталога во всей красе
$_CENTER="show_category_item(".$newParts[0].");";
eval($_CENTER);
// ...
$_LEFT='get_main_category($cat_id, $new_path);';
$_CENTER="show_category_item_list($".'newParts'.");";
Вот с таким адом мне приходится работать.