- 1
- 2
- 3
- 4
- 5
if (result == true) {
return true;
}
else { return false; }
return false;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+143
if (result == true) {
return true;
}
else { return false; }
return false;
не баян, а классика
+138
private static Dictionary<RoleEnum, string> Roles = new Dictionary<RoleEnum, string>
{
{RoleEnum.TeamMember, "Team Member"},
{RoleEnum.ProjectManager, "Project Manager"},
{RoleEnum.ProgramManager, "Program Manager"},
{RoleEnum.PortfolioManager, "Portfolio Manager"},
{RoleEnum.Executive, "Executive"},
{RoleEnum.Undefined, "Undefined"}
};
public static RoleEnum ParseRole(string role)
{
RoleEnum result = RoleEnum.Undefined;
Roles
.Where(_ => _.Value == role)
.ToList()
.ForEach(_ => result = _.Key);
return result;
}
Странное использование дикшинари, очень странное, в обратную сторону можна сказать
−98
if value is False:
res = ~res
elif not value is True:
raise AnalyzeError("Invalid value {0}".format(condition.value))
+84
{*********** PosEx ***********}
function Posex(const substr,str:string; const startloc:integer):integer;
{Search for "substr" in "str" starting at "startloc" return 0 or the start
postion where "substr" was found}
var
i, j,k,ssLen, sLen, stop:integer;
a:char;
begin
result:=0;
ssLen:=length(substr);
slen:=length(str);
stop:=slen-sslen+1; {highest feasible start location for substring}
if (ssLen=0) or (sslen>sLen) then exit;
a:=substr[1]; {1st letter of substr}
i:=startloc; {start search location}
while (i<=stop) and (result=0) do
begin
while (i<=stop) and (a<>str[i]) do inc(i); {find the 1st letter}
if i<=stop then
begin
if sslen=1 then result:=i {It was a 1 character search, so we're done}
else
begin
j:=2;
k:=i-1; {back "K" up by 1 so that we can use K+j as the index to the string}
while (j<=sslen) do
begin {compare the rest of the substring}
if (substr[j]<>str[k+j]) then break
else inc(j); {The letter matched, go to the next+
{When we pass the substring end, "while" loop will terminate}
end;
if (j>sslen) then
begin
result:=i;
exit;
end
else inc(i); {that search failed, look for the next 1st letter match}
end;
end;
end;
end;
Несколько вложенных циклов - это НЕ может работать быстро.
Для сравнения - функция PosEx из StrUtils.pas
function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
var
I,X: Integer;
Len, LenSubStr: Integer;
begin
if Offset = 1 then
Result := Pos(SubStr, S)
else
begin
I := Offset;
LenSubStr := Length(SubStr);
Len := Length(S) - LenSubStr + 1;
while I <= Len do
begin
if S[i] = SubStr[1] then
begin
X := 1;
while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do
Inc(X);
if (X = LenSubStr) then
begin
Result := I;
exit;
end;
end;
Inc(I);
end;
Result := 0;
end;
end;
The Delphi "Pos" function searches for a
substring within a string. Later versions of
Delphi also include a "PosEx" function
which
starts the search at a given position so
multiple calls can return all occurrences.
This program tests DFF versions of these
two
functions. Pos was rewritten to provide a
base
of code for PosEx. And PosEx wll provide
the
missing function for versions of Delphi
before
Delphi 7.
As an unexpected bonus, it appears that the
DFF versions of Pos and Posex are slightly
quicker than the D7 versions.
+121
Wct Editor forever
Ахаххахаха))
+80
function thttp.Get(URI: string): string;
var
newlocation:string;
redirect:integer;
contenttype:string;
i:integer;
contentencoding:string;
test:string;
host:string;
begin
redirect:=0;
headers.clear;
document.clear;
uri:=stringreplace(uri,'\','/',[rfreplaceall]);
// building the host///
if request.host <> '' then
headers.Add(format('Host:%s',[request.host]))
else
begin
i:=pos('://',uri);
if i>0 then
begin
host:=copy(uri,i+3,maxint);
i:=pos('/',host);
if i>0 then
host:=copy(host,1,i-1);
request.host:=host;
end
else
begin
i:=pos('/',uri);
if i>0 then host:=copy(uri,1,i-1)
else
host:=uri;
request.host:=host;
end;
end;
if request.referer <> '' then
headers.Add(format('Referer:%s',[request.referer]));
if request.useragent <> '' then
headers.Add(format('User-Agent:%s',[request.useragent]));
if request.AcceptEncoding <> '' then
headers.Add(format('Accept-Encoding:%s',[request.AcceptEncoding]));
if request.contenttype <> '' then
headers.Add('Content-Type:'+request.contenttype);
if request.connection <> '' then
headers.add('Connection:'+request.connection);
HTTPMethod('GET',uri);
if allowredirects=true then
begin
while (resultcode>=300) and (resultcode<400) do
begin
if (maxredirects <> -1) and (redirect > self.MaxRedirects) then break;
document.clear;
newlocation:=trim(Headers.Values['Location']);
if newlocation='' then break;
if (rightstr(request.host,1) <> '/') and (copy(newlocation,1,1) <> '/') then
newlocation:='/'+newlocation;
headers.clear;
document.clear;
HTTPMethod('GET',host+newlocation);
host:=trim(headers.Values['host']);
if host <> '' then
request.host:=host;
inc(redirect);
end;
end;
contenttype:=Headers.Values['Content-Type'];
contentencoding:=Headers.Values['Content-Encoding'];
request.contentencoding:=contentencoding;
request.contenttype:=contenttype;
if pos('gzip',ansilowercase(contentencoding))>0 then
begin
mstream.clear;
try
GZDecompressStream(Document, MStream);
document.Clear;
document.LoadFromStream(mstream);
document.Position:=0;
except
end;
end;
result:=memorystreamtostring(Document);
if pos('charset=utf-8',ansilowercase(contenttype))>0 then
test:=utf8toansi(result);
if test <> '' then
result:=test;
end;
У Булгакова есть цикл рассказов "Записки на манжетах".
Мой цикл называется "Записки на туалетной бумаге салфетках".
Итак, "Записки на салфетках. Как я обертывал Synapse".
+123
drwsr
+117
bormand сосёт анус своему отцу, размазывая говно по лицу.
+130
<input id="resetbutton" class="btn btn-info" type="reset" value="Reset" name="reset"></input>
Джун порадовал. Не хватает комментария "Шоб наверняка!"
+140
Лошади снова здесь.