- 1
- 2
- 3
- 4
- 5
Jenkins Auto-Updater added a comment - Today 00:35
UNSTABLE: Integrated in contoso #223
Create unit test for CN-858; Currently fails
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+107
Jenkins Auto-Updater added a comment - Today 00:35
UNSTABLE: Integrated in contoso #223
Create unit test for CN-858; Currently fails
+107
function FindPathInPath(path1: string; path2: string): Boolean;
var
lst: TStringlist;
i, l: integer;
begin
lst := TStringlist.Create;
// ----------------------------------------------
path1 := stringreplaceall(path1, '/', '\');
path1 := stringreplaceall(path1, '\\', '\');
// ----------------------------------------------
path2 := stringreplaceall(path2, '\', '');
path2 := stringreplaceall(path2, '/', '');
path2 := stringreplaceall(path2, '"', '');
path2 := stringreplaceall(path2, '<', '');
path2 := stringreplaceall(path2, '>', '');
path2 := stringreplaceall(path2, '?', '');
path2 := stringreplaceall(path2, '|', '');
path2 := stringreplaceall(path2, ':', '');
path2 := stringreplaceall(path2, '*', '');
// ----------------------------------------------
for i := 2 to CountString(path1, '\') + 1 do
begin
lst.Add(StringField(path1, '\', i));
end;
for l := 0 to lst.Count - 1 do
begin
if lstrcmpi(pchar(lst[l]), pchar(path2)) = 0 then
begin
FindPathInPath := True;
break;
end;
end;
lst.Free;
FindPathInPath := false;
exit;
end;
Функция для поиска названий подпапок в файловых путях.
Трудно судить г..нокод ли это, но так как я все же использовал более изящное решение, то быть посему...
+107
while (!jHove.WaitForExit(2000)) { }
Thread.Sleep(2000); // just for case
комментарий убил
+107
// define types
const int FB2 = 0;
const int TXT = 1;
// private
private int Type;
…
// class methods
public CVBook(string path, string type) {
switch(type)
{
case "fb2":
{
Type = 0;
}
break;
case "txt":
{
Type = 1;
}
break;
default:
{
throw new Exception("Unknown Book Format");
}
}
…
switch (Type) {
case FB2: { … }
case TXT: { … }
default:
{
throw new Exception("Unknown Book Format");
}
}
}
}
Парсер книг, все в одном методе.
+107
if (_appliesTo.Contains("CH"))
{
depElig &= true;
}
else
{
depElig &= false;
}
Вроде такого boolshit тут ещё не было.
+107
public Quote[] ParseQuotesFromFile(string p){
HtmlDocument d = new HtmlDocument();
d.Load(p, new UTF8Encoding());
#if !DEBUG
return
#endif
#if DEBUG
var v1 =
#endif
d.GetElementbyId("body")//main div
#if DEBUG
; var v2 = v1
#endif
.ChildNodes//subnodes
#if DEBUG
; var v3 = v2
#endif
.Where(a => a.Attributes.Contains("class"))//nodes with classes
#if DEBUG
; var v4 = v3
#endif
.Where(a => a.Attributes["class"].Value == "quote")//quotes
#if DEBUG
; var v5 = v4
#endif
.Where(a => a.ChildNodes.Any(b => b.Attributes.Contains("class")))//only real quotes
#if DEBUG
; var v6 = v5
#endif
.Select(a => a.ChildNodes.Where(b => b.Attributes.Contains("class")).ToArray())//only usable
#if DEBUG
; var v7 = v6
#endif
.Where(a => a.Length == 2)//drop ads
#if DEBUG
; var v8 = v7
#endif
.Select(a => new Quote()
{
Text = conv.HtmlSpecialCharsDecode(a.First(b => b.Attributes["class"].Value == "text").InnerHtml.Replace("<br>", "\r\n"),StringTools.ReplaceType.Both),
ID=BadParse(GetIdString(a)),
Score=BadParse(GetScoreString(a))})
#if DEBUG
; var v9 = v8
#endif
.ToArray();
#if DEBUG
return v9;
#endif
} private static string GetScoreString(HtmlNode[] a){
#if !DEBUG
return
#endif
#if DEBUG
var v1 =
#endif
a.First(b => b.Attributes["class"].Value == "actions")
#if DEBUG
; var v2 = v1
#endif
.ChildNodes.Where(b => b.Name != "#text")
#if DEBUG
; var v3 = v2
#endif
.First(b => b.Attributes["class"].Value == "rating-o")
#if DEBUG
; var v4 = v3
#endif
.FirstChild
#if DEBUG
; var v5 = v4
#endif
.InnerText;
#if DEBUG
return v5;
#endif
} private static string GetIdString(HtmlNode[] a) {
#if !DEBUG
return
#endif
#if DEBUG
var v1=
#endif
a.First(b => b.Attributes["class"].Value == "actions")
#if DEBUG
; var v2 = v1
#endif
.ChildNodes.Where(b => b.Name != "#text")
#if DEBUG
; var v3 = v2
#endif
.First(b => b.Attributes["class"].Value == "id")
#if DEBUG
; var v4 = v3
#endif
.InnerText.Replace("#", "");
#if DEBUG
return v4;
#endif
}
Это должен был быть парсер bash.org.ru
Самоое странное, что код даже работает
+107
if (curMenu != null)
{
depth = curMenu.Depth;
Menu menuG = null;
if (depth == 1)
{
menuG = curMenu;
}
if (depth == 2)
{
menuG = curMenu.Menu2;
}
if (depth == 3)
{
menuG = curMenu.Menu2.Menu2;
}
if (depth == 4)
{
menuG = curMenu.Menu2.Menu2.Menu2;
}
Меню "неограниченной" вложенности
+107
@Inject
protected MainWindowController(
final SessionController session,
final QueueController queueController,
final MachineController machineController,
final PrintController printController,
final MainWindow window,
final UIHandler uiHandler,
final ImageCache imageCache,
final EventBus bus,
final ActiveOrderHolder orderHolder,
final ApiClientAsync apiClient,
final ReferenceDataCache dataCache,
@SvnRevision final int svnRevision) throws IOException {
+107
function Ns(ds: char; var vs: byte): boolean;
begin
case ds of
'Q': vs:= 81;
'W': vs:= 87;
'E': vs:= 69;
'R': vs:= 82;
'T': vs:= 84;
'Y': vs:= 89;
'U': vs:= 85;
'I': vs:= 73;
'O': vs:= 79;
'P': vs:= 80;
'A': vs:= 65;
'S': vs:= 83;
'D': vs:= 68;
'F': vs:= 70;
'G': vs:= 71;
'H': vs:= 72;
'J': vs:= 74;
'K': vs:= 75;
'L': vs:= 76;
'Z': vs:= 90;
'X': vs:= 88;
'C': vs:= 67;
'V': vs:= 86;
'B': vs:= 66;
'N': vs:= 78;
'M': vs:= 77;
else vs:= 0;
end;
if vs = 0 then Result:= false else Result:= true;
end;
Определение кода виртуальных клавиш, вот что бывает, когда кто-то не знает матчасть, вся эта белиберда легко заменяется на :
function Ns(ds: char; var vs: byte): boolean;
begin
case ds of
'A'..'Z': vs:= byte(ds);
else vs:= 0;
end;
if vs = 0 then Result:= false else Result:= true;
end;
И не лень же было клаву мучить!
+107
begin
writeln('Enter 1st number');
readln(a);
writeln('Enter 2st number');
readln(b);
writeln('Enter 3st number');
readln(c);
if a = b then if a = c then if b = c then ;
writeln('numbers are');
if a > b then if a = c then if b < c then
writeln('a Equally c and it is more b') ;
if a = b then if a > c then if b > c then
writeln('a Equally b and it is more c') ;
if a < b then if a < c then if b = c then
writeln('b Equally c and it is more a') ;
if a > b then if a > c then if b > c then
writeln('a it is more ') ;
if a > b then if a > c then if b < c then
writeln('a it is more ') ;
if a > b then if a > c then if b = c then
writeln('a it is more ') ;
if a < b then if a = c then if b > c then
writeln('b it is more ') ;
if a < b then if a > c then if b > c then
writeln('b it is more ') ;
if a < b then if a < c then if b > c then
writeln('b it is more ') ;
if a = b then if a < c then if b < c then
writeln('c it is more ') ;
if a > b then if a < c then if b < c then
writeln('c it is more ') ;
if a < b then if a < c then if b < c then
writeln('c it is more ') ;
Такое выдал один из моих учеников в 10м классе после того, как отказался учится рисовать блок-схемы и сказал, что сразу сможет писать. Задание заключалось в том, чтобы программа выводила большее из 3х введенных пользователем чисел.