- 1
- 2
foreach($keys as $key)
$settings[$type][$fieldname][$key] = (isset($fl[$type] [$fieldname] ['widget'] [$key] ) ) ? $fl[$type] [$fieldname] ['widget'] [$key] : '';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+34
foreach($keys as $key)
$settings[$type][$fieldname][$key] = (isset($fl[$type] [$fieldname] ['widget'] [$key] ) ) ? $fl[$type] [$fieldname] ['widget'] [$key] : '';
вобля
+145
/********************************************************************************
** Form generated from reading UI file 'qrselector.ui'
**
** Created: Thu 6. Jan 14:25:49 2011
** by: Qt User Interface Compiler version 4.7.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_QRSELECTOR_H
#define UI_QRSELECTOR_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_QRSelector
{
public:
QLabel *label;
void setupUi(QWidget *QRSelector)
{
if (QRSelector->objectName().isEmpty())
QRSelector->setObjectName(QString::fromUtf8("QRSelector"));
QRSelector->resize(400, 300);
label = new QLabel(QRSelector);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(10, 10, 371, 16));
retranslateUi(QRSelector);
QMetaObject::connectSlotsByName(QRSelector);
} // setupUi
void retranslateUi(QWidget *QRSelector)
{
QRSelector->setWindowTitle(QApplication::translate("QRSelector", "QRSelector", 0, QApplication::UnicodeUTF8));
label->setText(QString());
} // retranslateUi
};
namespace Ui {
class QRSelector: public Ui_QRSelector {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_QRSELECTOR_H
ui_qrselector.h
+112
public static class EntryPoint
{
private class NotFoundException : ApplicationException
{
public FoundException(int id, SourceType type)
private SourceType Type { get; set; }
private int Id { get; set; }
}
private class InProgressException : ApplicationException
{
public InProgressException(int id, SourceType type)
{
Type = type;
Id = id;
}
private UserViewSourceType Type { get; set; }
private int Id { get; set; }
}
public static void Analyze(SourceType type, IEnumerable<int> dataId)
{
try
{
initialize(type, dataId);
}
catch (InProgressException)
{
// немного говнокода
}
catch (NotFoundException)
{
// немного говнокода
}
}
Для того что бы внутри статического класса между двумя процедурами наладить связь (Analyze - initilize) человек определил два новых типа exceptions (private) и дал им дополнительные свойства которые нигде не используются. Exceptions эти больше нигде кроме initialize не кидаются и нигде кроме Analyze не ловятся. Ну и initialize больше ниоткуда кроме Analyze не вызывается.
В итоге имеем два лишних класса и тучу кода который можно без помех удалить, чем я собственно и занимаюсь :)
+125
m_PRICEURL = m_PRICEURL.Replace("{0}", "2010");
Новый Год принёс не только подарки, но и коллекцию говнокода вроде такого
+166
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result),", Unique ID - \"",$result[Key($result)],"\"</PRE>\n";
Замена foreach в индусском коде.
+157
function get_file_info($glob, $freq = 0)
{
static $cache = array();
if (isset($cache[$glob])) {
return $cache[$glob];
} else {
$ret = new stdClass;
$g = glob($glob);
$test = trim(`ls $glob`);
$g = split( "\n", $test );
if (!is_array($g)) {
return $ret;
}
$g = array_reverse($g);
$ret->files = array();
$now = time();
$first = true;
foreach($g as $filename) {
$f = new stdClass;
$f->name = $filename;
$f->size = @filesize($f->name);
$f->size_str = sprintf("%.1f",$f->size/1024/1024);
if (preg_match("((\\d{12}))", $f->name, $m)) {
$t = strtotime($m[1]);
$f->time = $t;
$f->time_str = str_replace(" ", " ", date("M d, Y H:i T", $f->time));
if ($freq) {
$to = $t + $freq - $now;
if ($to < 0) {
if ($to > -600) {
$res = '<em>any moment now.</em>';
} else {
$res = '<em>please consult /dev/urandom</em>';
}
} else {
$h = floor($to/3600);
$m = floor(($to - $h * 3600) / 60);
if ($h) {
$res = $h . ' hour'.($h==1?'':'s').' and ' . $m . ' minute'.($m==1?'':'s');
} else {
$res = $m . ' minute'.($m==1?'':'s');
}
}
$f->next = $res;
}
}
$ret->files[] = $f;
}
return $ret;
}
}
Говнокод на сайте php.net :)
Исходник: http://snaps.php.net/?source
P.S. это еще цветочки, после обеда будет зачетный с http://www.php.net/source.php?url=/index.php
+121
int finda(string[] strl, string a)
{
int ii=0;
foreach(var i in strl)
{
if(a==i)
return ii;
ii++;//Тут нужно оптимизировать!!!
};
}
+145
ДЕТСКОЕ ПОРНО МАЛЬЧИКИ ДЕВОЧКИ ЦЕЛКИ КЛУБНИЧКИ МАЛЕНЬКИЕ СИСЬКИ УПРУГИЕ ПОПКИ
+99
Procedure MakeChain(x: real; var a: array of word); (* Процедура раскладывает вещественное число в цепную дробь *)
var
i: byte;
begin
i:=0;
Repeat
a[i]:=Int(x); x:=1/(x-a[i]); i:=i+1
Until (abs(1/x) < epsilon) or (Int(x) = 0) (* NB! *)
end;
Procedure MakeFrac(a: array of word; var AN, BN: word); (* Процедура собирает обыкновенную дробь из цепной дроби *)
var
i: byte; AP, BP: word; temp: word;
begin
AN:=1; AP:=0; BN:=a[1]; BP:=1; i:=2;
Repeat
temp:=AN; AN:=AN*a[i]+AP; AP:=temp;
temp:=BN; BN:=BN*a[i]+BP; BP:=temp;
i:=i+1
Until a[i] = 0 (* NB! *)
end;
Function PowerInt(x: real; p: longint): real; (* возведение числа в целую степень *)
var
R: real;
begin
R:=1; if p<0 then x:=1/x; p:=abs(p);
Repeat
if p and 1 = 1 then R:=R*x;
p:=p shr 1;
if p<>0 then x:=sqr(x)
Until p=0;
PowerInt:=R
end;
Function Power(x: real; p: real): real;
var
y: real;
z: array[0..16000 div sizeof(word)] of word;
a, b: word;
begin
y:=PowerInt(x, Trunc(p)) * exp(Frac(p) * ln(abs(x)));
if x<0 then
begin
MakeChain(Frac(p), z);
MakeFrac(z, a, b);
if Odd(b) then
begin
if Odd(a) then y:=-y (* если числитель и знаменатель показателя степени нечётные, меняем знак результата *)
end
else
begin
(* NB! В случае чётного знаменателя показателя степени результат комплексный. Забьём на это *)
end
end;
Power:=y
end;
Инновационный алгоритм, написанный мной лет 12 тому назад, позволяющий возводить отрицательные числа в дробную степень.
Жанру сайта вполне соответствует, то есть не без говнокода.
+80
/**
* произвольные группы районов
*/
public enum DistrictGroup {
/*...*/
public int getOrdinal() {
for (int i = 0; i < values().length; i++) {
if (this == values()[i]) {
return i;
}
}
throw new Error("no ordinal found"); // never can be
}
}
Вот так пишут выпускники ВМК МГУ.