- 1
- 2
- 3
- 4
- 5
- 6
n = 0
for i in range(n):
pass
print i
NameError: name 'i' is not defined
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−146
n = 0
for i in range(n):
pass
print i
NameError: name 'i' is not defined
+9
template<...many params...>
class Foo
{
template <typename T>
class __Bar
{
T t;
public :
__Bar(T t) : t(t) {}
};
public :
template <typename T>
__Bar<T> Bar(T t)
{
return __Bar<T>(t); // просто __Bar(t) нельзя, вывод не сработает
}
template <typename T>
void Buzz (T t)
{
}
};
...
Foo f;
f.Buzz(Bar(5));
А как вы выкручиваетесь из неумения определять тип результата по типу параметров конструктора?
−139
>> # HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A')
>> $content =~ s/(?<!%0D)%0A/%0D%0A/g if defined($content);
HTTP::Request::Common 6.04, строка 86
http://cpansearch.perl.org/src/GAAS/HTTP-Message-6.04/lib/HTTP/Request/Common.pm
Оно просто берёт и изменяет передаваемый контент. Любой. В том числе просто бинарные данные.
+32
// *.h
class MyClass {
public:
MyClass ();
~MyClass ();
// ..etc
};
// *.cpp
#include "*.h"
MyClass *mycl;
MyClass::MyClass ()
{
mycl=this; // эту строчку не удалять без нее не работает, точнее не всегда работает иногда сбоит
}
MyClass::~MyClass ()
{
}
Простите меня пожалуйста. Я уныл чуть мене чем полностью, но почему человек которые это написал хороший программист. Это писал не я. Извините пожалуйста за беспокойство :( ..
+170
<?
if (!$_SESSION['signed_id_user'] || $_SESSION['signed_id_group'] != 1) {
$pagetitle = 'Необходима авторизация';
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<div align=\"center\" style=\"width: 400px;\">\n";
$pagecontent .= "<form action=\"login.php\" method=\"post\">\n";
$pagecontent .= "<fieldset class=\"bw\">\n";
$pagecontent .= " <legend class=\"bw\">авторизация пользователя</legend>\n";
$pagecontent .= " <p>Поля, помеченные <span class=\"required\">*</span> являются обязательными для заполнения</p>\n";
$pagecontent .= " <table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"300\" align=\"center\">\n";
$pagecontent .= " <tr>\n";
$pagecontent .= " <td width=\"160\" align=\"right\">имя пользователя:</td>\n";
$pagecontent .= " <td width=\"120\"><input type=\"text\" size=\"20\" class=\"baseinput\" name=\"username\" id=\"username\" /></td>\n";
$pagecontent .= " <td><div id=\"msgUsername\" class=\"required\">*</div></td>\n";
$pagecontent .= " </tr>\n";
$pagecontent .= " <tr>\n";
$pagecontent .= " <td width=\"160\" align=\"right\">пароль:</td>\n";
$pagecontent .= " <td width=\"120\"><input type=\"password\" size=\"20\" class=\"baseinput\" name=\"password\" id=\"password\" /></td>\n";
$pagecontent .= " <td><div id=\"msgPassword\" class=\"required\">*</div></td>\n";
$pagecontent .= " </tr>\n";
$pagecontent .= " <tr>\n";
$pagecontent .= " <td width=\"160\"> </td>\n";
$pagecontent .= " <td width=\"120\"><input type=\"submit\" class=\"button\" name=\"posted\" value=\"Войти\" /></td>\n";
$pagecontent .= " <td> </td>\n";
$pagecontent .= " </tr>\n";
$pagecontent .= " </table>\n";
$pagecontent .= "</fieldset>\n";
$pagecontent .= "</form>\n";
$pagecontent .= "</div>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$pagecontent .= "<p> <p>\n";
$tpl = new Template();
$tpl->set_file('tpl/e-con_bw.tpl');
$tpl->add_var('PAGETITLE', $pagetitle);
$tpl->add_var('PAGECONTENT', $pagecontent);
echo $tpl->output();
$tpl = NULL;
exit();
}
?>
Подскажите, пожалуйста, нахер с таким стилем кодинга вообще шаблонизатор надо?..
+148
int getGKnumber()
{
return 7000;
}
просто гет :)
+163
substr_count(strtolower(php_uname()),'windows') ? ';' : ':')
NetCat, такой NetCat. О существовании PATH_SEPARATOR даже и не знали.
+164
void Attr::setConvertedValue(std::string pValue)
{
/* ............. - BEGIN - Place the HTML code instead of the */
/* plain values. This is needed since special XML characters */
/* might exist. */
for(int i = 0; i < pValue.length(); i++)
{
int ascii = (int)pValue[i];
if(!( (ascii == 32 ) ||
(ascii >= 48 && ascii <= 57) ||
(ascii >= 65 && ascii <= 90) ||
(ascii >= 97 && ascii <= 122) ) )
{
if( ascii < 0 )
ascii += 256;
std::ostringstream stream;
stream << ascii;
std::string newString = stream.str();
newString = "&#" + newString + ';';
pValue.replace(i, 1, newString);
i += newString.length() - 1;
}
}
/* ............. - END - Place the HTML code instead of the */
/* plain values. This is needed since special XML characters */
/* might exist. */
mConvertedValue = pValue;
}
я стою на асфальте, ноги в лыжы абуты.
мы эскайпим значения для ХМЛ.
вы тут посмейтесь, а я пошел головой об стенку стучатся.
ЗЫ пысано в Бразилии.
−160
function midVal(X, Y)
{
return (Math.max(X, Y) - Math.min(X, Y)) / 2 + Math.min(X, Y);
}
Это среднее арифметическое один один чел так считает.
Взято отсюда: http://www.gamedev.ru/flame/forum/?id=137879&page=4#m47
Тема сама по себе весёлая.
0
const int sum(int a, int b){
return a+b;
}
int a(int x)
{
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
return sum4(123);
}
int b(int x)
{
puts("bagor");
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
return sum4(123);
}
int c(int x)
{
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
puts("bagor");
return sum4(123);
}
// Функции a и b нормально инлайнятся. Ассемблерный выхлоп:
sum(int, int): # @sum(int, int)
lea eax, [rdi + rsi]
ret
a(int): # @a(int)
mov eax, 127
ret
b(int): # @b(int)
push rax
mov edi, offset .L.str
call puts
mov eax, 127
pop rcx
ret
//А вот int c(int x)
c(int): # @c(int)
push rbx
sub rsp, 32
mov edi, 16
call operator new(unsigned long)
mov rbx, rax
mov qword ptr [rax], offset sum(int, int)
mov dword ptr [rax + 8], 4
mov qword ptr [rsp], rax
mov qword ptr [rsp + 24], offset std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&)
mov qword ptr [rsp + 16], offset std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
mov edi, offset .L.str
call puts
mov esi, dword ptr [rbx + 8]
mov edi, 123
call qword ptr [rbx]
mov ebx, eax
mov rax, qword ptr [rsp + 16]
test rax, rax
je .LBB3_3
mov rdi, rsp
mov rsi, rdi
mov edx, 3
call rax
.LBB3_3:
mov eax, ebx
add rsp, 32
pop rbx
ret
mov rdi, rax
call __clang_call_terminate
mov rbx, rax
mov rax, qword ptr [rsp + 16]
test rax, rax
je .LBB3_6
mov rdi, rsp
mov rsi, rdi
mov edx, 3
call rax
.LBB3_6:
mov rdi, rbx
call _Unwind_Resume@PLT
mov rdi, rax
call __clang_call_terminate
__clang_call_terminate: # @__clang_call_terminate
push rax
call __cxa_begin_catch
call std::terminate()
std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&): # @std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&)
mov rax, qword ptr [rdi]
mov rcx, qword ptr [rax]
mov edi, dword ptr [rsi]
mov esi, dword ptr [rax + 8]
jmp rcx # TAILCALL
std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation): # @std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
Решил попробовать std::bind.
https://godbolt.org/z/eW5eT5oj4