- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
sub exdef {
my ($hash, $key) = @_;
if (exists $hash->{$key} && defined $hash->{$key}) {
return 1;
}
return 0;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−103
sub exdef {
my ($hash, $key) = @_;
if (exists $hash->{$key} && defined $hash->{$key}) {
return 1;
}
return 0;
}
No comments.
BTW.
http://perldoc.perl.org/functions/exists.html
http://perldoc.perl.org/functions/defined.html
+16
try
{
Application->Initialize();
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
Найдено в проекте написанном на Borland C++Builder :)
+103
if (s[n][c]='1')and(s[n][c+1]='0')and(s[n+1][c]='0')and(n=1)and(c=1) then writeln('*');
if (s[n][c]='1')and(s[n][c-1]='0')and(s[n+1][c]='0')and(s[n][c+1]='0')and(n=1) then writeln('*');
if (s[n][c]='1')and(s[n][c-1]='0')and(s[n+1][c]='0')and(n=1)and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n-1][c]='0')and(s[n][c-1]='0')and(s[n+1][c]='0')and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n-1][c]='0')and(s[n][c-1]='0')and(n=10)and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n][c+1]='0')and(s[n-1][c]='0')and(s[n][c-1]='0')and(n=10) then writeln('*');
if (s[n][c]='1')and(s[n][c+1]='0')and(s[n-1][c]='0')and(n=10)and(c=1) then writeln('*');
if (s[n][c]='1')and(s[n+1][c]='0')and(s[n][c+1]='0')and(s[n-1][c]='0')and(c=1) then writeln('*');
if (s[n][c]='1')and(s[n][c+1]='.')and(s[n+1][c]='.')and(n=1)and(c=1) then writeln('*');
if (s[n][c]='1')and(s[n][c-1]='.')and(s[n+1][c]='.')and(s[n][c+1]='.')and(n=1) then writeln('*');
if (s[n][c]='1')and(s[n][c-1]='.')and(s[n+1][c]='.')and(n=1)and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n-1][c]='.')and(s[n][c-1]='.')and(s[n+1][c]='.')and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n-1][c]='.')and(s[n][c-1]='.')and(n=10)and(c=10) then writeln('*');
if (s[n][c]='1')and(s[n][c+1]='.')and(s[n-1][c]='.')and(s[n][c-1]='.')and(n=10) then writeln('*');
if (s[n][c]='1')and(s[n][c+1]='.')and(s[n-1][c]='.')and(n=10)and(c=1) then writeln('*');
if (s[n][c]='1')and(s[n+1][c]='.')and(s[n][c+1]='.')and(s[n-1][c]='.')and(c=1) then writeln('*');
Конец решения первой задачи все из той же дистанционки.
На этот раз мопед не мой, а одной юной дамы.
Вот за ЭТО я и недолюбливаю Паскаль: иногда код хер прочитаешь. А еще путаница с типами. И логикой. Гы.
+155
$content="{$_POST["From"]} - {$_POST["To"]}: {$_POST["DepartureDate"]},{$_POST["ArrivalDate"]}; {$_POST["date_type"]}";
$content=str_replace("'","",$content);
if(!mysql_num_rows(mysql_query("select id from table where sess_id='$sess_id' AND aff_id='$aff_id' AND operation_id='$operation_id' AND `content`='$content'"))>0){
}
+131
<li>1</li><!--
--><li>2</li><!--
--><li>3</li><!--
--><li>4</li>
http://forum.htmlbook.ru/index.php?showtopic=20109
+135
public bool IsSupportServerVersion()
{
if (this._connMaster.State == ConnectionState.Closed)
this._connMaster.Open();
if (int.Parse(((object) this._connMaster.ServerVersion.Split(new char[1]
{
'.'
})[0]).ToString()) >= 9)
{
if (int.Parse(((object) this._connMaster.ServerVersion.Split(new char[1]
{
'.'
})[0]).ToString()) <= 10)
return true;
}
return false;
}
Проверка версии MSSQL. На фоне того, что писателями заявлена работа с 2005, смотрится особенно хорошо.
+155
function showList($mod, $tab_name, $data)
{
?>
<TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
<TR>
<?
// Заголовки столбцов
foreach ($tab_name as $key=>$value)
{
echo '<TH class="first_row_left_td">'.$value.'</TH>';
}
?>
<TH colspan=2 class="first_row_left_td">Функции</TH>
</TR>
<?
// Строки таблицы
$i = 0;
foreach ($data as $v)
{
?>
<TR>
<?
$i+=1;
$cl = (($i % 2) == 0) ? "row2" : "row1";
foreach ($tab_name as $key=>$value)
{
if ($key == 'destination')
{
switch ($v[$key])
{
case '1': $d = '<FONT COLOR="#009900">Опубликовано</FONT>'; break;
case '-1': $d = '<FONT COLOR="#0000FF">В проверке</FONT>'; break;
case '0': $d = '<FONT COLOR="#FF0000">Отклонено</FONT>'; break;
}
echo '<TD class="'.$cl.'">'.$d.'</TD>';
continue;
}
echo '<TD class="'.$cl.'" >'.$v[$key].'</TD>';
}
?>
<TD align="center" class="<?=$cl?>"><A HREF="admin.php?mod=<?=$mod?>&op=edit&id=<?=$v['id']?>">Редактировать</A></TD>
<TD align=center class="<?=$cl?>"><A HREF="Javascript: if (confirm ('Вы уверены?')) window.location.href='admin.php?mod=<?=$mod?>&op=delete&id=<?=$v['id']?>'" onmouseout=" window.status=''" onmouseover=" window.status='Удалить'; return true;" title="Удалить">Удалить</A></TD>
</TR>
<?
}
?>
</TABLE>
<?
}
Зато с комментариями!
+152
<?php
session_start();
if (empty($_SESSION['login']) or empty($_SESSION['session_id'])) {
$DATA = array('login' => $_POST['login'], 'password' => $_POST['password']);
include "classes/data_base_class.php";
$auth_result = DataBase::StartAuth($DATA['login'], $DATA['password']);
if ($auth_result == 1) {
echo '<meta http-equiv="refresh" content="0;URL=../error.php?mod=auth">';
exit();
}
else
{
$_SESSION['login'] = $auth_result['user_login'];
$_SESSION['user_name'] = $auth_result['user_name'];
$_SESSION['session_id'] = $auth_result['reg_data'];
echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
exit();
}
}
else
{
echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
exit();
}
?>
Вот вам авторизация, ага - ага!
+13
bool[] Inmask;
....
private void discreteOIForm_Load(object sender, EventArgs e)
{
if (icpI_measure.Connect() && icpO_measure.Connect())
{
Inmask = new bool[1];
Inmask[Convert.ToInt32(0)] = true;
}
}
Новоприбывший сотрудник откладывает вот такое. Это он сделал после совета использовать маски. Вы когда-нибудь видели массив из одного элемента? Я тоже нет.
+136
// Было
string postCode;
if (person != null)
{
if (HasMedicalRecord(person) && person.Address != null)
{
CheckAddress(person.Address);
if (person.Address.PostCode != null)
postCode = person.Address.PostCode.ToString();
else
postCode = "UNKNOWN";
}
}
// Стало
string postCode = this.With(x => person)
.If(x => HasMedicalRecord(x))]
.With(x => x.Address)
.Do(x => CheckAddress(x))
.With(x => x.PostCode)
.Return(x => x.ToString(), "UNKNOWN");
"как можно использовать более “монадический” синтаксис в C# для того, чтобы __повысить удобочитаемость__ исходного кода"
http://www.gotdotnet.ru/blogs/nesteruk/6975/