- 1
- 2
- 3
- 4
for (int i = 0; i < 40; i++)
{
GC.Collect();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+115
for (int i = 0; i < 40; i++)
{
GC.Collect();
}
чтоб наверняка :))
+43
/*
* encoding.cpp
*
* Created on: Oct 25, 2012
* Author: root
*/
+91
function TDuel.getFieldStr(p1: ansistring; p2: ansistring; p3: ansistring = ''): ansistring;
begin
Result := '';
if p1 = 'p1' then begin
if p2 = 'attack' then begin
if p3 = '' then Result := p1attack;
if p3 = '1' then Result := p1attack1;
end;
if p2 = 'defend' then begin
Result := p1defend;
end;
end;
if p1 = 'p2' then begin
if p2 = 'attack' then begin
if p3 = '' then Result := p2attack;
if p3 = '1' then Result := p2attack1;
end;
if p2 = 'defend' then begin
Result := p2defend;
end;
end;
end;
function TDuel.getFieldInt(p1: ansistring; p2: ansistring; p3: ansistring = ''): integer;
begin
if p1 = 'player' then begin
if p2 = '1' then Result := player1;
if p2 = '2' then Result := player2;
end;
if p1 = 'p' then begin
if p2 = '1' then begin
if p3 = 'dmg' then Result := p1dmg;
end;
if p2 = '2' then begin
if p3 = 'dmg' then Result := p2dmg;
end;
end;
end;
procedure TDuel.updFieldInt(p1: ansistring; p2: ansistring; value: integer);
begin
if p1 = 'p1' then begin
if p2 = 'dmg' then p1dmg := p1dmg + value;
end;
if p1 = 'p2' then begin
if p2 = 'dmg' then p2dmg := p2dmg + value;
end;
end;
Вот такой шедевр программерской мысли остался в коде сервера браузерки от первых девелоперов. Я так и не распарсил пока, что он делает-)
+171
if($pos === false){
$true = true;
}
else{
$true = false;
}
if($true){ /* тут код */ }
Просто оставлю это здесь.
+2
void KateQuickOpen::update () {
// пропущено
QModelIndex idxToSelect;
int linecount = 0;
QMapIterator<qint64, KTextEditor::View *> i2(sortedViews);
while (i2.hasNext()) {
i2.next();
KTextEditor::Document *doc = i2.value()->document();
if (alreadySeenDocs.contains(doc))
continue;
alreadySeenDocs.insert (doc);
QStandardItem *itemName = new QStandardItem(doc->documentName());
itemName->setData(qVariantFromValue(QPointer<KTextEditor::Document> (doc)), DocumentRole);
itemName->setData(QString("%1: %2").arg(doc->documentName()).arg(doc->url().pathOrUrl()), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(doc->url().pathOrUrl());
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
if (!doc->url().isEmpty() && doc->url().isLocalFile())
alreadySeenFiles.insert (doc->url().toLocalFile());
// select second document, that is the last used (beside the active one)
if (linecount == 2)
idxToSelect = itemName->index();
}
// get all open documents
QList<KTextEditor::Document*> docs = Kate::application()->documentManager()->documents();
foreach(KTextEditor::Document *doc, docs) {
// skip docs already open
if (alreadySeenDocs.contains (doc))
continue;
QStandardItem *itemName = new QStandardItem(doc->documentName());
itemName->setData(qVariantFromValue(QPointer<KTextEditor::Document> (doc)), DocumentRole);
itemName->setData(QString("%1: %2").arg(doc->documentName()).arg(doc->url().pathOrUrl()), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(doc->url().pathOrUrl());
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
if (!doc->url().isEmpty() && doc->url().isLocalFile())
alreadySeenFiles.insert (doc->url().toLocalFile());
}
// insert all project files, if any project around
if (Kate::PluginView *projectView = m_mainWindow->mainWindow()->pluginView ("kateprojectplugin")) {
QStringList projectFiles = projectView->property ("projectFiles").toStringList();
foreach (const QString &file, projectFiles) {
// skip files already open
if (alreadySeenFiles.contains (file))
continue;
QFileInfo fi (file);
QStandardItem *itemName = new QStandardItem(fi.fileName());
itemName->setData(qVariantFromValue(KUrl::fromPath (file)), UrlRole);
itemName->setData(QString("%1: %2").arg(fi.fileName()).arg(file), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(file);
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
}
}
// swap models and kill old one
m_model->setSourceModel (base_model);
delete m_base_model;
m_base_model = base_model;
// пропущено
}
Адская копипаста. У меня мозг сегфолтится при попытке ее формализировать.
https://projects.kde.org/projects/kde/applications/kate/repository/revisions/master/entry/kate/app/katequickopen.cpp#L135
−120
Option Explicit
Dim HTMLCode As String 'переменная для хранения кода страницы
Private Sub Command1_Click()
Winsock1.RemotePort = 80 'устанавливаем порт сервера 80
Winsock1.RemoteHost = "ippages.com" 'Хост
Winsock1.Connect 'Подключаемся
Label4.Caption = Winsock2.LocalIP
End Sub
Function CutIP(HTML As String) As String
Dim p1 As Integer
p1 = InStr(HTML, "Content-Type: text/html")
CutIP = Trim(Mid(HTML, p1 + 27, Len(HTML) - p1 - 23))
End Function
Private Sub Label1_Click()
End Sub
Private Sub Winsock1_Close() 'Событие генерируется при закрытии Канала связи
Form1.Caption = "Не подключен" 'Просто сообщаем о том что не подключены
Winsock1.Close
End Sub
Private Sub Winsock1_Connect() 'Событие генерируется при подключении
Form1.Caption = "Подключение" 'Подключены
'Посылаем запрос на сервер выдающему наш IP
Winsock1.SendData "GET " + "/simple/" + " HTTP/1.0" + Chr(10) + Chr(10)
End Sub
'Событие генерируется когда нам приходят данные
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Temp As String
Winsock1.GetData HTMLCode
Label1.Caption = CutIP(HTMLCode)
End Sub
Получение ай-пи адреса посредством отправки на сайт запроса через компонент WinSock.
http://vbbook.ru/visual-basic/polychenie-svoego-ip/
Строго говоря, это не лажа кодера, просто используется (по незнанию?) очень глючный и непредсказуемый компонент.
Fixed by me:
Function GetCurrentIP() As String
Dim txt As String
Dim i, j As Integer
Dim mshttp As New XMLHTTP 'по умолчанию сервер всегда зареган.
mshttp.open "GET", "http://checkip.dyndns.org/", False ' синхронный get
mshttp.send
txt = mshttp.responseText
i = InStr(1, txt, ":")
If i > 0 Then
i = i + 1
Else
GetCurrentIP = "" ' удобно было бы, если по присваиванию, подобному этому, происходило покидание процедуры. Ан, нет.
Exit Function
End If
j = InStr(i, txt, "</")
If j < 1 Then
GetCurrentIP = ""
Exit Function
End If
GetCurrentIP = Trim(Mid(txt, i, j - i))
End Function
−184
- (Pt) menuItemPos: (int) i colRef: (int *) colr
{
int rowBeg [6] = { 1, 8, 15, 22, 28, 100 };
float rowNum [6] = { 7, 7, 7, 6.0, 5.0 };// { 7.03, 6.72, 7, 5.65, 4.43 };
int col = -5;
int row = -5;
for(int j = 1; j < 6; ++j)
if(i < rowBeg[j] && i >= rowBeg[j - 1])
{
row = j - 1;
col = i - rowBeg[row];
*colr = col;
break;
}
float S = _large ? 80 : 30;
float W = _large ? 1474/2 : 320;
float w = W - 2 * S;
float dx = w / (rowNum[row] - 1);
// float scX = _large ? 2.1 : 1.0;
float scY = _large ? 2.0 : 1.0;
float aX = _large ? 18 : 0;
return ccp( (S + col * dx) + aX, (210 - row * 56.0) * scY);
}
Хардкодинг 90 уровня. Все константы подобраны вручную, с заботой и любовью.
+70
.
buffer.put(Transaction.getTransaction((JSONObject)transactionsData.get(j)).getBytes());
Вложенность, например. Но это нужно видеть целиком.
https://bitbucket.org/JeanLucPicard/nxt-public/src/
−157
SELECT ...
FROM ...
WHERE (CASE WHEN big_part = 1 AND blk_flag = 2 THEN -1 ELSE 0 END) <> -1
;
+139
var date = (DateTime.UtcNow.Date > DateTime.UtcNow ? DateTime.UtcNow.AddSeconds(1) : (DateTime.UtcNow.Date < DateTime.UtcNow ? DateTime.UtcNow.Date.AddSeconds(1) : DateTime.UtcNow));
Обнаружил сегодня в процессе код ревью (получение даты в каком-то тесте, который писал джуниор). Пребываю в состоянии когнитивного диссонанса...