- 1
- 2
- 3
- 4
- 5
- 6
enum Bool
{
True,
False,
FileNotFound
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+136
enum Bool
{
True,
False,
FileNotFound
};
Как оказывается Boolean может быть не только long, но и FileNotFound.
Нашел зде©ь http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx
+159
function key_exists_check($key,$ar)
{
if (empty($key))
$key = '0.001';
strval($key);
if (array_key_exists($key,$ar))
while (array_key_exists($key,$ar))
$key=strval(floatval($key)+0.001);
return strval($key);
}
Другого решения не вижу - задача при добавлении в массив - делать уникальные ключи, которые типа float.
+144
if if = then then
then = else;
else else = if;
Следующий фрагмент вполне допустим при программировании на PL/1, но написать такое может только идиот со справкой. "Совершенный код" (c)
+141
#define ass assert (false)
...
−131.6
SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER
JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id =
ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and
ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table
AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS
rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE
'002%' and ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM
com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN
payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id
WHERE ct.tax_id LIKE '001%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id,
rt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id
LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id =
ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name,
ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id =
ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt
ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '2' UNION SELECT ct.com_id,
cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS
cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN
tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '2' UNION SELECT
ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN
com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id
LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '3'
UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table AS ct LEFT
OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id =
ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and
ct.com_id = '3';
Не помню, что именно. Вырыл в старом логе. К сожалению из-за местных ограничений по длине кода не удалось выложить подобные портянки длинной в 10 тыщ символов.
+115.2
class TReadWrapper<TItemType>
{
public static object item(string ItemString)
{
if (typeof(TItemType) == typeof(double))
return Convert.ToDouble(ItemString);
TDbg.Assert(false);
return null;
}
};
class TRead<TItemType>
{
public static TItemType item(StreamReader BinaryStream)
{
string ItemString = BinaryStream.ReadLine();
if (ItemString == null)
throw new Exception();
return (TItemType)TReadWrapper<TItemType>.item(ItemString);
}
};
class TFileToList<TListItem> : List<TListItem>
{
public TFileToList(string FileName)
{
if(typeof(TListItem)==typeof(char))
{
StreamReader file = new StreamReader(FileName, Encoding.Unicode);
string FileData = file.ReadToEnd();
foreach (char item in FileData)
this.Add((TListItem)(object)item);
file.Close();
return;
};
StreamReader fileSource = new StreamReader(FileName, Encoding.Unicode);
try
{
for (;;)
this.Add(TRead<TListItem>.item(fileSource));
}
catch
{
};
fileSource.Close();
}
}
class TListToFile<TListItem>
{
static public void rewrite(string NameOfDestinationFile, List<TListItem> Source)
{
if(typeof(TListItem)==typeof(char))
{
StreamWriter file = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
foreach (TListItem item in Source)
file.Write(item);
file.Flush();
file.Close();
return;
};
StreamWriter fileDestination = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
foreach (TListItem item in Source)
fileDestination.WriteLine(Convert.ToString(item));
fileDestination.Flush();
fileDestination.Close();
}
}
+110
Function IsBigLet(Let: String): Boolean;
var r: bool;
begin
r:=false;
if pos('Й',Let)>0 then r:=true;
if pos('Ц',Let)>0 then r:=true;
if pos('У',Let)>0 then r:=true;
if pos('К',Let)>0 then r:=true;
if pos('Е',Let)>0 then r:=true;
if pos('Н',Let)>0 then r:=true;
if pos('Г',Let)>0 then r:=true;
if pos('Ш',Let)>0 then r:=true;
if pos('Щ',Let)>0 then r:=true;
if pos('З',Let)>0 then r:=true;
if pos('Х',Let)>0 then r:=true;
if pos('Ф',Let)>0 then r:=true;
if pos('Ы',Let)>0 then r:=true;
if pos('В',Let)>0 then r:=true;
if pos('А',Let)>0 then r:=true;
if pos('П',Let)>0 then r:=true;
if pos('Р',Let)>0 then r:=true;
if pos('О',Let)>0 then r:=true;
if pos('Л',Let)>0 then r:=true;
if pos('Д',Let)>0 then r:=true;
if pos('Ж',Let)>0 then r:=true;
if pos('Э',Let)>0 then r:=true;
if pos('Я',Let)>0 then r:=true;
if pos('Ч',Let)>0 then r:=true;
if pos('С',Let)>0 then r:=true;
if pos('М',Let)>0 then r:=true;
if pos('И',Let)>0 then r:=true;
if pos('Т',Let)>0 then r:=true;
if pos('Б',Let)>0 then r:=true;
if pos('Ю',Let)>0 then r:=true;
Result:=r;
end;
Немножко индусского кода!
+186.2
$AmountOfChairs=0;
foreach($faculty['Chair'] as $currChair)
{
$AmountOfChairs++;
}
echo $AmountOfChairs;
+162.8
<?php
function db_connect($host, $user, $pass, $db) {
global $glink;
$glink = mysql_connect($host, $user, $pass) or db_give_error(3, '', db_error($glink));
mysql_select_db($db, $glink) or db_give_error(4, '', db_error($glink));
mysql_query("SET CHARSET cp1251",$glink);
return $glink;
}
function db_query($sql, $log = 0) {
global $glink;
$res = mysql_query($sql, $glink) or db_give_error(5, $sql, db_error($glink));
return $res;
}
function db_fetch_row($res) {
$row = empty($res) ? false : mysql_fetch_row($res);
return $row;
}
function db_num_rows($res, $stmt = '') {
$rows = mysql_num_rows($res);
if (null === $rows) db_give_error(6, '', db_error($glink));
return $rows;
}
function db_num_fields($res, $stmt = '') {
$fields = empty($res) ? false : mysql_num_fields($res);
if (null === $fields) db_give_error(7, '', db_error($glink));
return $fields;
}
function db_field_name($res, $fld) {
$name = (empty($res) or !isset($fld)) ? false : mysql_field_name($res, $fld);
if (false === $name) db_give_error(8, '', db_error($glink));
return $name;
}
function db_affected_rows($res) {
global $glink;
$rows = mysql_affected_rows($glink);
if (null === $rows) db_give_error(9, '', db_error($glink));
return $rows;
}
function db_insert_id($id = 0) {
$id = mysql_insert_id();
return ($id) ? $id : 1;
}
function db_next_id($table, $field, $seqname = 'seq') {
return 0;
}
function db_errno($res) {
return mysql_errno($res);
}
function db_error($res) {
return mysql_error();
}
function db_free_result($res) {
$res = mysql_free_result($res);
return $res;
}
?>
Все из того же проекта (http://govnokod.ru/2929). авторам видимо надоело писать mysql_ и они решили сделать свой аналог db_. При чем смысла от этого полный NULL. Говнокод, он и в Африке говнокод
+163.2
if($id>542)
{
echo '<img Name="altimg" src="'.$foto.'" border=0>';
}
else
{
$size = getimagesize ($foto);
if($size['0']>=500 ? $w=500:$w=$size['0']);
if($size['1']>=500 ? $h=500:$h=$size['1']);
echo '<img Name="altimg" src="'.$foto.'" width="'.$w.'" height="'.$h.'" border=0>';
}
вот что значит запускать бета верси говноскрипта в действие. Не продумав изначально что не плохо бы изменять размеры изображения при заливке пришлось вот так говнокодить.