- 1
- 2
- 3
- 4
- 5
- 6
try {
...
} catch ( Exception $O_o ) {
error_log( $O_o->getMessage() );
...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+164
try {
...
} catch ( Exception $O_o ) {
error_log( $O_o->getMessage() );
...
}
Совсем неожиданный эксепшин O_o
+168
$action=$_GET["action"];
...
if($action==1){ ... }
if($action==2){ ... }
...
if($action==9){ ... }
if($action!=1 &&
$action!=2 &&
$action!=3 &&
$action!=4 &&
$action!=5 &&
$action!=6 &&
$action!=7 &&
$action!=8 &&
$action!=9) print("<html><body bgcolor=".'"#000000"'." color=".'"#FFFFFF"'."><div align=".'"center"'."><h1><b>Ошибка! Такой страницы нет!</b></h1></div><!--*copyright*--></body></html>");
crazy code
+160
<?php
$text = '<td>
<img src="https://site/accounts/msh.gif" alt="История веб-поиска">
</td>
<td style="font-size:83%"> ';
$beforeText = '<div>';
$afterText = '</div>';
$curPos = 0;
while(false !== $imgTagStartPos = stripos($text, '<img', $curPos))
{
if(!ctype_space($text[$imgTagStartPos + 4]))
{
$curPos += $imgTagStartPos + 4;
continue;
}
$imgTagEndPos = stripos($text, '>', $imgTagStartPos + 5);
if(false === $imgTagEndPos)
break;
$imgTagLen = $imgTagEndPos + 1 - $imgTagStartPos;
$imgTag = substr($text, $imgTagStartPos, $imgTagLen);
$text = substr_replace($text, "{$beforeText}{$imgTag}{$afterText}", $imgTagStartPos, $imgTagLen);
$curPos = $imgTagEndPos + 1 + strlen($beforeText) + strlen($afterText);
}
Замена всех "<img .*>" на "<div><img .*></div>". Взято с форума http://softtime.ru/forum/read.php?id_forum=1&id_theme=75199 , хотя ниже автор этого кода написал нормальный вариант с регэкпами.
+130
function Wait-ProcessStart{
param([string]$PName)
$pname = $PName
$started = $false
$countONstart = if((Get-Process|Where{$_.Name -eq $pname}).Length -eq $null){if((Get-Process|Where{$_.Name -eq $pname}).Name -eq $null){0}else{1}}else{(Get-Process|Where{$_.Name -eq $pname}).Length}
while($started -eq $false){
$ccount = if((Get-Process|Where{$_.Name -eq $pname}).Length -eq $null){if((Get-Process|Where{$_.Name -eq $pname}).Name -eq $null){0}else{1}}else{(Get-Process|Where{$_.Name -eq $pname}).Length}
if($ccount -le $countONstart){$countONstart = $ccount;continue}
if($ccount -gt $countONstart){$started = $true}
}
}
Это мой высер вместо WMI-событий.
Ждем запуска процесса с определенным именем.
+97
{
----------------------8<----------------------
Цей юніт призначений лише для використання
разом із пакетом програм ███████
будь-якої версії.
Він не може розповсюджуватися окремо, так
як являється частиною пакету, який може
розповсюджуватися на платній основі.
(С) Copyright ███████████████
----------------------8<----------------------
}
(* ~15 строк поскипано за унылостью *)
procedure TranslateForm(var form:TObject; const LNGFile:String);
var
ini:TIniW;
c1,c2,p1,p2,i:Integer;
Sct,par,val:string;
keys:TStringList;
cobg:TObject;
comp:TComponent;
begin
initini(ini,LNGFile);
keys:=TStringList.Create;
sct:=Trim((form as TForm).Name);
c1:=ini.KeyCount(Sct);
ini.ReadSection(Sct,keys);
cobg:=(form as TObject);
for I := 0 to c1-1 do
begin
par:=keys[I];
p1:=Pos('=',par);
par:=Trim(Copy(par,0,p1-1));
val:=ini.ReadString(Sct,par,'read error');
typinfo.SetStrProp(cobg,par,val);
end;
c2:=(form as TForm).ComponentCount;
for p2 := 0 to c2 - 1 do
begin
comp:=(form as TForm).Components[p2];
cobg:=(comp as TObject);
sct:=typinfo.GetStrProp(cobg,'Name');
c1:=ini.KeyCount(Sct);
if c1>0 then
ini.ReadSection(Sct,keys);
for I := 0 to c1-1 do
begin
par:=keys[I];
p1:=Pos('=',par);
par:=Trim(Copy(par,0,p1-1));
val:=ini.ReadString(Sct,par,'read error');
try
typinfo.SetStrProp(cobg,par,val);
except
end;
end;
end;
end;
end.
Сверху - жадность, снизу - отсутствие скиллов.
+118
public void isCollideWith(gObj obj, ref bool xCollision, ref bool yCollision)
{
xCollision = (obj.bounds.Top <= this.bounds.Center.Y && this.bounds.Center.Y <= obj.bounds.Bottom) &&
(obj.bounds.Top > this.bounds.Top && obj.bounds.Top < this.bounds.Bottom) ||
(obj.bounds.Bottom > this.bounds.Top && obj.bounds.Bottom < this.bounds.Bottom);
yCollision = (obj.bounds.Left <= this.bounds.Center.X && this.bounds.Center.X <= obj.bounds.Right) &&
(obj.bounds.Left > this.bounds.Left && obj.bounds.Left < this.bounds.Right) ||
(obj.bounds.Right > this.bounds.Left && obj.bounds.Right < this.bounds.Right);
}
Вот так я проверяю произошло ли столкновения двух(obj и this) прямоугольных объектов.
+77
Writer writer = new BufferedWriter(new FileWriter(new File("launch.vbs")));
writer.write("Set objIExplorer = CreateObject(\"internetexplorer.application\")\r\n");
writer.write("objIExplorer.visible = True\r\n");
writer.write("objIExplorer.navigate \"http://www.google.com\"\r\n");
writer.flush();
writer.close();
Runtime.getRuntime().exec("cscript.exe launch.vbs");
Запуск IE под виндой, когда путь к нему неизвестен.
+189
function d1m(spa,spb,spc,spd,spe,spf){
if(!ie5){spa+=(sbSIZE*2); }
if(!spb||spb==""){spb="left";}
if(!spc||spc==""){spc="left";}
if(!spd){spd=0;}
if(!spe){spe=0;}
if(!spf){spf="";}
sP[(m-1)]=new Array(spa,spb,spc,spd,spe,spf);
if(sm==0){
sI[(m-1)]=new Array; cP[(m-1)]=new Array; cI[(m-1)]=new Array;
}
}
function d2m(cpa,cpb,cpc,cpd,cpe,cpf){
if(!ie5){cpa+=(sbSIZE*2); }
if(!cpb||cpb==""){cpb="left";}
if(!cpc||cpc==""){cpc="left";}
if(!cpd){cpd=0;}
if(!cpe){cpe=0;}
if(!cpf){cpf="";}
cP[(m-1)][(sm-1)]=new Array(cpa,cpb,cpc,cpd,cpe,cpf);
cI[(m-1)][(sm-1)]=new Array;
}
а я то думал что функции нужны чтоб не писать одно и тоже по 100 раз
+161
$F1 = F2($x);
if ($F1 !== 0)
{
$InInt = false;
if ($F1) $InInt = true; // <--- это писец
if (!$InInt) continue; // <--- это тоже
}
$F3 = F($x);
$SumH += abs($F3);
+115
private int? ID {
set {
if (ViewState["ID"] != null)
ViewState["ID"] = value;
else
ViewState.Add("ID", value);
}
get {
if (ViewState["ID"] != null)
return Convert.ToInt32(ViewState["ID"]);
else
return null;
}
}