- 1
- 2
- 3
- 4
- 5
$this->_requestUri = 0 === strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])
? substr(
$_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])
)
: $_SERVER['REQUEST_URI'];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+53
$this->_requestUri = 0 === strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])
? substr(
$_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])
)
: $_SERVER['REQUEST_URI'];
+102
var usr = Enumerable.Range(1, 1)
.Select(id => new User(1, "FooBar", "desc" + 1, DateTime.UtcNow))
.ToReadonly()
.GetRandomElement();
Из юнит-теста. Копипаста рождает чудовищ.
+25
public OnPlayerSpawn(playerid) {
IsSpawned[playerid]=1;
if(Team[playerid]==ZOMBIE) { TextDrawSetString(Textdraw9[playerid],"You are a ~r~Zombie~w~. Kill & Infect every Human to complete your mission.");
} else if(Team[playerid]==HUMAN) { TextDrawSetString(Textdraw9[playerid],"You are a ~r~Human~w~. Prevent Zombie attacks and survive till the end."); }
TextDrawHideForAll(Box); TextDrawHideForAll(text_Top5[0]); TextDrawHideForAll(text_Top5[1]);
TextDrawShowForPlayer(playerid, Textdraw0); TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2); TextDrawShowForPlayer(playerid, Textdraw3);
TextDrawShowForPlayer(playerid, Textdraw4); TextDrawShowForPlayer(playerid, Textdraw5);
TextDrawShowForPlayer(playerid, Textdraw6); TextDrawShowForPlayer(playerid, Textdraw7);
TextDrawShowForPlayer(playerid, Textdraw9[playerid]);
TextDrawShowForPlayer(playerid, Textdraw15); TextDrawShowForPlayer(playerid, Textdraw16[playerid]);
SetTeam(playerid); SetClass(playerid);
if(Infection==1) {
Infection=0;
if(Totalplayers>=2) {
SetTimer("InfectionLoad",0,0);
} else if(Totalplayers>=10) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=10) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=20) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=30) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=45) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=60) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers<=75) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}
} return 1; }
Серьезно?
−90
public static function findNeighbourEmpty(cx:int, cy:int, checkDebris:Boolean = true):Cell {
var cell:Cell = Cell.getCell(cx, cy);
var i:int = 0;
var distance:int = 1;
var n:int = 8;
while(!cell || !cell.accessible || (checkDebris && !isEmptyTile(cell))) {
if (i < n * distance / 4) {
cell = Cell.getCell(cx + Math.min(i, distance), cy + Math.min(distance * 2 - i, distance));
} else if (i < n * distance / 2) {
cell = Cell.getCell(cx + Math.min(distance * 2 - i + n * distance / 4, distance), cy + Math.max(n * distance / 4 - i, -distance));
} else if (i < 3 * n * distance / 4) {
cell = Cell.getCell(cx + Math.max(n * distance / 2 - i, -distance), cy + Math.max(-distance * 2 + i - n * distance / 2, -distance));
} else if (i < n * distance) {
cell = Cell.getCell(cx + Math.max(-distance * 2 + i - 3 * n * distance / 4, -distance), cy + Math.min(i - 3 * n * distance / 4, distance));
} else {
i = 0;
distance++;
if (distance > MAX_NEIGHBOUR_CELL_DISTANCE) {
return findNeighbourEmpty(cx, cy, false);
}
continue;
}
i++;
}
return cell;
}
Какой милый метод...
+140
Здравствуйте, господа!
Кто знает, как выяснить свободный порт виртуальной машины средствами PHP?
+49
function preDispatch() {
// Validate and redirect
try {
$this->_DB = Zend_Db_Table::getDefaultAdapter();
$time = $this->_DB->query('SELECT time FROM `CapturesList` WHERE InnerLink = \'' . $_SERVER['REQUEST_URI'] . '\' LIMIT 0,1;')->fetchAll();
@$this->view->time = $time[0]['time'];
if ($time[0]['time'] != NULL) {
$times = split(', ', $time[0]['time']);
if (strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00") < (int) (mktime())) {
if (strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00") > 1347032555) {
$count = $this->_DB->query('SELECT *, COUNT(time) AS counts FROM `CapturesList` WHERE time IS NOT NULL;')->fetchAll();
$count = $count[0]['counts'];
@$newdate = strftime("%G, %m, %d, %H", strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00 +" . ((int)($count / 2) + 1) . " weeks"));
@$this->_DB->query('UPDATE `CapturesList` SET `time` = \'' . ($newdate) . '\' WHERE InnerLink = \'' . $_SERVER['REQUEST_URI'] . '\';');
@$this->view->time = $newdate;
}
else{@$this->view->time = $time[0]['time'];}
} else {
@$this->view->time = $time[0]['time'];
}
} else {
@$this->view->time = "NULL";
}
} catch (Exception $exc) {
echo $exc->getTraceAsString();
@$this->view->time = "NULL";
}
header('Refer: ' . $this->view->linktofunnel);
if (session_id() == '')
session_start();
if ($this->_getParam('action') != 'save') {
$_SESSION["domain"] = $this->view->domain;
$_SESSION["owner"] = $this->OwnerData;
}
}
Более говнокодного я давно не писал. Кажется я схожу с ума
+79
private static String dbl2str(Object obj) {
String value;
String str = obj.toString();
if (str.indexOf('E') != -1) {
//System.out.print("1 ");
String[] qwe = str.split("E");
String newstr = "";
int step = Integer.parseInt(qwe[1]);
for (int ind = 0; ind < qwe[0].length(); ind++) {
if (step > 0) {
if ((ind == (step + 2)) && (ind != qwe[0].length())) {
newstr = newstr + '.';
}
if (str.charAt(ind) != '.') {
newstr = newstr + str.charAt(ind);
}
if ((ind == qwe[0].length() - 1) && (ind <= step)) {
for (int ind2 = 0; ind2 < (step + 1 - ind); ind2++) {
newstr = newstr + "0";
}
}
} else {
if (ind == 0) {
newstr = newstr + "0.";
for (int ind3 = 0; ind3 > step + 1; ind3--) {
newstr = newstr + "0";
}
}
if (str.charAt(ind) != '.') {
newstr = newstr + str.charAt(ind);
}
}
}
value = newstr;
} else {
value = obj.toString();
}
return value;
}
жгем, товарищи! Double to String!
+169
if(navigator.appName == "Microsoft Internet Explorer") {
for(var i=0;i<$('.product_documents').length;i++) if( ( (firstLaunch_onChangeDocs) && ($('.product_documents')[i].selectedIndex==0)) || (!firstLaunch_onChangeDocs) )
{
document.getElementById($('.product_documents')[i].id).innerHTML = '';
document.getElementById($('.product_documents')[i].id).outerHTML = document.getElementById($('.product_documents')[i].id).outerHTML.replace("</SELECT>", jsInternalDocuments + '</select>')
}
} else
for(var i=0;i<$('.product_documents').length;i++) if( ( (firstLaunch_onChangeDocs) && ($('.product_documents')[i].selectedIndex==0)) || (!firstLaunch_onChangeDocs) )
$('.product_documents')[i].innerHTML = jsInternalDocuments;
Очень альтернативная техника использования jquery.
−118
Если (ЕстьНомен.НайтиЗначение(Док.Номенклатура) > 0)
ИЛИ (ЕстьНомен.НайтиЗначение(Док.Номенклатура.Родитель) > 0)
ИЛИ (ЕстьНомен.НайтиЗначение(Док.Номенклатура.Родитель.Родитель) > 0)
ИЛИ (ЕстьНомен.НайтиЗначение(Док.Номенклатура.Родитель.Родитель.Родитель) > 0)
ИЛИ (ЕстьНомен.НайтиЗначение(Док.Номенклатура.Родитель.Родитель.Родитель.Родитель) > 0)
ИЛИ (ЕстьНомен.НайтиЗначение(Док.Номенклатура.Родитель.Родитель.Родитель.Родитель.Родитель) > 0) Тогда
ИтогоРМ = ИтогоРМ+Док.Сумма;
КонецЕсли;
ЕстьНомен - это элемент формы Список, т.е. код можно упростить до:
Если ЕстьНомен.Принадлежит(Док.Номенклатура) =1 Тогда
ИтогоРМ = ИтогоРМ+Док.Сумма;
КонецЕсли;
взято из конфигурации одного автодилера.
+160
for(var i = 0, l = requestParams.length; i < l; i++) {
var param_pair = requestParams[i];
key = encodeURIComponent(param_pair[0]);
val = param_pair[1];
if ( val && val.constructor.toString().match(/array/i) ) {
val = val.join('+');
}
// ...
}
Кусочек велосипеда, который заменяет функционал jQuery.ajax
Если вдруг наш параметр оказался массивом ... ну что ж еще с ним сделать кроме как соединить через "+". Обратите внимание на саму проверку.