- 1
decode(coalesce(d.modif19,'0'),'0','0',d.modif19)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−168
decode(coalesce(d.modif19,'0'),'0','0',d.modif19)
+86
function IsMemoryCommitByAdress(const AAddress: Pointer): Boolean;
var
MemoryInfo: TMemoryBasicInformation;
begin
Result := False;
if not Assigned(AAddress) then
Exit;
VirtualQuery(AAddress, MemoryInfo, SizeOf(MemoryInfo));
Result := MemoryInfo.State and MEM_COMMIT <> 0;
end;
function IsPointerToVMT(const APointer: Pointer): Boolean;
var
VMTPointer, VMTPointerSelf: Pointer;
begin
Result := False;
if not IsMemoryCommitByAdress(APointer) then
Exit;
VMTPointer := APointer;
VMTPointerSelf := Pointer(Integer(VMTPointer) + vmtSelfPtr);
if not IsMemoryCommitByAdress(VMTPointer) then
Exit;
if not IsMemoryCommitByAdress(VMTPointerSelf) then
Exit;
if not IsMemoryCommitByAdress(PPointer(VMTPointerSelf)^) then
Exit;
Result := PPointer(VMTPointerSelf)^ = VMTPointer;
end;
function IsBadptr(apointer:pointer):boolean;
begin
Result := IsMemoryCommitByAdress(APointer) and IsPointerToVMT(PPointer(APointer)^);
end;
Функция, для определения качества указателя, в ситуации "один объект - несколько указателей".
Гк в том, что нет надежности - это все равно, что юзать IsBadReadPtr и аналогичные.
Почему-то никто не пытается использовать операторы is и as (я узнал о них благодаря Тарасу, спасибо ему), чтобы сравнить качество приведения.
+138
bool ExcludeCase4(int iDepth)
{
MyNodeType pN = mPath[iDepth];
if (pN != null)
if (pN.AuxField.bRed) return false;
MyNodeType pP = mPath[iDepth - 1];
if (!pP.AuxField.bRed) return false;
MyNodeType pS;
if (LeftSon(iDepth))
pS = pP.pRight;
else
pS = pP.pLeft;
if (pS == null)
{
pP.AuxField.bRed = false;
iDepthBad = -1;
return true;
}
if (pS.AuxField.bRed) return false;
MyNodeType pSL = pS.pLeft;
if (pSL != null)
if (pSL.AuxField.bRed) return false;
MyNodeType pSR = pS.pRight;
if (pSR != null)
if (pSR.AuxField.bRed) return false;
pS.AuxField.bRed = true;
pP.AuxField.bRed = false;
iDepthBad = -1;
return true;
// Дерево стало хорошим. Корректировать больше не надо.
}
bool ExcludeCase6(int iDepth)
{
MyNodeType pN, pP, pS;
bool bLeft, bRedP;
pN = mPath[iDepth];
if (pN != null)
if (pN.AuxField.bRed) return false;
pP = mPath[iDepth - 1];
bRedP = pP.AuxField.bRed;
bLeft = LeftSon(iDepth);
if (bLeft)
pS = pP.pRight;
else
pS = pP.pLeft;
if (pS == null) return false;
if (pS.AuxField.bRed) return false;
MyNodeType pSL, pSR, p2, p3;
pSL = pS.pLeft;
pSR = pS.pRight;
if (bLeft)
{
if (pSR == null || pSR != null && !pSR.AuxField.bRed)
{
if (pSL == null) return false;
if (!pSL.AuxField.bRed) return false;
// Сюда попали => это Случай 5.
p2 = pSL.pRight;
pSL.pRight = pS;
pS.pLeft = p2;
pSL.AuxField.bRed = false;
pS.AuxField.bRed = true;
pP.pRight = pSL;
pSR = pS;
pS = pSL;
}
else
if (!pSR.AuxField.bRed) return false;
// Сюда попали => это Случай 6.
,......}
кусочек красно-черного дерева, необходимый, но не достаточный
+87
public BarrierAssessment(int id, Client client, int homephone, int mobile, int email, int transport, int licence, boolean notInWorkForce, boolean unpaidWork, boolean cdeProgram, boolean notWorkingBut, int paidWork,
String employerOcc, String reason, int highlevel, String further, int stableAccomodation, int loneParent, int livingWith, int policeProblems, int courtPending, int preventFrom, int medical, int drugTest, int currentBusy,
String scurrentBusy, String reasonForNotGettingJob, int startTomorrow, String jobGoals, int currentResume, int canvasLetter, int referees, int interviewClothing, String otherBarriers, int ec, LastModified lastModified,
Date datestamp, Date bupdated, String disabilityBarriers, Date licenceDueToExpire, Date licenceDueBack, String currentSkills, String possibleSkills) {
...
}
Мать всех конструкторов!
+74
import java.io.*;
import java.util.*;
public class Solution
{
public static void main(String[] args) throws Exception
{ Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int z = scanner.nextInt();
if (a < b && a < c && a < z)
{ if (b < c && b < z)
{if (c < z)
{System.out.println(z + " " + c + " " + b + " " + a);}
else
{System.out.println(c + " " + z + " " + b + " " + a);} }
else if (c < b && c < z)
{ if (b < z)
{System.out.println(z + " " + b + " " + c + " " + a);}
else
{System.out.println(b + " " + z + " " + c + " " + a);} }
else if (z < c && z < b)
{ if (c < b)
{System.out.println(b + " " + c + " " + z + " " + a);}
else
{System.out.println(c + " " + b + " " + z + " " + a);} } }
else if (b < a && b < c && b < z)
{ if (a < c && a < z)
{ if (c < z)
{System.out.println(z + " " + c + " " + a + " " + b);}
else
{System.out.println(c + " " + z + " " + a + " " + b);} }
else if (c < a && c < z)
{ if (a < z)
{System.out.println(z + " " + a + " " + c + " " + b);}
else
{System.out.println(a + " " + z + " " + c + " " + b);} }
else if (z < a && z < c)
{ if (a < c)
{System.out.println(c + " " + a + " " + z + " " + b);}
else
{System.out.println(a + " " + c + " " + z + " " + b);} } }
else if (c < a && c < b && c < z)
{ if (a < b && a < z)
{ if (b < z)
{System.out.println(z + " " + b + " " + a + " " + c);}
else
{System.out.println(b + " " + z + " " + a + " " + c);} }
else if (b < a && b < z)
{ if (a < z)
{System.out.println(z + " " + a + " " + b + " " + c);}
else
{System.out.println(a + " " + z + " " + b + " " + c);} }
else if (z < a && z < b)
{ if (a < b)
{System.out.println(b + " " + a + " " + z + " " + c);}
else
{System.out.println(a + " " + b + " " + z + " " + c);} } }
else if (z < a && z < b && z < c)
{ if (a < c && a < b)
{ if (c < b)
{System.out.println(b + " " + c + " " + a + " " + z);}
else
{System.out.println(c + " " + b + " " + a + " " + z);} }
else if (c < a && c < b)
{ if (a < b)
{System.out.println(b + " " + a + " " + c + " " + z);}
else
{System.out.println(a + " " + b + " " + c + " " + z);} }
else if (b < a && b < c)
{
if (a < c)
{System.out.println(c + " " + a + " " + b + " " + z);}
else
{System.out.println(a + " " + c + " " + b + " " + z);} } }
}
}
Ня!
+136
static string[] ArrayFuller(string pathToFile)
{
int rr = 0;
StreamReader sr=new StreamReader(pathToFile);
while(!sr.EndOfStream){
sr.ReadLine();
rr++;
}
StreamReader sr2 = new StreamReader(pathToFile);
string[] arrayBox = new string[rr];
for (int i = 0; i < rr; i++)
{
arrayBox[i] = Convert.ToString(sr2.ReadLine());
}
sr2.Close();
return arrayBox;
}
+79
public Long getRecordCount() {
long result = 0;
if(pfrFile != null){
if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ() != null){
result++;
}
if(pfrFile.getПачкаВходящихДокументов().getРСВ1() != null){
result++;
}
if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_СВ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ_НАЧИНАЯ_С_2012_ГОДА() != null){
result++;
}
if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_СВ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ_НАЧИНАЯ_С_2013_ГОДА() != null){
result++;
}
...
return result;
}
:D
+74
/**
* Some UI hacks for JRuby Facet
*/
public class NiiChAVOUtil {
}
Слова лишнии
+133
string parser(string chto, string chem)
{
int dlina = chem.Length;
int kol = chto.Length;
string ret = null;
int shet = 0;
int r = 0;
int nom = 0;
for (int i = 0; i < kol; i++)
{
if (chto[i] == chem[0] && shet == 0)
{
for (int j = i; j < dlina + i; j++)
{
if (chto[j] == chem[r])
{
r++;
shet++;
nom = j;
}
}
if (shet != dlina)
{
shet = 0;
r = 0;
nom = 0;
}
}
}
int schet = nom + 3;
while (chto[schet] != '<')
{
ret += chto[schet];
schet++;
}
return ret;
}
Функция для парсинга подстроки
+156
if ((int)($basket->summ/1000) > 999)
{
$price_all = substr_replace($basket->summ," ",1,0);
$price_all = substr_replace($price_all," ",5,0);
}
elseif ((int)($basket->summ/1000) > 99)
{
$price_all = substr_replace($basket->summ," ",3,0);
}
elseif ((int)($basket->summ/1000) > 9)
{
$price_all = substr_replace($basket->summ," ",2,0);
}
elseif ((int)($basket->summ/1000) < 9 && (int)($basket->summ/1000) > 0)
{
$price_all = substr_replace($basket->summ," ",1,0);
}
elseif ((int)($basket->summ/1000) == 0)
{
$price_all = $basket->summ;
}
Вот так вот у нас на офисе коллега форматировал цену...