- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
function $(element, method) {
if (!method) {
return document.getElementById(element);
} else {
return {
node: $(element)
}
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+152.9
function $(element, method) {
if (!method) {
return document.getElementById(element);
} else {
return {
node: $(element)
}
}
}
+162.9
if (strlen($id) == '1') $out = substr($MP,965,54);
if (strlen($id) == '2') $out = substr($MP,971,55);
if (strlen($id) == '3') $out = substr($MP,977,56);
if (strlen($id) == '4') $out = substr($MP,983,57);
if (strlen($id) == '5') $out = substr($MP,989,58);
if (strlen($id) == '6') $out = substr($MP,995,59);
if (strlen($id) == '7') $out = substr($MP,1001,60);
Автор знает меру - 10^7-1 материалов - максимум.
+158
$GLOBALS['_utf8win1251'] = array(
"\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4",
............
"\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2");
$GLOBALS['_win1251utf8'] = array(
"\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94",
............
"\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E");
function utf8_win1251($a) {
// global $_utf8win1251;
if (is_array($a)){
foreach ($a as $k => $v) {
if (is_array($v)) {
$a[$k] = utf8_win1251($v);
} else {
$a[$k] = strtr($v, $GLOBALS['_utf8win1251']);
}
}
return $a;
} else {
return strtr($a, $GLOBALS['_utf8win1251']);
}
}
function win1251_utf8($a) {
// global $_win1251utf8;
if (is_array($a)){
foreach ($a as $k=>$v) {
if (is_array($v)) {
$a[$k] = win1251_utf8($v);
} else {
$a[$k] = strtr($v, $GLOBALS['_win1251utf8']);
}
}
return $a;
} else {
return strtr($a, $GLOBALS['_win1251utf8']);
}
}
а сколько всего...
mb_convert_encoding и array_walk_recursive отменили...
ну или хотя-бы от вложенных if избавиться можно
+92.3
program krestiki_noliki;
var a,b,c,
d,e,f,
g,h,i,
click:char;
cl,cr,count:smallint;
procedure move; forward;
procedure clickproc;
begin
If cr=0
then
begin
cr:=1;
click:='X';
end
else
begin
cr:=0;
click:='O';
end;
end;
procedure restart;
begin
if count<9
then move
else
begin
count:=0;
cr:=0;
cl:=0;
click:='X';
a:='_';
b:='_';
c:='_';
d:='_';
e:='_';
f:='_';
g:='_';
h:='_';
i:='_';
end;
end;
procedure move;
begin
readln(cl);
clickproc;
if (cl=1) and (a='_') then a:=click;
if (cl=2) and (b='_') then b:=click;
if (cl=3) and (c='_') then c:=click;
if (cl=4) and (d='_') then d:=click;
if (cl=5) and (e='_') then e:=click;
if (cl=6) and (f='_') then f:=click;
if (cl=7) and (g='_') then g:=click;
if (cl=8) and (h='_') then h:=click;
if (cl=9) and (i='_') then i:=click;
count:=count+1;
writeln(a,'|',b,'|',c);
writeln(d,'|',e,'|',f);
writeln(g,'|',h,'|',i);
writeln('-----');
restart;
end;
begin
count:=0;
cr:=0;
writeln('1|2|3');
writeln('4|5|6f');
writeln('7|8|9');
writeln('-----');
restart;
end.
навеяло кодом на Visual Basic, подумал что смогу воплотить на Паскале. Зря, не стоило...
(так и не понял, что именно не работает)
+129.7
public string GetHtmlElement(RepeaterItem Container)
{
string Result = string.Empty;
string AClasses = HAS_CHILDREN_BASE_CSS_CLASS;
SiteMapNode Node = (SiteMapNode)Container.DataItem;
string Title = Node.Title;
string EnabledAttrSign = CustomSiteMapNodeInfo.ENABLED_ATTR_NAME;
string CssClassNameSign = CustomSiteMapNodeInfo.CSS_CLASS_ATTR_NAME;
string SpanCssClasses = string.Empty;
// checks for separator
if (string.IsNullOrEmpty(Node.Title) || Node.Title == ShellModuleInitializer.SEPARATOR)
{
SpanCssClasses = MENU_SEPARATOR_CSS_CLASS_NAME;
Title = EMPTY_TEXT;
}
bool HasImage = !string.IsNullOrEmpty(Node[CssClassNameSign]);
if (HasImage)
{
SpanCssClasses += HAS_IMAGE_CSS_CLASS_NAME;
}
Result = string.Format("<span class=\"{0}\">{1}</span>", SpanCssClasses, Title);
if (HasImage)
{
Result = string.Format("<span class=\"{0}\">{1}</span>{2}", Node[CssClassNameSign], EMPTY_TEXT, Result);
}
// checks for disabled item
if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "false", true) == 0)
{
AClasses += string.Format(" {0}", DISABLED_CSS_CLASS_NAME);
}
// checks for enabled item
if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "true", true) == 0)
{
Result = string.Format("<a href=\"{0}\" class=\"{1}\">{2}</a>", GetFullUrl(Container), AClasses, Result);
}
else
{
// cheks for non-clickable item
Result = string.Format("<a class=\"{0}\">{1}</a>", AClasses, Result);
}
return Result;
}
+150.9
<?php
...
mysql_select_db($database_store, $store);
$query_rsThisCategoryItems = sprintf("SELECT DISTINCT store_products.product_name, store_products.image_file, store_products.product_id, store_products.product_price, store_products_to_categories.category_id, store_products.sku FROM store_products_to_categories, store_products WHERE store_products_to_categories.category_id=%s AND store_products_to_categories.product_id=store_products.product_id GROUP BY store_products.product_name", GetSQLValueString($cat_rsThisCategoryItems, "int"));
$rsThisCategoryItems = mysql_query($query_rsThisCategoryItems, $store) or die(mysql_error());
$row_rsThisCategoryItems = mysql_fetch_assoc($rsThisCategoryItems);
$totalRows_rsThisCategoryItems = mysql_num_rows($rsThisCategoryItems);
//product query
$colname_rsThisProduct = "1";
if (isset($_GET['p_id'])) {
$colname_rsThisProduct = $_GET['p_id'];
}
mysql_select_db($database_store, $store);
$query_rsThisProduct = sprintf("SELECT * FROM store_products WHERE product_id=%s", GetSQLValueString($colname_rsThisProduct, "int"));
$rsThisProduct = mysql_query($query_rsThisProduct, $store) or die(mysql_error());
$row_rsThisProduct = mysql_fetch_assoc($rsThisProduct);
$totalRows_rsThisProduct = mysql_num_rows($rsThisProduct);
//cart contents for header summary
$colname_rsQuickCart = "-1";
if (isset($_SESSION['sessionid'])) {
$colname_rsQuickCart = $_SESSION['sessionid'];
}
mysql_select_db($database_store, $store);
$query_rsQuickCart = sprintf("SELECT * FROM store_cart, store_products WHERE store_cart.session_id = %s AND store_cart.product_id=store_products.product_id", GetSQLValueString($colname_rsQuickCart, "text"));
$rsQuickCart = mysql_query($query_rsQuickCart, $store) or die(mysql_error());
$row_rsQuickCart = mysql_fetch_assoc($rsQuickCart);
$totalRows_rsQuickCart = mysql_num_rows($rsQuickCart);
$colname_rsCartTotal = "-1";
if (isset($_SESSION['sessionid'])) {
$colname_rsCartTotal = $_SESSION['sessionid'];
}
mysql_select_db($database_store, $store);
$query_rsCartTotal = sprintf("SELECT SUM(total_price) FROM store_cart WHERE session_id = %s", GetSQLValueString($colname_rsCartTotal, "text"));
$rsCartTotal = mysql_query($query_rsCartTotal, $store) or die(mysql_error());
$row_rsCartTotal = mysql_fetch_assoc($rsCartTotal);
$totalRows_rsCartTotal = mysql_num_rows($rsCartTotal);
...
?>
пришёл на работу.
Дали до делать вебсайт
увидел ЭТО....и обиделся на аФФтара О_о
+126.4
foreach (object item in this.cbFind.Properties.Items)
{
int a = -1;
}
+136.7
void parseDate(String str, ref int day, ref int month, ref int year)
{
String[] strings = str.Split('/');
day = Int32.Parse(strings[0]);
month = Int32.Parse(strings[1]);
year = Int32.Parse(strings[2]);
}
bool validateDate(String s)
{
//let the data be null
if (s == null || s == "")
return true;
try
{
String[] strings = s.Split('/');
if (strings.Length != 3)
return false;
String day = strings[0];
if (Int32.Parse(day) > 31)
{
return false;
}
String month = strings[1];
if (Int32.Parse(month) > 12)
{
return false;
}
String year = strings[2];
if (year.Length != 4)
{
return false;
}
}
catch (SystemException)
{
return false;
}
return true;
}
int compareDates(String s1, String s2)
{
if (s1 == "" && s2 != "")
return -1;
if (s1 == s2)
return 0;
if (s1 != "" && s2 == "")
return 1;
int day1 = 0, month1 = 0, year1 = 0, day2 = 0, month2 = 0, year2 = 0;
parseDate(s1, ref day1, ref month1, ref year1);
parseDate(s2, ref day2, ref month2, ref year2);
if (year1 > year2)
return -1;
if (year1 < year2)
return 1;
if (month1 > month2)
return -1;
if (month2 < month1)
return 1;
if (day1 > day2)
return -1;
if (day2 > day1)
return 1;
return 0;
}
no comments
+161.8
function casecyr($eng) {
$rus = $eng;
if ($eng=="д") $rus = "Д";
if ($eng=="ш") $rus = "Ш";
if ($eng=="п") $rus = "П";
if ($eng=="с") $rus = "С";
if ($eng=="т") $rus = "Т";
if ($eng=="ч") $rus = "Ч";
if ($eng=="в") $rus = "В";
if ($eng=="о") $rus = "О";
return $rus;
}
Без комментариев
+160.5
echo "Ваша корзина:";
foreach ($_REQUEST as $name => $value)
switch ($value)
{
case "ras1":
echo "<p> $name";
break;
case "ras2":
echo "<p> $name";
break;
case "ras3":
echo "<p> $name";
break;
case "ras4":
echo "<p> $name";
break;
case "ras5":
echo "<p> $name";
break;
case "ras6":
echo "<p> $name";
break;
case "ras7":
echo "<p> $name";
break;
case "ras8":
echo "<p> $name";
break;
}
$filename= 'zakaz.txt';
$somecontent = "$name\n";
if (is_writable($filename)) {
fwrite().
if (!$handle = fopen($filename, 'w')) {
echo "Не могу открыть файл ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
exit;
}
fclose($handle);
}
чувак спросил на форуме, почему его скрипт все время выводит строку 'vc' вместо страницы. Потом привел аццкий код :)