- 1
- 2
- 3
- 4
if (!isset($pmas_table[0][3])) $pmas_table[0][3]='';
if (!isset($pmas_table[0][5])) $pmas_table[0][5]='';
if (!isset($pmas_table[0][6])) $pmas_table[0][6]='';
if (!isset($pmas_table[0][7])) $pmas_table[0][7]='';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+150
if (!isset($pmas_table[0][3])) $pmas_table[0][3]='';
if (!isset($pmas_table[0][5])) $pmas_table[0][5]='';
if (!isset($pmas_table[0][6])) $pmas_table[0][6]='';
if (!isset($pmas_table[0][7])) $pmas_table[0][7]='';
UserSide v2.48 again. Так как там каждая строчка имеет право быть на этом сайте, выкладываю The best of the best =)
+161
while (!$db->query("INSERT INTO lots (lot_num) VALUES (".($unicnum=rand(1,99999)).")"));
Проверка и создание уникального рандомного идентификатора
+156
string Delimiter(string Text, int Index, const char* Delimiter) {
int n = 0, find = 0;
for (int i = 0; i <= Index; i++) {
find = Text.find(Delimiter, n);
if (i == Index) {
return Text.substr(n, find - n);
}
n = find + 1;
}
return "";
}
+993
void inline WriteXY(int X, int Y, byte szText, WORD fColor = 0x01F) {
DWORD cWritten;
COORD ptCoord = {X - 1, Y - 1};
gotoxy(X, Y);
cout << char(szText);
cout.flush();
FillConsoleOutputAttribute(hStdOut, fColor, 1, ptCoord, &cWritten);
return;
}
void inline WriteXY(int X, int Y, string szText, WORD fColor = 0x01F) {
DWORD cWritten;
COORD ptCoord = {X - 1, Y - 1};
gotoxy(X, Y);
cout << szText.c_str();
cout.flush();
FillConsoleOutputAttribute(hStdOut, fColor, strlen(szText.c_str()), ptCoord, &cWritten);
return;
}
Функция и её прототип
+150
public function run() {
$stime = microtime(TRUE);
$this->header('Content-Type: text/html');
$this->setcookie('testcookie', '1');
$this->registerShutdownFunction(function() {
?></html><?php
});
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>It works!</title>
</head>
<body>
<h1>It works! Be happy! ;-)</h1>
............
............
............
phpDaemon Example.php line 63
+173
/*
if($_REQUEST["act_id"]==8){
а нет. маньяки так не пишут...
*/
define("Э", $_REQUEST["act_id"]);
if( 8===Э ){
...
}
оператор члена :)
−79
// Досталось по наследству:
@try {
if([[items objectAtIndex:indexPath.row] performSelector:@selector(songsArray)]){
NSArray *songsArray = [[items objectAtIndex:indexPath.row] songsArray];
for(Song *song in songsArray){
[song setIsSelected:button.selected];
}
}
}
@catch (NSException *exception) {
NSLog(@"need fix in next time");
}
// переделал в
if ( [[items objectAtIndex:indexPath.row] respondsToSelector:@selector(songsArray)] )
{
NSArray *songsArray = [[items objectAtIndex:indexPath.row] songsArray];
for(Song *song in songsArray){
[song setIsSelected:button.selected];
}
}
+69
package com.govnoistochnik.servleti;
...
import javax.servlet.GenericServlet;
...
public class GenericReportingServlet extends GenericServlet {
...
public synchronized void createReport(...)
{
// pessot strok govnokoda
}
public synchronized void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
// Kucha govnokoda
createReport(...);
// Prodoljeniye kuchi
}
...
}
Хороший пример как сделать однопоточный репортинг сервер.
Обратите внимание на "synchronized".
Результат:
1) Мах Session (200).
2) Жрёт всю память
3) Сервер виснет. Никакой Psi prob, Lambda prob ету гадину не выявит.
4) Хрен найдёшь почему говняет если кода нет.
+969
public static string ConvertNumberToString(double tmpStr)
{
string ret = "";
try
{
if (((long)tmpStr).ToString().Length > 3)
{
string len = ((long)tmpStr).ToString();
string[] strSplit = tmpStr.ToString().Split(',');
long tmpM = 0;
if (strSplit.Length > 1)
tmpM = Convert.ToInt64(strSplit[1]);
int count = (int)len.Length / 3;
ret = len.Substring(0, (len.Length - 3 * count));
for (int i = 0; i < count; i++)
{
ret += " " + len.Substring((ret.Length - i), 3);
}
if (tmpM > 0)
{
ret += "," + strSplit[1];
}
}
else
ret = tmpStr.ToString();
}
catch
{
}
return ret.Trim();
}
Из той же оперы...
+126
public static bool IsLong(string tmpStr)
{
bool blRetVal = true;
for (int i = 0; i < tmpStr.Length; i++)
{
if (tmpStr[i] != '0' && tmpStr[i] != '1' && tmpStr[i] != '2' &&
tmpStr[i] != '3' && tmpStr[i] != '4' && tmpStr[i] != '5' &&
tmpStr[i] != '6' && tmpStr[i] != '7' && tmpStr[i] != '8' &&
tmpStr[i] != '9')
blRetVal = false;
}
return blRetVal;
}
static public string ConvertDateTimeForSQL(DateTime tmpDateTime)
{
return (
tmpDateTime.Year.ToString() + "-" +
(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString() + " " +
(tmpDateTime.Hour < 10 ? "0" : "") + tmpDateTime.Hour.ToString() + ":" +
(tmpDateTime.Minute < 10 ? "0" : "") + tmpDateTime.Minute.ToString() + ":" +
(tmpDateTime.Second < 10 ? "0" : "") + tmpDateTime.Second.ToString());
}
static public string ConvertDateTimeShortForSQL(DateTime tmpDateTime)
{
return (tmpDateTime.Year.ToString() + "-" +
(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString());
}
-----------------------------------
P.S. Версия .NET 3.5